svn commit: r229873 - in head/sys: kern net
John Baldwin
jhb at FreeBSD.org
Mon Jan 9 19:34:12 UTC 2012
Author: jhb
Date: Mon Jan 9 19:34:12 2012
New Revision: 229873
URL: http://svn.freebsd.org/changeset/base/229873
Log:
Convert the per-interface address list lock from a mutex to a reader/writer
lock.
Reviewed by: bz
Modified:
head/sys/kern/subr_witness.c
head/sys/net/if_var.h
Modified: head/sys/kern/subr_witness.c
==============================================================================
--- head/sys/kern/subr_witness.c Mon Jan 9 19:31:35 2012 (r229872)
+++ head/sys/kern/subr_witness.c Mon Jan 9 19:34:12 2012 (r229873)
@@ -520,7 +520,7 @@ static struct witness_order_list_entry o
{ "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 @@ static struct witness_order_list_entry o
{ "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
Modified: head/sys/net/if_var.h
==============================================================================
--- head/sys/net/if_var.h Mon Jan 9 19:31:35 2012 (r229872)
+++ head/sys/net/if_var.h Mon Jan 9 19:34:12 2012 (r229873)
@@ -189,11 +189,11 @@ struct ifnet {
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 */
LIST_ENTRY(ifnet) if_clones; /* interfaces of a cloner */
TAILQ_HEAD(, ifg_list) if_groups; /* linked list of groups per if */
- /* protected by if_addr_mtx */
+ /* protected by if_addr_lock */
void *if_pf_kif;
void *if_lagg; /* lagg glue */
char *if_description; /* interface description */
@@ -246,15 +246,14 @@ typedef void if_init_f_t(void *);
/*
* 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)
More information about the svn-src-all
mailing list