diff options
author | jhb <jhb@FreeBSD.org> | 2012-01-09 19:34:12 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2012-01-09 19:34:12 +0000 |
commit | 0577b44f7395fee798c50b2e4f6f24d717dabeb7 (patch) | |
tree | 54a20ac5995236347ac839258d02f70c54300efc | |
parent | 5b2011f996582d2355336fa0cb0104ebb253cfc2 (diff) | |
download | FreeBSD-src-0577b44f7395fee798c50b2e4f6f24d717dabeb7.zip FreeBSD-src-0577b44f7395fee798c50b2e4f6f24d717dabeb7.tar.gz |
Convert the per-interface address list lock from a mutex to a reader/writer
lock.
Reviewed by: bz
-rw-r--r-- | sys/kern/subr_witness.c | 4 | ||||
-rw-r--r-- | sys/net/if_var.h | 21 |
2 files changed, 12 insertions, 13 deletions
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 55cb2d7..bd2a5cb 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -520,7 +520,7 @@ static struct witness_order_list_entry order_lists[] = { { "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 order_lists[] = { { "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 diff --git a/sys/net/if_var.h b/sys/net/if_var.h index e78f287..d1157af 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -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) |