From owner-freebsd-net@FreeBSD.ORG Fri Jan 6 20:56:56 2012 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4A82B1065706; Fri, 6 Jan 2012 20:56:56 +0000 (UTC) (envelope-from bz@freebsd.org) Received: from mx1.sbone.de (mx1.sbone.de [IPv6:2a01:4f8:130:3ffc::401:25]) by mx1.freebsd.org (Postfix) with ESMTP id D18CE8FC12; Fri, 6 Jan 2012 20:56:55 +0000 (UTC) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:31::2013:587]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.sbone.de (Postfix) with ESMTPS id F2F7425D3A00; Fri, 6 Jan 2012 20:56:54 +0000 (UTC) Received: from content-filter.sbone.de (content-filter.sbone.de [IPv6:fde9:577b:c1a9:31::2013:2742]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id 32949BD89EC; Fri, 6 Jan 2012 20:56:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:31::2013:587]) by content-filter.sbone.de (content-filter.sbone.de [fde9:577b:c1a9:31::2013:2742]) (amavisd-new, port 10024) with ESMTP id BruLBP7ImpBC; Fri, 6 Jan 2012 20:56:52 +0000 (UTC) Received: from orange-en1.sbone.de (orange-en1.sbone.de [IPv6:fde9:577b:c1a9:31:cabc:c8ff:fecf:e8e3]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id BAF91BD89EA; Fri, 6 Jan 2012 20:56:52 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: "Bjoern A. Zeeb" In-Reply-To: <201201061539.55984.jhb@freebsd.org> Date: Fri, 6 Jan 2012 20:56:52 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201112221130.01823.jhb@freebsd.org> <201112291527.26763.jhb@freebsd.org> <201201061539.55984.jhb@freebsd.org> To: John Baldwin X-Mailer: Apple Mail (2.1084) Cc: freebsd-net@freebsd.org, Robert Watson Subject: Re: Transitioning if_addr_lock to an rwlock X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Jan 2012 20:56:56 -0000 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!