Annotate Giant drop/pickup macros with __predict_false

They are used in important places of the kernel with the lock not being held
majority of the time.

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Mateusz Guzik 2018-12-07 12:06:03 +00:00
parent afacf95d5c
commit 6e8c1ccbe2
2 changed files with 4 additions and 4 deletions

View File

@ -96,14 +96,14 @@ CTASSERT(LK_UNLOCKED == (LK_UNLOCKED &
int _i = 0; \
WITNESS_SAVE_DECL(Giant)
#define GIANT_RESTORE() do { \
if (_i > 0) { \
if (__predict_false(_i > 0)) { \
while (_i--) \
mtx_lock(&Giant); \
WITNESS_RESTORE(&Giant.lock_object, Giant); \
} \
} while (0)
#define GIANT_SAVE() do { \
if (mtx_owned(&Giant)) { \
if (__predict_false(mtx_owned(&Giant))) { \
WITNESS_SAVE(&Giant.lock_object, Giant); \
while (mtx_owned(&Giant)) { \
_i++; \

View File

@ -496,7 +496,7 @@ do { \
int _giantcnt = 0; \
WITNESS_SAVE_DECL(Giant); \
\
if (mtx_owned(&Giant)) { \
if (__predict_false(mtx_owned(&Giant))) { \
WITNESS_SAVE(&Giant.lock_object, Giant); \
for (_giantcnt = 0; mtx_owned(&Giant) && \
!SCHEDULER_STOPPED(); _giantcnt++) \
@ -509,7 +509,7 @@ do { \
#define PARTIAL_PICKUP_GIANT() \
mtx_assert(&Giant, MA_NOTOWNED); \
if (_giantcnt > 0) { \
if (__predict_false(_giantcnt > 0)) { \
while (_giantcnt--) \
mtx_lock(&Giant); \
WITNESS_RESTORE(&Giant.lock_object, Giant); \