diff options
author | Kristof Provost <kp@FreeBSD.org> | 2020-12-11 14:11:41 +0000 |
---|---|---|
committer | Kristof Provost <kp@FreeBSD.org> | 2020-12-11 14:11:41 +0000 |
commit | 42df5a4995fc34402e0e11924948f6714876b597 (patch) | |
tree | 4fe82296cc936d1066d07275ec0ff18453112e7d | |
parent | f441f76e11ace0098fddabd9e87bb24fbf4c50f2 (diff) | |
download | src-test2-42df5a4995fc34402e0e11924948f6714876b597.tar.gz src-test2-42df5a4995fc34402e0e11924948f6714876b597.zip |
Notes
-rw-r--r-- | sys/net/if.c | 8 | ||||
-rw-r--r-- | sys/net/if_var.h | 24 |
2 files changed, 6 insertions, 26 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index da55e4b64c72..fd7689e0ead0 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -305,12 +305,8 @@ VNET_DEFINE(struct ifnet **, ifindex_table); /* * The global network interface list (V_ifnet) and related state (such as - * if_index, if_indexlim, and ifindex_table) are protected by an sxlock and - * an rwlock. Either may be acquired shared to stablize the list, but both - * must be acquired writable to modify the list. This model allows us to - * both stablize the interface list during interrupt thread processing, but - * also to stablize it over long-running ioctls, without introducing priority - * inversions and deadlocks. + * if_index, if_indexlim, and ifindex_table) are protected by an sxlock. + * This may be acquired to stabilise the list, or we may rely on NET_EPOCH. */ struct rwlock ifnet_rwlock; RW_SYSINIT_FLAGS(ifnet_rw, &ifnet_rwlock, "ifnet_rw", RW_RECURSE); diff --git a/sys/net/if_var.h b/sys/net/if_var.h index b0be4b9421a2..44334e67cc5c 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -569,27 +569,11 @@ struct ifmultiaddr { extern struct rwlock ifnet_rwlock; extern struct sx ifnet_sxlock; -#define IFNET_WLOCK() do { \ - sx_xlock(&ifnet_sxlock); \ - rw_wlock(&ifnet_rwlock); \ -} while (0) - -#define IFNET_WUNLOCK() do { \ - rw_wunlock(&ifnet_rwlock); \ - sx_xunlock(&ifnet_sxlock); \ -} while (0) - -/* - * To assert the ifnet lock, you must know not only whether it's for read or - * write, but also whether it was acquired with sleep support or not. - */ -#define IFNET_RLOCK_ASSERT() sx_assert(&ifnet_sxlock, SA_SLOCKED) +#define IFNET_WLOCK() sx_xlock(&ifnet_sxlock) +#define IFNET_WUNLOCK() sx_xunlock(&ifnet_sxlock) +#define IFNET_RLOCK_ASSERT() sx_assert(&ifnet_sxlock, SA_SLOCKED) #define IFNET_RLOCK_NOSLEEP_ASSERT() MPASS(in_epoch(net_epoch_preempt)) -#define IFNET_WLOCK_ASSERT() do { \ - sx_assert(&ifnet_sxlock, SA_XLOCKED); \ - rw_assert(&ifnet_rwlock, RA_WLOCKED); \ -} while (0) - +#define IFNET_WLOCK_ASSERT() sx_assert(&ifnet_sxlock, SA_XLOCKED) #define IFNET_RLOCK() sx_slock(&ifnet_sxlock) #define IFNET_RLOCK_NOSLEEP() struct epoch_tracker ifnet_rlock_et; epoch_enter_preempt(net_epoch_preempt, &ifnet_rlock_et) #define IFNET_RUNLOCK() sx_sunlock(&ifnet_sxlock) |