diff mbox series

[net-next,1/2] net/sched: act_api: uninline tc_action_net_init() and tc_action_net_exit()

Message ID 20240208102508.262907-2-edumazet@google.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net/sched: act_api: speed up netns dismantles | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1106 this patch: 1106
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1066 this patch: 1066
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1150 this patch: 1150
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 89 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-02-08--21-00 (tests: 685)

Commit Message

Eric Dumazet Feb. 8, 2024, 10:25 a.m. UTC
tc_action_net_init() and tc_action_net_exit() are slow path,
and quite big.

tcf_idrinfo_destroy() becomes static.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/net/act_api.h | 33 ++-------------------------------
 net/sched/act_api.c   | 36 +++++++++++++++++++++++++++++++++---
 2 files changed, 35 insertions(+), 34 deletions(-)
diff mbox series

Patch

diff --git a/include/net/act_api.h b/include/net/act_api.h
index 77ee0c657e2c78276ecb2efca7f4c3d28be511a2..8ec97644edf86d5d95960b74b9b57908ca19a198 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -146,39 +146,10 @@  struct tc_action_net {
 	const struct tc_action_ops *ops;
 };
 
-static inline
 int tc_action_net_init(struct net *net, struct tc_action_net *tn,
-		       const struct tc_action_ops *ops)
-{
-	int err = 0;
-
-	tn->idrinfo = kmalloc(sizeof(*tn->idrinfo), GFP_KERNEL);
-	if (!tn->idrinfo)
-		return -ENOMEM;
-	tn->ops = ops;
-	tn->idrinfo->net = net;
-	mutex_init(&tn->idrinfo->lock);
-	idr_init(&tn->idrinfo->action_idr);
-	return err;
-}
-
-void tcf_idrinfo_destroy(const struct tc_action_ops *ops,
-			 struct tcf_idrinfo *idrinfo);
-
-static inline void tc_action_net_exit(struct list_head *net_list,
-				      unsigned int id)
-{
-	struct net *net;
-
-	rtnl_lock();
-	list_for_each_entry(net, net_list, exit_list) {
-		struct tc_action_net *tn = net_generic(net, id);
+		       const struct tc_action_ops *ops);
 
-		tcf_idrinfo_destroy(tn->ops, tn->idrinfo);
-		kfree(tn->idrinfo);
-	}
-	rtnl_unlock();
-}
+void tc_action_net_exit(struct list_head *net_list, unsigned int id);
 
 int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb,
 		       struct netlink_callback *cb, int type,
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 9ee622fb1160fe5de8df9a5fca0c9a412e40e31a..9492eae0ebe5844419e1631122871d19b443bc4e 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -886,8 +886,24 @@  int tcf_idr_check_alloc(struct tc_action_net *tn, u32 *index,
 }
 EXPORT_SYMBOL(tcf_idr_check_alloc);
 
-void tcf_idrinfo_destroy(const struct tc_action_ops *ops,
-			 struct tcf_idrinfo *idrinfo)
+int tc_action_net_init(struct net *net, struct tc_action_net *tn,
+		       const struct tc_action_ops *ops)
+{
+	int err = 0;
+
+	tn->idrinfo = kmalloc(sizeof(*tn->idrinfo), GFP_KERNEL);
+	if (!tn->idrinfo)
+		return -ENOMEM;
+	tn->ops = ops;
+	tn->idrinfo->net = net;
+	mutex_init(&tn->idrinfo->lock);
+	idr_init(&tn->idrinfo->action_idr);
+	return err;
+}
+EXPORT_SYMBOL(tc_action_net_init);
+
+static void tcf_idrinfo_destroy(const struct tc_action_ops *ops,
+				struct tcf_idrinfo *idrinfo)
 {
 	struct idr *idr = &idrinfo->action_idr;
 	struct tc_action *p;
@@ -904,7 +920,21 @@  void tcf_idrinfo_destroy(const struct tc_action_ops *ops,
 	}
 	idr_destroy(&idrinfo->action_idr);
 }
-EXPORT_SYMBOL(tcf_idrinfo_destroy);
+
+void tc_action_net_exit(struct list_head *net_list, unsigned int id)
+{
+	struct net *net;
+
+	rtnl_lock();
+	list_for_each_entry(net, net_list, exit_list) {
+		struct tc_action_net *tn = net_generic(net, id);
+
+		tcf_idrinfo_destroy(tn->ops, tn->idrinfo);
+		kfree(tn->idrinfo);
+	}
+	rtnl_unlock();
+}
+EXPORT_SYMBOL(tc_action_net_exit);
 
 static LIST_HEAD(act_base);
 static DEFINE_RWLOCK(act_mod_lock);