[PATCH v2 2/5] cgroup: Do not add sock_update_classid() when CONFIG_NET_CLS_CGROUP=0
DORMANTno replies
From: Daniel Wagner <hidden>
Date: 2012-07-11 09:35:38
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_NET_CLS_CGROUP=0 sock_update_classid() was still added and introduced unnecessary load. Also remove cls cgroup related definition form sock.h. The only user is socket.h which includes cls_cgroup.h direclty. Signed-off-by: Daniel Wagner <redacted> Cc: Neil Horman <redacted> Cc: Glauber Costa <redacted> Cc: Kamezawa Hiroyuki <redacted> Cc: Tejun Heo <redacted> Cc: Li Zefan <redacted> Cc: Eric Dumazet <redacted> Cc: "David S. Miller" <redacted> --- include/net/cls_cgroup.h | 33 +++++++++++++++++++++++---------- include/net/sock.h | 8 -------- net/core/sock.c | 4 +++- 3 files changed, 26 insertions(+), 19 deletions(-)
diff --git a/include/net/cls_cgroup.h b/include/net/cls_cgroup.h
index a4dc5b0..d2a8cfa 100644
--- a/include/net/cls_cgroup.h
+++ b/include/net/cls_cgroup.h@@ -17,14 +17,29 @@ #include <linux/hardirq.h> #include <linux/rcupdate.h> -#ifdef CONFIG_CGROUPS +#if IS_ENABLED(CONFIG_NET_CLS_CGROUP) + struct cgroup_cls_state { struct cgroup_subsys_state css; u32 classid; }; -#ifdef CONFIG_NET_CLS_CGROUP +extern void sock_update_classid(struct sock *sk); + +#else + +#define sock_update_classid(sk) + +static inline u32 task_cls_classid(struct task_struct *p) +{ + return 0; +} + +#endif + +#if IS_BUILTIN(CONFIG_NET_CLS_CGROUP) + static inline u32 task_cls_classid(struct task_struct *p) { int classid;
@@ -39,7 +54,9 @@ static inline u32 task_cls_classid(struct task_struct *p) return classid; } -#else + +#elif IS_MODULE(CONFIG_NET_CLS_CGROUP) + extern int net_cls_subsys_id; static inline u32 task_cls_classid(struct task_struct *p)
@@ -60,11 +77,7 @@ static inline u32 task_cls_classid(struct task_struct *p) return classid; } -#endif -#else -static inline u32 task_cls_classid(struct task_struct *p) -{ - return 0; -} -#endif + +#endif /* CONFIG_NET_CLS_GROUP */ + #endif /* _NET_CLS_CGROUP_H */
diff --git a/include/net/sock.h b/include/net/sock.h
index dcb54a0..6282230 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h@@ -1451,14 +1451,6 @@ extern void *sock_kmalloc(struct sock *sk, int size, extern void sock_kfree_s(struct sock *sk, void *mem, int size); extern void sk_send_sigurg(struct sock *sk); -#ifdef CONFIG_CGROUPS -extern void sock_update_classid(struct sock *sk); -#else -static inline void sock_update_classid(struct sock *sk) -{ -} -#endif - /* * Functions to fill in entries in struct proto_ops when a protocol * does not implement a particular function.
diff --git a/net/core/sock.c b/net/core/sock.c
index bbab10d..52c4a2a 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c@@ -272,7 +272,7 @@ int sysctl_optmem_max __read_mostly = sizeof(unsigned long)*(2*UIO_MAXIOV+512); EXPORT_SYMBOL(sysctl_optmem_max); #if defined(CONFIG_CGROUPS) -#if !defined(CONFIG_NET_CLS_CGROUP) +#if IS_MODULE(CONFIG_NET_CLS_CGROUP) int net_cls_subsys_id = -1; EXPORT_SYMBOL_GPL(net_cls_subsys_id); #endif
@@ -1168,6 +1168,7 @@ static void sk_prot_free(struct proto *prot, struct sock *sk) } #ifdef CONFIG_CGROUPS +#if IS_ENABLED(CONFIG_NET_CLS_CGROUP) void sock_update_classid(struct sock *sk) { u32 classid;
@@ -1179,6 +1180,7 @@ void sock_update_classid(struct sock *sk) sk->sk_classid = classid; } EXPORT_SYMBOL(sock_update_classid); +#endif void sock_update_netprioidx(struct sock *sk) {
--
1.7.11.1.165.g299666c