Commit 4bd2c1ee authored by Michal Hocko's avatar Michal Hocko Committed by Linus Torvalds

memcg: cleanup kmem tcp ifdefs

TCP kmem accounting is currently guarded by CONFIG_MEMCG_KMEM ifdefs but
the code is not used if !CONFIG_INET so we should rather test for both.
The same applies to net/sock.h, net/ip.h and net/tcp_memcontrol.h but
let's keep those outside of any ifdefs because it is considered safer wrt.
 future maintainability.

Tested with
- CONFIG_INET && CONFIG_MEMCG_KMEM
- !CONFIG_INET && CONFIG_MEMCG_KMEM
- CONFIG_INET && !CONFIG_MEMCG_KMEM
- !CONFIG_INET && !CONFIG_MEMCG_KMEM
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: default avatarMichal Hocko <mhocko@suse.cz>
Cc: Glauber Costa <glommer@parallels.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1939c557
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include <linux/oom.h> #include <linux/oom.h>
#include "internal.h" #include "internal.h"
#include <net/sock.h> #include <net/sock.h>
#include <net/ip.h>
#include <net/tcp_memcontrol.h> #include <net/tcp_memcontrol.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -326,7 +327,7 @@ struct mem_cgroup { ...@@ -326,7 +327,7 @@ struct mem_cgroup {
struct mem_cgroup_stat_cpu nocpu_base; struct mem_cgroup_stat_cpu nocpu_base;
spinlock_t pcp_counter_lock; spinlock_t pcp_counter_lock;
#ifdef CONFIG_INET #if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_INET)
struct tcp_memcontrol tcp_mem; struct tcp_memcontrol tcp_mem;
#endif #endif
}; };
...@@ -412,9 +413,7 @@ struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *s) ...@@ -412,9 +413,7 @@ struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *s)
} }
/* Writing them here to avoid exposing memcg's inner layout */ /* Writing them here to avoid exposing memcg's inner layout */
#ifdef CONFIG_MEMCG_KMEM #if defined(CONFIG_INET) && defined(CONFIG_MEMCG_KMEM)
#include <net/sock.h>
#include <net/ip.h>
static bool mem_cgroup_is_root(struct mem_cgroup *memcg); static bool mem_cgroup_is_root(struct mem_cgroup *memcg);
void sock_update_memcg(struct sock *sk) void sock_update_memcg(struct sock *sk)
...@@ -461,7 +460,6 @@ void sock_release_memcg(struct sock *sk) ...@@ -461,7 +460,6 @@ void sock_release_memcg(struct sock *sk)
} }
} }
#ifdef CONFIG_INET
struct cg_proto *tcp_proto_cgroup(struct mem_cgroup *memcg) struct cg_proto *tcp_proto_cgroup(struct mem_cgroup *memcg)
{ {
if (!memcg || mem_cgroup_is_root(memcg)) if (!memcg || mem_cgroup_is_root(memcg))
...@@ -470,10 +468,7 @@ struct cg_proto *tcp_proto_cgroup(struct mem_cgroup *memcg) ...@@ -470,10 +468,7 @@ struct cg_proto *tcp_proto_cgroup(struct mem_cgroup *memcg)
return &memcg->tcp_mem.cg_proto; return &memcg->tcp_mem.cg_proto;
} }
EXPORT_SYMBOL(tcp_proto_cgroup); EXPORT_SYMBOL(tcp_proto_cgroup);
#endif /* CONFIG_INET */
#endif /* CONFIG_MEMCG_KMEM */
#if defined(CONFIG_INET) && defined(CONFIG_MEMCG_KMEM)
static void disarm_sock_keys(struct mem_cgroup *memcg) static void disarm_sock_keys(struct mem_cgroup *memcg)
{ {
if (!memcg_proto_activated(&memcg->tcp_mem.cg_proto)) if (!memcg_proto_activated(&memcg->tcp_mem.cg_proto))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment