Date: Thu, 13 Sep 2007 01:34:00 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 126350 for review Message-ID: <200709130134.l8D1Y0UV014654@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=126350 Change 126350 by kmacy@kmacy_home:ethng on 2007/09/13 01:32:58 update rnh locking primitives to account for the fact that the lock can be recursed Affected files ... .. //depot/projects/ethng/src/sys/net/radix.h#4 edit Differences ... ==== //depot/projects/ethng/src/sys/net/radix.h#4 (text+ko) ==== @@ -145,13 +145,26 @@ #define Free(p) free((caddr_t)p, M_RTABLE); #define RADIX_NODE_HEAD_LOCK_INIT(rnh) \ -rw_init(&(rnh)->rnh_lock, "radix node head") + rw_init_flags(&(rnh)->rnh_lock, "radix node head", RW_RECURSE) #define RADIX_NODE_HEAD_LOCK(rnh) rw_wlock(&(rnh)->rnh_lock) #define RADIX_NODE_HEAD_UNLOCK(rnh) rw_wunlock(&(rnh)->rnh_lock) -#define RADIX_NODE_HEAD_LOCK_SHARED(rnh) rw_rlock(&(rnh)->rnh_lock) -#define RADIX_NODE_HEAD_UNLOCK_SHARED(rnh) rw_runlock(&(rnh)->rnh_lock) +#define RADIX_NODE_HEAD_LOCK_DOWNGRADE(rnh) rw_downgrade(&(rnh)->rnh_lock) +#define RADIX_NODE_HEAD_LOCK_TRY_UPGRADE(rnh) rw_try_upgrade(&(rnh)->rnh_lock) +#define RADIX_NODE_HEAD_LOCK_SHARED(rnh) \ + do { \ + if (!rw_wowned(&(rnh)->rnh_lock)) \ + rw_rlock(&(rnh)->rnh_lock); \ + } while (0) + +#define RADIX_NODE_HEAD_UNLOCK_SHARED(rnh) \ + do { \ + if (!rw_wowned(&(rnh)->rnh_lock)) \ + rw_runlock(&(rnh)->rnh_lock); \ + } while (0) + #define RADIX_NODE_HEAD_DESTROY(rnh) rw_destroy(&(rnh)->rnh_lock) #define RADIX_NODE_HEAD_LOCK_ASSERT(rnh) rw_assert(&(rnh)->rnh_lock, RA_LOCKED) +#define RADIX_NODE_HEAD_UNLOCK_ASSERT(rnh) rw_assert(&(rnh)->rnh_lock, RA_UNLOCKED) #endif /* _KERNEL */ void rn_init(void);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200709130134.l8D1Y0UV014654>