diff options
| author | Michal Hocko <mhocko@suse.cz> | 2012-10-08 19:33:10 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-09 03:22:54 -0400 |
| commit | 4bd2c1ee4b439d926e437a4841e8145230df98c9 (patch) | |
| tree | b9bf448dda9bfb5d428928c7f26fd7c7aad30267 /mm | |
| parent | 1939c557b5c3c0e800328e3589ae3d27fdfea29e (diff) | |
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: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Michal Hocko <mhocko@suse.cz>
Cc: Glauber Costa <glommer@parallels.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
| -rw-r--r-- | mm/memcontrol.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index a72f2ffdc3d0..4f5f93657246 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
| @@ -51,6 +51,7 @@ | |||
| 51 | #include <linux/oom.h> | 51 | #include <linux/oom.h> |
| 52 | #include "internal.h" | 52 | #include "internal.h" |
| 53 | #include <net/sock.h> | 53 | #include <net/sock.h> |
| 54 | #include <net/ip.h> | ||
| 54 | #include <net/tcp_memcontrol.h> | 55 | #include <net/tcp_memcontrol.h> |
| 55 | 56 | ||
| 56 | #include <asm/uaccess.h> | 57 | #include <asm/uaccess.h> |
| @@ -326,7 +327,7 @@ struct mem_cgroup { | |||
| 326 | struct mem_cgroup_stat_cpu nocpu_base; | 327 | struct mem_cgroup_stat_cpu nocpu_base; |
| 327 | spinlock_t pcp_counter_lock; | 328 | spinlock_t pcp_counter_lock; |
| 328 | 329 | ||
| 329 | #ifdef CONFIG_INET | 330 | #if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_INET) |
| 330 | struct tcp_memcontrol tcp_mem; | 331 | struct tcp_memcontrol tcp_mem; |
| 331 | #endif | 332 | #endif |
| 332 | }; | 333 | }; |
| @@ -412,9 +413,7 @@ struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *s) | |||
| 412 | } | 413 | } |
| 413 | 414 | ||
| 414 | /* Writing them here to avoid exposing memcg's inner layout */ | 415 | /* Writing them here to avoid exposing memcg's inner layout */ |
| 415 | #ifdef CONFIG_MEMCG_KMEM | 416 | #if defined(CONFIG_INET) && defined(CONFIG_MEMCG_KMEM) |
| 416 | #include <net/sock.h> | ||
| 417 | #include <net/ip.h> | ||
| 418 | 417 | ||
| 419 | static bool mem_cgroup_is_root(struct mem_cgroup *memcg); | 418 | static bool mem_cgroup_is_root(struct mem_cgroup *memcg); |
| 420 | void sock_update_memcg(struct sock *sk) | 419 | void sock_update_memcg(struct sock *sk) |
| @@ -461,7 +460,6 @@ void sock_release_memcg(struct sock *sk) | |||
| 461 | } | 460 | } |
| 462 | } | 461 | } |
| 463 | 462 | ||
| 464 | #ifdef CONFIG_INET | ||
| 465 | struct cg_proto *tcp_proto_cgroup(struct mem_cgroup *memcg) | 463 | struct cg_proto *tcp_proto_cgroup(struct mem_cgroup *memcg) |
| 466 | { | 464 | { |
| 467 | if (!memcg || mem_cgroup_is_root(memcg)) | 465 | if (!memcg || mem_cgroup_is_root(memcg)) |
| @@ -470,10 +468,7 @@ struct cg_proto *tcp_proto_cgroup(struct mem_cgroup *memcg) | |||
| 470 | return &memcg->tcp_mem.cg_proto; | 468 | return &memcg->tcp_mem.cg_proto; |
| 471 | } | 469 | } |
| 472 | EXPORT_SYMBOL(tcp_proto_cgroup); | 470 | EXPORT_SYMBOL(tcp_proto_cgroup); |
| 473 | #endif /* CONFIG_INET */ | ||
| 474 | #endif /* CONFIG_MEMCG_KMEM */ | ||
| 475 | 471 | ||
| 476 | #if defined(CONFIG_INET) && defined(CONFIG_MEMCG_KMEM) | ||
| 477 | static void disarm_sock_keys(struct mem_cgroup *memcg) | 472 | static void disarm_sock_keys(struct mem_cgroup *memcg) |
| 478 | { | 473 | { |
| 479 | if (!memcg_proto_activated(&memcg->tcp_mem.cg_proto)) | 474 | if (!memcg_proto_activated(&memcg->tcp_mem.cg_proto)) |
