diff mbox series

[net-next,1/2] net: add synchronize_net_expedited()

Message ID 20220313100033.343442-2-equinox@diac24.net (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next,1/2] net: add synchronize_net_expedited() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 4769 this patch: 4769
netdev/cc_maintainers fail 3 maintainers not CCed: davem@davemloft.net edumazet@google.com kuba@kernel.org
netdev/build_clang success Errors and warnings before: 824 this patch: 824
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4924 this patch: 4924
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 27 lines checked
netdev/kdoc success Errors and warnings before: 1 this patch: 1
netdev/source_inline success Was 0 now: 0

Commit Message

David Lamparter March 13, 2022, 10 a.m. UTC
The AF_PACKET code has a bunch of calls to synchronize_net() while in a
syscall from userland.  These become very visible in some applications
(e.g. just plain starting wireshark when the system has a lot of
interfaces.)

Add a "synchronize_net_expedited()" for cases like these.

Signed-off-by: David Lamparter <equinox@diac24.net>
---
 include/linux/netdevice.h |  2 ++
 net/core/dev.c            | 13 +++++++++++++
 2 files changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 0d994710b335..fcc8cfe5e4d8 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -74,6 +74,8 @@  struct bpf_prog;
 struct xdp_buff;
 
 void synchronize_net(void);
+void synchronize_net_expedited(void);
+
 void netdev_set_default_ethtool_ops(struct net_device *dev,
 				    const struct ethtool_ops *ops);
 
diff --git a/net/core/dev.c b/net/core/dev.c
index 8d25ec5b3af7..d53c171040c6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10633,6 +10633,19 @@  void synchronize_net(void)
 }
 EXPORT_SYMBOL(synchronize_net);
 
+/**
+ *	synchronize_net_expedited - synchronize_net, but always expedited
+ *
+ *	Some callers may have reasons other than "RTNL held" to want expedited
+ *	RCU sync.  A prominent example is if the RCU delay is user visible.
+ */
+void synchronize_net_expedited(void)
+{
+	might_sleep();
+	synchronize_rcu_expedited();
+}
+EXPORT_SYMBOL(synchronize_net_expedited);
+
 /**
  *	unregister_netdevice_queue - remove device from the kernel
  *	@dev: device