Date: Fri, 6 Jan 2012 20:56:52 +0000 From: "Bjoern A. Zeeb" <bz@freebsd.org> To: John Baldwin <jhb@freebsd.org> Cc: freebsd-net@freebsd.org, Robert Watson <rwatson@freebsd.org> Subject: Re: Transitioning if_addr_lock to an rwlock Message-ID: <CD2FEBEE-9919-4ED4-A03B-AA591FEA48F0@freebsd.org> In-Reply-To: <201201061539.55984.jhb@freebsd.org> References: <201112221130.01823.jhb@freebsd.org> <201112291527.26763.jhb@freebsd.org> <201201061539.55984.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 6. Jan 2012, at 20:39 , John Baldwin wrote: >=20 > Now that all of this is in the tree, here is the small patch to cut = the locks > over to rwlocks rather than mutexes: I have not checked if that's all (esp. for witness) but the macro = conversion look right. > Index: kern/subr_witness.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- kern/subr_witness.c (revision 229726) > +++ kern/subr_witness.c (working copy) > @@ -520,7 +520,7 @@ > { "udpinp", &lock_class_rw }, > { "in_multi_mtx", &lock_class_mtx_sleep }, > { "igmp_mtx", &lock_class_mtx_sleep }, > - { "if_addr_mtx", &lock_class_mtx_sleep }, > + { "if_addr_lock", &lock_class_rw }, > { NULL, NULL }, > /* > * IPv6 multicast: > @@ -529,7 +529,7 @@ > { "udpinp", &lock_class_rw }, > { "in6_multi_mtx", &lock_class_mtx_sleep }, > { "mld_mtx", &lock_class_mtx_sleep }, > - { "if_addr_mtx", &lock_class_mtx_sleep }, > + { "if_addr_lock", &lock_class_rw }, > { NULL, NULL }, > /* > * UNIX Domain Sockets > Index: net/if_var.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- net/if_var.h (revision 229726) > +++ net/if_var.h (working copy) > @@ -189,7 +189,7 @@ > int if_afdata_initialized; > struct rwlock if_afdata_lock; > struct task if_linktask; /* task for link change events = */ > - struct mtx if_addr_mtx; /* mutex to protect address = lists */ > + struct rwlock if_addr_lock; /* lock to protect address lists = */ >=20 > LIST_ENTRY(ifnet) if_clones; /* interfaces of a cloner */ > TAILQ_HEAD(, ifg_list) if_groups; /* linked list of groups per = if */ > @@ -246,15 +246,14 @@ > /* > * Locks for address lists on the network interface. > */ > -#define IF_ADDR_LOCK_INIT(if) mtx_init(&(if)->if_addr_mtx, = \ > - "if_addr_mtx", NULL, MTX_DEF) > -#define IF_ADDR_LOCK_DESTROY(if) = mtx_destroy(&(if)->if_addr_mtx) > -#define IF_ADDR_WLOCK(if) mtx_lock(&(if)->if_addr_mtx) > -#define IF_ADDR_WUNLOCK(if) mtx_unlock(&(if)->if_addr_mtx) > -#define IF_ADDR_RLOCK(if) mtx_lock(&(if)->if_addr_mtx) > -#define IF_ADDR_RUNLOCK(if) mtx_unlock(&(if)->if_addr_mtx) > -#define IF_ADDR_LOCK_ASSERT(if) mtx_assert(&(if)->if_addr_mtx, = MA_OWNED) > -#define IF_ADDR_WLOCK_ASSERT(if) = mtx_assert(&(if)->if_addr_mtx, MA_OWNED) > +#define IF_ADDR_LOCK_INIT(if) rw_init(&(if)->if_addr_lock, = "if_addr_lock") > +#define IF_ADDR_LOCK_DESTROY(if) = rw_destroy(&(if)->if_addr_lock) > +#define IF_ADDR_WLOCK(if) rw_wlock(&(if)->if_addr_lock) > +#define IF_ADDR_WUNLOCK(if) rw_wunlock(&(if)->if_addr_lock) > +#define IF_ADDR_RLOCK(if) rw_rlock(&(if)->if_addr_lock) > +#define IF_ADDR_RUNLOCK(if) rw_runlock(&(if)->if_addr_lock) > +#define IF_ADDR_LOCK_ASSERT(if) rw_assert(&(if)->if_addr_lock, = RA_LOCKED) > +#define IF_ADDR_WLOCK_ASSERT(if) rw_assert(&(if)->if_addr_lock, = RA_WLOCKED) > /* XXX: Compat. */ > #define IF_ADDR_LOCK(if) IF_ADDR_WLOCK(if) > #define IF_ADDR_UNLOCK(if) IF_ADDR_WUNLOCK(if) >=20 > --=20 > John Baldwin --=20 Bjoern A. Zeeb You have to have visions! It does not matter how good you are. It matters what good you do!
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CD2FEBEE-9919-4ED4-A03B-AA591FEA48F0>