Author: mjg Date: Fri Dec 7 12:06:03 2018 New Revision: 341683 URL: https://svnweb.freebsd.org/changeset/base/341683
Log: 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 Modified: head/sys/kern/kern_lock.c head/sys/sys/mutex.h Modified: head/sys/kern/kern_lock.c ============================================================================== --- head/sys/kern/kern_lock.c Fri Dec 7 12:05:11 2018 (r341682) +++ head/sys/kern/kern_lock.c Fri Dec 7 12:06:03 2018 (r341683) @@ -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++; \ Modified: head/sys/sys/mutex.h ============================================================================== --- head/sys/sys/mutex.h Fri Dec 7 12:05:11 2018 (r341682) +++ head/sys/sys/mutex.h Fri Dec 7 12:06:03 2018 (r341683) @@ -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); \ _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"