[PATCH v2 3/5] cgroup: Do not add sock_update_netprioidx() when CONFIG_NETPRIO_CGROUP=0
From: Daniel Wagner <hidden>
Date: 2012-07-11 09:35:45
Also in:
cgroups
Subsystem:
networking [general], networking [sockets], the rest · Maintainers:
"David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Kuniyuki Iwashima, Willem de Bruijn, Linus Torvalds
From: Daniel Wagner <redacted> With the configuration CONFIG_CGROUPS=y and CONFIG_NETPRIO_CGROUP=0 sock_update_netprioidx() was still added and introduced unnecessary load. Signed-off-by: Daniel Wagner <redacted> Cc: Neil Horman <nhorman@tuxdriver.com> Cc: Glauber Costa <redacted> Cc: Kamezawa Hiroyuki <redacted> Cc: Tejun Heo <tj@kernel.org> Cc: Li Zefan <redacted> Cc: Eric Dumazet <edumazet@google.com> Cc: "David S. Miller" <davem@davemloft.net> --- include/net/netprio_cgroup.h | 31 ++++++++++++++----------------- net/core/sock.c | 4 +++- 2 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/include/net/netprio_cgroup.h b/include/net/netprio_cgroup.h
index d58fdec..d14dfbe 100644
--- a/include/net/netprio_cgroup.h
+++ b/include/net/netprio_cgroup.h@@ -17,6 +17,7 @@ #include <linux/hardirq.h> #include <linux/rcupdate.h> +#if IS_ENABLED(CONFIG_NETPRIO_CGROUP) struct netprio_map { struct rcu_head rcu;
@@ -24,19 +25,24 @@ struct netprio_map { u32 priomap[]; }; -#ifdef CONFIG_CGROUPS - struct cgroup_netprio_state { struct cgroup_subsys_state css; u32 prioidx; }; -#ifndef CONFIG_NETPRIO_CGROUP -extern int net_prio_subsys_id; -#endif - extern void sock_update_netprioidx(struct sock *sk); +#else + +#define sock_update_netprioidx(sk) + +static inline u32 task_netprioidx(struct task_struct *p) +{ + return 0; +} + +#endif + #if IS_BUILTIN(CONFIG_NETPRIO_CGROUP) static inline u32 task_netprioidx(struct task_struct *p)
@@ -54,6 +60,8 @@ static inline u32 task_netprioidx(struct task_struct *p) #elif IS_MODULE(CONFIG_NETPRIO_CGROUP) +extern int net_prio_subsys_id; + static inline u32 task_netprioidx(struct task_struct *p) { struct cgroup_netprio_state *state;
@@ -72,17 +80,6 @@ static inline u32 task_netprioidx(struct task_struct *p) return idx; } -#else - -static inline u32 task_netprioidx(struct task_struct *p) -{ - return 0; -} - #endif /* CONFIG_NETPRIO_CGROUP */ -#else -#define sock_update_netprioidx(sk) -#endif - #endif /* _NET_CLS_CGROUP_H */
diff --git a/net/core/sock.c b/net/core/sock.c
index 52c4a2a..94e0100 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c@@ -276,7 +276,7 @@ EXPORT_SYMBOL(sysctl_optmem_max); int net_cls_subsys_id = -1; EXPORT_SYMBOL_GPL(net_cls_subsys_id); #endif -#if !defined(CONFIG_NETPRIO_CGROUP) +#if IS_MODULE(CONFIG_NETPRIO_CGROUP) int net_prio_subsys_id = -1; EXPORT_SYMBOL_GPL(net_prio_subsys_id); #endif
@@ -1182,6 +1182,7 @@ void sock_update_classid(struct sock *sk) EXPORT_SYMBOL(sock_update_classid); #endif +#if IS_ENABLED(CONFIG_NETPRIO_CGROUP) void sock_update_netprioidx(struct sock *sk) { u32 prioidx;
@@ -1195,6 +1196,7 @@ void sock_update_netprioidx(struct sock *sk) } EXPORT_SYMBOL_GPL(sock_update_netprioidx); #endif +#endif /** * sk_alloc - All socket objects are allocated here
--
1.7.11.1.165.g299666c