OpenVZ Forum - RDF feed
type: channel
items: [PATCH v6 00/10] Request for inclusion: per-cgroup tcp memory pressure controls
items: [PATCH v6 01/10] Basic kernel memory functionality for the Memory Controller
items: [PATCH v6 02/10] foundations of per-cgroup memory pressure controlling.
items: [PATCH v6 03/10] socket: initial cgroup code.
items: [PATCH v6 04/10] Account tcp memory as kernel memory
items: [PATCH v6 05/10] per-netns ipv4 sysctl_tcp_mem
items: [PATCH v6 06/10] tcp buffer limitation: per-cgroup limit
items: [PATCH v6 07/10] Display current tcp memory allocation in kmem cgroup
items: [PATCH v6 08/10] Display current tcp failcnt in kmem cgroup
items: [PATCH v6 09/10] Display maximum tcp memory allocation in kmem cgroup
items: [PATCH v6 10/10] Disable task moving when using kernel memory accounting
items: Re: [PATCH v6 01/10] Basic kernel memory functionality for the Memory Controller
items: Re: [PATCH v6 02/10] foundations of per-cgroup memory pressure controlling.
items: Re: [PATCH v6 04/10] Account tcp memory as kernel memory
items: Re: [PATCH v6 06/10] tcp buffer limitation: per-cgroup limit
items: Re: [PATCH v6 07/10] Display current tcp memory allocation in kmem cgroup
items: Re: [PATCH v6 08/10] Display current tcp failcnt in kmem cgroup
items: Re: [PATCH v6 09/10] Display maximum tcp memory allocation in kmem cgroup
items: Re: [PATCH v6 10/10] Disable task moving when using kernel memory accounting

[PATCH v6 00/10] Request for inclusion: per-cgroup tcp memory pressure controls
type: item
description: Hi Dave, I hope the following series is in an acceptable state: I modified the tests in __sk_mem_schedule() in a way that we should still leave the function pretty soon under no pressure conditions. Also, I managed to remove almost everything tcp related from memcontrol.c: the only thing left is a simple function to calculate the address of the tcp sub-structure in the main memcg structure - I hope this is acceptable, since besides being simple, it is not related to the protocol itself. I also believed that by now, all other comments so far were addressed. Let me know if there are any blocking concerns to this, and I'll address them as soon as I can. Thanks Glauber Costa (10): Basic kernel memory functionality for the Memory Controller foundations of per-cgroup memory pressure controlling. socket: initial cgroup code. Account tcp memory as kernel memory per-netns ipv4 sysctl_tcp_mem tcp buffer limitation: per-cgroup limit Display current tcp memory allocation in kmem cgroup Display current tcp failcnt in kmem cgroup Display maximum tcp memory allocation in kmem cgroup Disable task moving when using kernel memory accounting Documentation/cgroups/memory.txt | 38 +++++- include/linux/memcontrol.h | 19 +++ include/net/netns/ipv4.h | 1 + include/net/sock.h | 232 +++++++++++++++++++++++++++++++++ include/net/tcp.h | 4 +- include/net/tcp_memcg.h | 20 +++ init/Kconfig | 14 ++ mm/memcontrol.c | 209 ++++++++++++++++++++++++++++-- net/core/sock.c | 106 ++++++++++++---- net/ipv4/Makefile | 1 + net/ipv4/af_inet.c | 2 + net/ipv4/proc.c | 7 +- net/ipv4/sysctl_net_ipv4.c | 65 +++++++++- net/ipv4/tcp.c | 17 +-- net/ipv4/tcp_input.c | 12 +- net/ipv4/tcp_ipv4.c | 13 ++- net/ipv4/tcp_memcg.c | 263 ++++++++++++++++++++++++++++++++++++++ net/ipv4/tcp_output.c | 2 +- net/ipv4/tcp_timer.c | 2 +- net/ipv6/af_inet6.c | 2 + net/ipv6/tcp_ipv6.c | 7 +- 21 files changed, 955 insertions(+), 81 deletions(-) create mode 100644 include/net/tcp_memcg.h create mode 100644 net/ipv4/tcp_memcg.c -- 1.7.6…
creator: Glauber Costa
date: 2011-11-25T17:38:06-00:00

[PATCH v6 01/10] Basic kernel memory functionality for the Memory Controller
type: item
description: This patch lays down the foundation for the kernel memory component of the Memory Controller. As of today, I am only laying down the following files: * memory.independent_kmem_limit * memory.kmem.limit_in_bytes (currently ignored) * memory.kmem.usage_in_bytes (always zero) Signed-off-by: Glauber Costa <glommer@parallels.com> Reviewed-by: Kirill A. Shutemov <kirill@shutemov.name> CC: Paul Menage <paul@paulmenage.org> CC: Greg Thelen <gthelen@google.com> --- Documentation/cgroups/memory.txt | 36 ++++++++++++- init/Kconfig | 14 +++++ mm/memcontrol.c | 107 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 150 insertions(+), 7 deletions(-) diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt index 06eb6d9..bf00cd2 100644 --- a/Documentation/cgroups/memory.txt +++ b/Documentation/cgroups/memory.txt @@ -44,8 +44,9 @@ Features: - oom-killer disable knob and oom-notifier - Root cgroup has no limit controls. - Kernel memory and Hugepages are not under control yet. We just manage - pages on LRU. To add more controls, we have to take care of performance. + Hugepages is not under control yet. We just manage pages on LRU. To add more + controls, we have to take care of performance. Kernel memory support is work + in progress, and the current version provides basically functionality. Brief summary of control files. @@ -56,8 +57,11 @@ Brief summary of control files. (See 5.5 for details) memory.memsw.usage_in_bytes # show current res_counter usage for memory+Swap (See 5.5 for details) + memory.kmem.usage_in_bytes # show current res_counter usage for kmem only. + (See 2.7 for details) memory.limit_in_bytes # set/show limit of memory usage memory.memsw.limit_in_bytes # set/show limit of memory+Swap usage + memory.kmem.limit_in_bytes # if allowed, set/show limit of kernel memory memory.failcnt # show the number of memory usage hits limits memory.memsw.failcnt # show the number of memory+Swap hits limits memory.max_usage_in_bytes # show max memory usag…
creator: Glauber Costa
date: 2011-11-25T17:38:07-00:00

[PATCH v6 02/10] foundations of per-cgroup memory pressure controlling.
type: item
description: This patch replaces all uses of struct sock fields' memory_pressure, memory_allocated, sockets_allocated, and sysctl_mem to acessor macros. Those macros can either receive a socket argument, or a mem_cgroup argument, depending on the context they live in. Since we're only doing a macro wrapping here, no performance impact at all is expected in the case where we don't have cgroups disabled. Signed-off-by: Glauber Costa <glommer@parallels.com> CC: David S. Miller <davem@davemloft.net> CC: Hiroyouki Kamezawa <kamezawa.hiroyu@jp.fujitsu.com> CC: Eric W. Biederman <ebiederm@xmission.com> CC: Eric Dumazet <eric.dumazet@gmail.com> --- include/net/sock.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ include/net/tcp.h | 3 +- net/core/sock.c | 55 +++++++++++++++++++++++++----------------- net/ipv4/proc.c | 7 +++-- net/ipv4/tcp.c | 6 +++- net/ipv4/tcp_input.c | 12 ++++---- net/ipv4/tcp_ipv4.c | 4 +- net/ipv4/tcp_output.c | 2 +- net/ipv4/tcp_timer.c | 2 +- net/ipv6/tcp_ipv6.c | 2 +- 10 files changed, 118 insertions(+), 39 deletions(-) diff --git a/include/net/sock.h b/include/net/sock.h index c6658be..0d054e0 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -54,6 +54,7 @@ #include <linux/security.h> #include <linux/slab.h> #include <linux/uaccess.h> +#include <linux/memcontrol.h> #include <linux/filter.h> #include <linux/rculist_nulls.h> @@ -863,6 +864,69 @@ static inline void sk_refcnt_debug_release(const struct sock *sk) #define sk_refcnt_debug_release(sk) do { } while (0) #endif /* SOCK_REFCNT_DEBUG */ +static inline int *sk_memory_pressure(const struct sock *sk) +{ + return sk->sk_prot->memory_pressure; +} + +static inline long sk_prot_mem(const struct sock *sk, int index) +{ + long *prot = sk->sk_prot->sysctl_mem; + return prot[index]; +} + +static inline long +sk_memory_allocated(const struct sock *sk) +{ + struct proto *prot = sk->sk_prot; + return atomic_long_read(prot->memory_allocated); +} + +static inline long +sk_memory_allocated_add(struct sock …
creator: Glauber Costa
date: 2011-11-25T17:38:08-00:00

[PATCH v6 03/10] socket: initial cgroup code.
type: item
description: The goal of this work is to move the memory pressure tcp controls to a cgroup, instead of just relying on global conditions. To avoid excessive overhead in the network fast paths, the code that accounts allocated memory to a cgroup is hidden inside a static_branch(). This branch is patched out until the first non-root cgroup is created. So when nobody is using cgroups, even if it is mounted, no significant performance penalty should be seen. This patch handles the generic part of the code, and has nothing tcp-specific. Signed-off-by: Glauber Costa <glommer@parallels.com> Acked-by: Kirill A. Shutemov<kirill@shutemov.name> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujtsu.com> CC: David S. Miller <davem@davemloft.net> CC: Eric W. Biederman <ebiederm@xmission.com> CC: Eric Dumazet <eric.dumazet@gmail.com> --- include/linux/memcontrol.h | 16 ++++ include/net/sock.h | 169 +++++++++++++++++++++++++++++++++++++++++++- mm/memcontrol.c | 40 +++++++++-- net/core/sock.c | 21 ++++-- 4 files changed, 230 insertions(+), 16 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index ac797fa..6644d90 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -377,5 +377,21 @@ mem_cgroup_print_bad_page(struct page *page) } #endif +#ifdef CONFIG_INET +enum { + UNDER_LIMIT, + SOFT_LIMIT, + OVER_LIMIT, +}; + +struct sock; +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM +void sock_update_memcg(struct sock *sk); +#else +static inline void sock_update_memcg(struct sock *sk) +{ +} +#endif /* CONFIG_CGROUP_MEM_RES_CTLR_KMEM */ +#endif /* CONFIG_INET */ #endif /* _LINUX_MEMCONTROL_H */ diff --git a/include/net/sock.h b/include/net/sock.h index 0d054e0..d802761 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -55,6 +55,7 @@ #include <linux/slab.h> #include <linux/uaccess.h> #include <linux/memcontrol.h> +#include <linux/res_counter.h> #include <linux/filter.h> #include <linux/rculist_nulls.h> @@ -169,6 +170,7 @@ struct sock_common { /* p…
creator: Glauber Costa
date: 2011-11-25T17:38:09-00:00

[PATCH v6 04/10] Account tcp memory as kernel memory
type: item
description: Now that we account and control tcp memory buffers memory for pressure controlling purposes, display this information as part of the normal memcg files and other usages. Signed-off-by: Glauber Costa <glommer@parallels.com> CC: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujtisu.com> CC: Eric W. Biederman <ebiederm@xmission.com> --- include/linux/memcontrol.h | 3 ++ include/net/sock.h | 3 ++ include/net/tcp_memcg.h | 17 +++++++++++ mm/memcontrol.c | 39 ++++++++++++++++++++++++-- net/core/sock.c | 42 ++++++++++++++++++++++++++-- net/ipv4/Makefile | 1 + net/ipv4/tcp_ipv4.c | 8 +++++- net/ipv4/tcp_memcg.c | 64 ++++++++++++++++++++++++++++++++++++++++++++ net/ipv6/tcp_ipv6.c | 4 +++ 9 files changed, 174 insertions(+), 7 deletions(-) create mode 100644 include/net/tcp_memcg.h create mode 100644 net/ipv4/tcp_memcg.c diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 6644d90..1aff2f6 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -85,6 +85,9 @@ extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page); extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p); extern struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm); +extern struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont); +extern struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *mem); + static inline int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup) { diff --git a/include/net/sock.h b/include/net/sock.h index d802761..da38de2 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -65,6 +65,9 @@ #include <net/dst.h> #include <net/checksum.h> +int sockets_populate(struct cgroup *cgrp, struct cgroup_subsys *ss); +void sockets_destroy(struct cgroup *cgrp, struct cgroup_subsys *ss); + /* * This structure really needs to be cleaned up. * Most of it is for TCP, and not used by any of diff --git a/include/net/tcp_memcg.h b/include/net/tcp_memcg.h new file mode 100644 index 0000000..5f5…
creator: Glauber Costa
date: 2011-11-25T17:38:10-00:00

[PATCH v6 05/10] per-netns ipv4 sysctl_tcp_mem
type: item
description: This patch allows each namespace to independently set up its levels for tcp memory pressure thresholds. This patch alone does not buy much: we need to make this values per group of process somehow. This is achieved in the patches that follows in this patchset. Signed-off-by: Glauber Costa <glommer@parallels.com> CC: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> CC: David S. Miller <davem@davemloft.net> CC: Eric W. Biederman <ebiederm@xmission.com> --- include/net/netns/ipv4.h | 1 + include/net/tcp.h | 1 - net/ipv4/af_inet.c | 2 + net/ipv4/sysctl_net_ipv4.c | 51 +++++++++++++++++++++++++++++++++++++------ net/ipv4/tcp.c | 11 +------- net/ipv4/tcp_ipv4.c | 1 - net/ipv4/tcp_memcg.c | 9 +++++-- net/ipv6/af_inet6.c | 2 + net/ipv6/tcp_ipv6.c | 1 - 9 files changed, 57 insertions(+), 22 deletions(-) diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h index d786b4f..bbd023a 100644 --- a/include/net/netns/ipv4.h +++ b/include/net/netns/ipv4.h @@ -55,6 +55,7 @@ struct netns_ipv4 { int current_rt_cache_rebuild_count; unsigned int sysctl_ping_group_range[2]; + long sysctl_tcp_mem[3]; atomic_t rt_genid; atomic_t dev_addr_genid; diff --git a/include/net/tcp.h b/include/net/tcp.h index ccaa3b6..f3cc395 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -230,7 +230,6 @@ extern int sysctl_tcp_fack; extern int sysctl_tcp_reordering; extern int sysctl_tcp_ecn; extern int sysctl_tcp_dsack; -extern long sysctl_tcp_mem[3]; extern int sysctl_tcp_wmem[3]; extern int sysctl_tcp_rmem[3]; extern int sysctl_tcp_app_win; diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 1b5096a..a8bbcff 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1671,6 +1671,8 @@ static int __init inet_init(void) ip_static_sysctl_init(); #endif + tcp_prot.sysctl_mem = init_net.ipv4.sysctl_tcp_mem; + /* * Add all the base protocols. */ diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 69fd720..bbd67ab 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv…
creator: Glauber Costa
date: 2011-11-25T17:38:11-00:00

[PATCH v6 06/10] tcp buffer limitation: per-cgroup limit
type: item
description: This patch uses the "tcp.limit_in_bytes" field of the kmem_cgroup to effectively control the amount of kernel memory pinned by a cgroup. This value is ignored in the root cgroup, and in all others, caps the value specified by the admin in the net namespaces' view of tcp_sysctl_mem. If namespaces are being used, the admin is allowed to set a value bigger than cgroup's maximum, the same way it is allowed to set pretty much unlimited values in a real box. Signed-off-by: Glauber Costa <glommer@parallels.com> CC: David S. Miller <davem@davemloft.net> CC: Hiroyouki Kamezawa <kamezawa.hiroyu@jp.fujitsu.com> CC: Eric W. Biederman <ebiederm@xmission.com> --- Documentation/cgroups/memory.txt | 1 + include/net/tcp_memcg.h | 3 + net/ipv4/sysctl_net_ipv4.c | 14 ++++ net/ipv4/tcp_memcg.c | 138 +++++++++++++++++++++++++++++++++++++- 4 files changed, 154 insertions(+), 2 deletions(-) diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt index bf00cd2..c1db134 100644 --- a/Documentation/cgroups/memory.txt +++ b/Documentation/cgroups/memory.txt @@ -78,6 +78,7 @@ Brief summary of control files. memory.independent_kmem_limit # select whether or not kernel memory limits are independent of user limits + memory.kmem.tcp.limit_in_bytes # set/show hard limit for tcp buf memory 1. History diff --git a/include/net/tcp_memcg.h b/include/net/tcp_memcg.h index 5f5e158..2c8bb6b 100644 --- a/include/net/tcp_memcg.h +++ b/include/net/tcp_memcg.h @@ -14,4 +14,7 @@ struct tcp_memcontrol { struct cg_proto *tcp_proto_cgroup(struct mem_cgroup *memcg); int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss); void tcp_destroy_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss); +unsigned long long tcp_max_memory(const struct mem_cgroup *memcg); +void tcp_prot_mem(struct mem_cgroup *memcg, long val, int idx); +int tcp_update_limit(struct mem_cgroup *memcg, u64 val); #endif /* _TCP_MEMCG_H */ diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index b…
creator: Glauber Costa
date: 2011-11-25T17:38:12-00:00

[PATCH v6 07/10] Display current tcp memory allocation in kmem cgroup
type: item
description: This patch introduces kmem.tcp.usage_in_bytes file, living in the kmem_cgroup filesystem. It is a simple read-only file that displays the amount of kernel memory currently consumed by the cgroup. Signed-off-by: Glauber Costa <glommer@parallels.com> CC: David S. Miller <davem@davemloft.net> CC: Hiroyouki Kamezawa <kamezawa.hiroyu@jp.fujitsu.com> CC: Eric W. Biederman <ebiederm@xmission.com> --- Documentation/cgroups/memory.txt | 1 + net/ipv4/tcp_memcg.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt index c1db134..00f1a88 100644 --- a/Documentation/cgroups/memory.txt +++ b/Documentation/cgroups/memory.txt @@ -79,6 +79,7 @@ Brief summary of control files. memory.independent_kmem_limit # select whether or not kernel memory limits are independent of user limits memory.kmem.tcp.limit_in_bytes # set/show hard limit for tcp buf memory + memory.kmem.tcp.usage_in_bytes # show current tcp buf memory allocation 1. History diff --git a/net/ipv4/tcp_memcg.c b/net/ipv4/tcp_memcg.c index b3721c3..a1ab613 100644 --- a/net/ipv4/tcp_memcg.c +++ b/net/ipv4/tcp_memcg.c @@ -16,6 +16,11 @@ static struct cftype tcp_files[] = { .read_u64 = tcp_cgroup_read, .private = RES_LIMIT, }, + { + .name = "kmem.tcp.usage_in_bytes", + .read_u64 = tcp_cgroup_read, + .private = RES_USAGE, + }, }; static inline struct tcp_memcontrol *tcp_from_cgproto(struct cg_proto *cg_proto) @@ -158,6 +163,19 @@ static u64 tcp_read_stat(struct mem_cgroup *memcg, int type, u64 default_val) return res_counter_read_u64(&tcp->tcp_memory_allocated, type); } +static u64 tcp_read_usage(struct mem_cgroup *memcg) +{ + struct tcp_memcontrol *tcp; + struct cg_proto *cg_proto; + + cg_proto = tcp_prot.proto_cgroup(memcg); + if (!cg_proto) + return atomic_long_read(&tcp_memory_allocated) << PAGE_SHIFT; + + tcp = tcp_from_cgproto(cg_proto); + return res_counter_read_u64(&tcp->tcp_memory_allocated, RES_USAGE); +} + static u64…
creator: Glauber Costa
date: 2011-11-25T17:38:13-00:00

[PATCH v6 08/10] Display current tcp failcnt in kmem cgroup
type: item
description: This patch introduces kmem.tcp.failcnt file, living in the kmem_cgroup filesystem. Following the pattern in the other memcg resources, this files keeps a counter of how many times allocation failed due to limits being hit in this cgroup. The root cgroup will always show a failcnt of 0. Signed-off-by: Glauber Costa <glommer@parallels.com> CC: David S. Miller <davem@davemloft.net> CC: Hiroyouki Kamezawa <kamezawa.hiroyu@jp.fujitsu.com> CC: Eric W. Biederman <ebiederm@xmission.com> --- net/ipv4/tcp_memcg.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/net/ipv4/tcp_memcg.c b/net/ipv4/tcp_memcg.c index a1ab613..da8d9c0 100644 --- a/net/ipv4/tcp_memcg.c +++ b/net/ipv4/tcp_memcg.c @@ -8,6 +8,7 @@ static u64 tcp_cgroup_read(struct cgroup *cont, struct cftype *cft); static int tcp_cgroup_write(struct cgroup *cont, struct cftype *cft, const char *buffer); +static int tcp_cgroup_reset(struct cgroup *cont, unsigned int event); static struct cftype tcp_files[] = { { @@ -21,6 +22,12 @@ static struct cftype tcp_files[] = { .read_u64 = tcp_cgroup_read, .private = RES_USAGE, }, + { + .name = "kmem.tcp.failcnt", + .private = RES_FAILCNT, + .trigger = tcp_cgroup_reset, + .read_u64 = tcp_cgroup_read, + }, }; static inline struct tcp_memcontrol *tcp_from_cgproto(struct cg_proto *cg_proto) @@ -188,12 +195,36 @@ static u64 tcp_cgroup_read(struct cgroup *cont, struct cftype *cft) case RES_USAGE: val = tcp_read_usage(memcg); break; + case RES_FAILCNT: + val = tcp_read_stat(memcg, RES_FAILCNT, 0); + break; default: BUG(); } return val; } +static int tcp_cgroup_reset(struct cgroup *cont, unsigned int event) +{ + struct mem_cgroup *memcg; + struct tcp_memcontrol *tcp; + struct cg_proto *cg_proto; + + memcg = mem_cgroup_from_cont(cont); + cg_proto = tcp_prot.proto_cgroup(memcg); + if (!cg_proto) + return 0; + tcp = tcp_from_cgproto(cg_proto); + + switch (event) { + case RES_FAILCNT: + res_counter_reset_failcnt(&tcp->tcp_memory_allocated); + …
creator: Glauber Costa
date: 2011-11-25T17:38:14-00:00

[PATCH v6 09/10] Display maximum tcp memory allocation in kmem cgroup
type: item
description: This patch introduces kmem.tcp.max_usage_in_bytes file, living in the kmem_cgroup filesystem. The root cgroup will display a value equal to RESOURCE_MAX. This is to avoid introducing any locking schemes in the network paths when cgroups are not being actively used. All others, will see the maximum memory ever used by this cgroup. Signed-off-by: Glauber Costa <glommer@parallels.com> CC: David S. Miller <davem@davemloft.net> CC: Hiroyouki Kamezawa <kamezawa.hiroyu@jp.fujitsu.com> CC: Eric W. Biederman <ebiederm@xmission.com> --- net/ipv4/tcp_memcg.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/net/ipv4/tcp_memcg.c b/net/ipv4/tcp_memcg.c index da8d9c0..e702f6a 100644 --- a/net/ipv4/tcp_memcg.c +++ b/net/ipv4/tcp_memcg.c @@ -28,6 +28,12 @@ static struct cftype tcp_files[] = { .trigger = tcp_cgroup_reset, .read_u64 = tcp_cgroup_read, }, + { + .name = "kmem.tcp.max_usage_in_bytes", + .private = RES_MAX_USAGE, + .trigger = tcp_cgroup_reset, + .read_u64 = tcp_cgroup_read, + }, }; static inline struct tcp_memcontrol *tcp_from_cgproto(struct cg_proto *cg_proto) @@ -196,7 +202,8 @@ static u64 tcp_cgroup_read(struct cgroup *cont, struct cftype *cft) val = tcp_read_usage(memcg); break; case RES_FAILCNT: - val = tcp_read_stat(memcg, RES_FAILCNT, 0); + case RES_MAX_USAGE: + val = tcp_read_stat(memcg, cft->private, 0); break; default: BUG(); @@ -217,6 +224,9 @@ static int tcp_cgroup_reset(struct cgroup *cont, unsigned int event) tcp = tcp_from_cgproto(cg_proto); switch (event) { + case RES_MAX_USAGE: + res_counter_reset_max(&tcp->tcp_memory_allocated); + break; case RES_FAILCNT: res_counter_reset_failcnt(&tcp->tcp_memory_allocated); break; -- 1.7.6.4
creator: Glauber Costa
date: 2011-11-25T17:38:15-00:00

[PATCH v6 10/10] Disable task moving when using kernel memory accounting
type: item
description: Since this code is still experimental, we are leaving the exact details of how to move tasks between cgroups when kernel memory accounting is used as future work. For now, we simply disallow movement if there are any pending accounted memory. Signed-off-by: Glauber Costa <glommer@parallels.com> CC: Hiroyouki Kamezawa <kamezawa.hiroyu@jp.fujitsu.com> --- mm/memcontrol.c | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 2df5d3c..ab7e57b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5451,10 +5451,19 @@ static int mem_cgroup_can_attach(struct cgroup_subsys *ss, { int ret = 0; struct mem_cgroup *mem = mem_cgroup_from_cont(cgroup); + struct mem_cgroup *from = mem_cgroup_from_task(p); + +#if defined(CONFIG_CGROUP_MEM_RES_CTLR_KMEM) && defined(CONFIG_INET) + if (from != mem && !mem_cgroup_is_root(from) && + res_counter_read_u64(&from->tcp_mem.tcp_memory_allocated, RES_USAGE)) { + printk(KERN_WARNING "Can't move tasks between cgroups: " + "Kernel memory held. task: %s\n", p->comm); + return 1; + } +#endif if (mem->move_charge_at_immigrate) { struct mm_struct *mm; - struct mem_cgroup *from = mem_cgroup_from_task(p); VM_BUG_ON(from == mem); @@ -5622,6 +5631,18 @@ static int mem_cgroup_can_attach(struct cgroup_subsys *ss, struct cgroup *cgroup, struct task_struct *p) { + struct mem_cgroup *mem = mem_cgroup_from_cont(cgroup); + struct mem_cgroup *from = mem_cgroup_from_task(p); + +#if defined(CONFIG_CGROUP_MEM_RES_CTLR_KMEM) && defined(CONFIG_INET) + if (from != mem && !mem_cgroup_is_root(from) && + res_counter_read_u64(&from->tcp_mem.tcp_memory_allocated, RES_USAGE)) { + printk(KERN_WARNING "Can't move tasks between cgroups: " + "Kernel memory held. task: %s\n", p->comm); + return 1; + } +#endif + return 0; } static void mem_cgroup_cancel_attach(struct cgroup_subsys *ss, -- 1.7.6.4
creator: Glauber Costa
date: 2011-11-25T17:38:16-00:00

Re: [PATCH v6 01/10] Basic kernel memory functionality for the Memory Controller
type: item
description: On Fri, 25 Nov 2011 15:38:07 -0200 Glauber Costa <glommer@parallels.com> wrote: > This patch lays down the foundation for the kernel memory component > of the Memory Controller. > > As of today, I am only laying down the following files: > > * memory.independent_kmem_limit > * memory.kmem.limit_in_bytes (currently ignored) > * memory.kmem.usage_in_bytes (always zero) > > Signed-off-by: Glauber Costa <glommer@parallels.com> > Reviewed-by: Kirill A. Shutemov <kirill@shutemov.name> > CC: Paul Menage <paul@paulmenage.org> > CC: Greg Thelen <gthelen@google.com> > --- > Documentation/cgroups/memory.txt | 36 ++++++++++++- > init/Kconfig | 14 +++++ > mm/memcontrol.c | 107 ++++++++++++++++++++++++++++++++++++-- > 3 files changed, 150 insertions(+), 7 deletions(-) > > diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt > index 06eb6d9..bf00cd2 100644 > --- a/Documentation/cgroups/memory.txt > +++ b/Documentation/cgroups/memory.txt > @@ -44,8 +44,9 @@ Features: > - oom-killer disable knob and oom-notifier > - Root cgroup has no limit controls. > > - Kernel memory and Hugepages are not under control yet. We just manage > - pages on LRU. To add more controls, we have to take care of performance. > + Hugepages is not under control yet. We just manage pages on LRU. To add more > + controls, we have to take care of performance. Kernel memory support is work > + in progress, and the current version provides basically functionality. > > Brief summary of control files. > > @@ -56,8 +57,11 @@ Brief summary of control files. > (See 5.5 for details) > memory.memsw.usage_in_bytes # show current res_counter usage for memory+Swap > (See 5.5 for details) > + memory.kmem.usage_in_bytes # show current res_counter usage for kmem only. > + (See 2.7 for details) > memory.limit_in_bytes # set/show limit of memory usage > memory.memsw.limit_in_bytes # set/show limit of memory+Swap usage > + memory.kmem.limit_in_bytes # if allowed, set/show limit of kernel memory > memor…
creator: KAMEZAWA Hiroyuki
date: 2011-11-28T02:24:41-00:00

Re: [PATCH v6 02/10] foundations of per-cgroup memory pressure controlling.
type: item
description: On Fri, 25 Nov 2011 15:38:08 -0200 Glauber Costa <glommer@parallels.com> wrote: > This patch replaces all uses of struct sock fields' memory_pressure, > memory_allocated, sockets_allocated, and sysctl_mem to acessor > macros. Those macros can either receive a socket argument, or a mem_cgroup > argument, depending on the context they live in. > > Since we're only doing a macro wrapping here, no performance impact at all is > expected in the case where we don't have cgroups disabled. > > Signed-off-by: Glauber Costa <glommer@parallels.com> > CC: David S. Miller <davem@davemloft.net> > CC: Hiroyouki Kamezawa <kamezawa.hiroyu@jp.fujitsu.com> > CC: Eric W. Biederman <ebiederm@xmission.com> > CC: Eric Dumazet <eric.dumazet@gmail.com> I have some comments on the style. Maybe a nitpick but many patches were sent for fixing conding style in memcg recently. +static inline int *sk_memory_pressure(const struct sock *sk) +{ + return sk->sk_prot->memory_pressure; +} + +static inline long sk_prot_mem(const struct sock *sk, int index) +{ + long *prot = sk->sk_prot->sysctl_mem; + return prot[index]; +} + I don't think sk_prot_mem() is an easy to undestand name. sk_prot_memory_limit() ? > +static inline int > +kcg_sockets_allocated_sum_positive(struct proto *prot, struct mem_cgroup *cg) > +{ > + return percpu_counter_sum_positive(prot->sockets_allocated); > +} > + > +static inline long > +kcg_memory_allocated(struct proto *prot, struct mem_cgroup *cg) > +{ > + return atomic_long_read(prot->memory_allocated); > +} > I don't like 'kcg'. What it means ? memory_cgrou_prot_socekts_allocated() ? and memory_cgroup_prot_memory_allocated() ? And the variable for memory cgroup should be 'memcg'. http://www.spinics.net/lists/linux-mm/msg26781.html So, please rename. > #ifdef CONFIG_PROC_FS > /* Called with local bh disabled */ > diff --git a/include/net/tcp.h b/include/net/tcp.h > index e147f42..ccaa3b6 100644 <snip> seq_printf(seq, "RAW: inuse %d\n", > diff --git a/net/ipv4/tcp.c b/net/ipv4/tc…
creator: KAMEZAWA Hiroyuki
date: 2011-11-28T02:55:41-00:00

Re: [PATCH v6 04/10] Account tcp memory as kernel memory
type: item
description: Some nitpicks. On Fri, 25 Nov 2011 15:38:10 -0200 Glauber Costa <glommer@parallels.com> wrote: > Now that we account and control tcp memory buffers memory for pressure > controlling purposes, display this information as part of the normal memcg > files and other usages. > > +extern struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont); > +extern struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *mem); > + > static inline > int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup) > { > diff --git a/include/net/sock.h b/include/net/sock.h > index d802761..da38de2 100644 > --- a/include/net/sock.h > +++ b/include/net/sock.h > @@ -65,6 +65,9 @@ > #include <net/dst.h> > #include <net/checksum.h> > > +int sockets_populate(struct cgroup *cgrp, struct cgroup_subsys *ss); > +void sockets_destroy(struct cgroup *cgrp, struct cgroup_subsys *ss); > + > /* Hmm, what is this 'populate' function for ? mem_cgroup_sockets_init() ? > * This structure really needs to be cleaned up. > * Most of it is for TCP, and not used by any of > diff --git a/include/net/tcp_memcg.h b/include/net/tcp_memcg.h > new file mode 100644 > index 0000000..5f5e158 > --- /dev/null > +++ b/include/net/tcp_memcg.h > @@ -0,0 +1,17 @@ > +#ifndef _TCP_MEMCG_H > +#define _TCP_MEMCG_H > + > +struct tcp_memcontrol { > + struct cg_proto cg_proto; > + /* per-cgroup tcp memory pressure knobs */ > + struct res_counter tcp_memory_allocated; > + struct percpu_counter tcp_sockets_allocated; > + /* those two are read-mostly, leave them at the end */ > + long tcp_prot_mem[3]; > + int tcp_memory_pressure; > +}; > + > +struct cg_proto *tcp_proto_cgroup(struct mem_cgroup *memcg); > +int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss); > +void tcp_destroy_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss); > +#endif /* _TCP_MEMCG_H */ > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 5f29194..2df5d3c 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -49,6 +49,…
creator: KAMEZAWA Hiroyuki
date: 2011-11-28T03:14:18-00:00

Re: [PATCH v6 06/10] tcp buffer limitation: per-cgroup limit
type: item
description: some comments. On Fri, 25 Nov 2011 15:38:12 -0200 Glauber Costa <glommer@parallels.com> wrote: > This patch uses the "tcp.limit_in_bytes" field of the kmem_cgroup to > effectively control the amount of kernel memory pinned by a cgroup. > > This value is ignored in the root cgroup, and in all others, > caps the value specified by the admin in the net namespaces' > view of tcp_sysctl_mem. > > If namespaces are being used, the admin is allowed to set a > value bigger than cgroup's maximum, the same way it is allowed > to set pretty much unlimited values in a real box. > > Signed-off-by: Glauber Costa <glommer@parallels.com> > CC: David S. Miller <davem@davemloft.net> > CC: Hiroyouki Kamezawa <kamezawa.hiroyu@jp.fujitsu.com> > CC: Eric W. Biederman <ebiederm@xmission.com> <snip> > EXPORT_SYMBOL(tcp_destroy_cgroup); > + > +int tcp_update_limit(struct mem_cgroup *memcg, u64 val) > +{ > + struct net *net = current->nsproxy->net_ns; > + struct tcp_memcontrol *tcp; > + struct cg_proto *cg_proto; > + int i; > + int ret; > + > + cg_proto = tcp_prot.proto_cgroup(memcg); > + if (!cg_proto) > + return -EINVAL; > + > + tcp = tcp_from_cgproto(cg_proto); > + > + ret = res_counter_set_limit(&tcp->tcp_memory_allocated, val); Here, you changed the limit. > + if (ret) > + return ret; > + > + val >>= PAGE_SHIFT; Here, you modifies 'val' > + > + for (i = 0; i < 3; i++) > + tcp->tcp_prot_mem[i] = min_t(long, val, > + net->ipv4.sysctl_tcp_mem[i]); > + > + if (val == RESOURCE_MAX) > + jump_label_dec(&memcg_socket_limit_enabled); the 'val' never be RESOUECE_MAX. > + else { > + u64 old_lim; > + old_lim = res_counter_read_u64(&tcp->tcp_memory_allocated, > + RES_LIMIT); old_lim is not already overwritten ? > + if (old_lim == RESOURCE_MAX) > + jump_label_inc(&memcg_socket_limit_enabled); > + } > + return 0; > +} > + Thanks, -Kame
creator: KAMEZAWA Hiroyuki
date: 2011-11-28T03:24:52-00:00

Re: [PATCH v6 07/10] Display current tcp memory allocation in kmem cgroup
type: item
description: On Fri, 25 Nov 2011 15:38:13 -0200 Glauber Costa <glommer@parallels.com> wrote: > This patch introduces kmem.tcp.usage_in_bytes file, living in the > kmem_cgroup filesystem. It is a simple read-only file that displays the > amount of kernel memory currently consumed by the cgroup. > > Signed-off-by: Glauber Costa <glommer@parallels.com> > CC: David S. Miller <davem@davemloft.net> > CC: Hiroyouki Kamezawa <kamezawa.hiroyu@jp.fujitsu.com> > CC: Eric W. Biederman <ebiederm@xmission.com> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
creator: KAMEZAWA Hiroyuki
date: 2011-11-28T04:20:27-00:00

Re: [PATCH v6 08/10] Display current tcp failcnt in kmem cgroup
type: item
description: On Fri, 25 Nov 2011 15:38:14 -0200 Glauber Costa <glommer@parallels.com> wrote: > This patch introduces kmem.tcp.failcnt file, living in the > kmem_cgroup filesystem. Following the pattern in the other > memcg resources, this files keeps a counter of how many times > allocation failed due to limits being hit in this cgroup. > The root cgroup will always show a failcnt of 0. > > Signed-off-by: Glauber Costa <glommer@parallels.com> > CC: David S. Miller <davem@davemloft.net> > CC: Hiroyouki Kamezawa <kamezawa.hiroyu@jp.fujitsu.com> > CC: Eric W. Biederman <ebiederm@xmission.com> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
creator: KAMEZAWA Hiroyuki
date: 2011-11-28T04:21:28-00:00

Re: [PATCH v6 09/10] Display maximum tcp memory allocation in kmem cgroup
type: item
description: On Fri, 25 Nov 2011 15:38:15 -0200 Glauber Costa <glommer@parallels.com> wrote: > This patch introduces kmem.tcp.max_usage_in_bytes file, living in the > kmem_cgroup filesystem. The root cgroup will display a value equal > to RESOURCE_MAX. This is to avoid introducing any locking schemes in > the network paths when cgroups are not being actively used. > > All others, will see the maximum memory ever used by this cgroup. > > Signed-off-by: Glauber Costa <glommer@parallels.com> > CC: David S. Miller <davem@davemloft.net> > CC: Hiroyouki Kamezawa <kamezawa.hiroyu@jp.fujitsu.com> > CC: Eric W. Biederman <ebiederm@xmission.com> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
creator: KAMEZAWA Hiroyuki
date: 2011-11-28T04:22:15-00:00

Re: [PATCH v6 10/10] Disable task moving when using kernel memory accounting
type: item
description: On Fri, 25 Nov 2011 15:38:16 -0200 Glauber Costa <glommer@parallels.com> wrote: > Since this code is still experimental, we are leaving the exact > details of how to move tasks between cgroups when kernel memory > accounting is used as future work. > > For now, we simply disallow movement if there are any pending > accounted memory. > > Signed-off-by: Glauber Costa <glommer@parallels.com> > CC: Hiroyouki Kamezawa <kamezawa.hiroyu@jp.fujitsu.com> > --- > mm/memcontrol.c | 23 ++++++++++++++++++++++- > 1 files changed, 22 insertions(+), 1 deletions(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 2df5d3c..ab7e57b 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -5451,10 +5451,19 @@ static int mem_cgroup_can_attach(struct cgroup_subsys *ss, > { > int ret = 0; > struct mem_cgroup *mem = mem_cgroup_from_cont(cgroup); > + struct mem_cgroup *from = mem_cgroup_from_task(p); > + > +#if defined(CONFIG_CGROUP_MEM_RES_CTLR_KMEM) && defined(CONFIG_INET) > + if (from != mem && !mem_cgroup_is_root(from) && > + res_counter_read_u64(&from->tcp_mem.tcp_memory_allocated, RES_USAGE)) { > + printk(KERN_WARNING "Can't move tasks between cgroups: " > + "Kernel memory held. task: %s\n", p->comm); > + return 1; > + } > +#endif Hmm, the kernel memory is not guaranteed as being held by the 'task' ? How about "Now, moving task between cgroup is disallowed while the source cgroup containes kmem reference." ? Hmm.. we need to fix this task-move/rmdir issue before production use. Thanks, -Kame
creator: KAMEZAWA Hiroyuki
date: 2011-11-28T04:32:03-00:00

Re: [PATCH v6 10/10] Disable task moving when using kernel memory accounting
type: item
description: On 11/28/2011 02:32 AM, KAMEZAWA Hiroyuki wrote: > On Fri, 25 Nov 2011 15:38:16 -0200 > Glauber Costa<glommer@parallels.com> wrote: > >> Since this code is still experimental, we are leaving the exact >> details of how to move tasks between cgroups when kernel memory >> accounting is used as future work. >> >> For now, we simply disallow movement if there are any pending >> accounted memory. >> >> Signed-off-by: Glauber Costa<glommer@parallels.com> >> CC: Hiroyouki Kamezawa<kamezawa.hiroyu@jp.fujitsu.com> >> --- >> mm/memcontrol.c | 23 ++++++++++++++++++++++- >> 1 files changed, 22 insertions(+), 1 deletions(-) >> >> diff --git a/mm/memcontrol.c b/mm/memcontrol.c >> index 2df5d3c..ab7e57b 100644 >> --- a/mm/memcontrol.c >> +++ b/mm/memcontrol.c >> @@ -5451,10 +5451,19 @@ static int mem_cgroup_can_attach(struct cgroup_subsys *ss, >> { >> int ret = 0; >> struct mem_cgroup *mem = mem_cgroup_from_cont(cgroup); >> + struct mem_cgroup *from = mem_cgroup_from_task(p); >> + >> +#if defined(CONFIG_CGROUP_MEM_RES_CTLR_KMEM)&& defined(CONFIG_INET) >> + if (from != mem&& !mem_cgroup_is_root(from)&& >> + res_counter_read_u64(&from->tcp_mem.tcp_memory_allocated, RES_USAGE)) { >> + printk(KERN_WARNING "Can't move tasks between cgroups: " >> + "Kernel memory held. task: %s\n", p->comm); >> + return 1; >> + } >> +#endif > > Hmm, the kernel memory is not guaranteed as being held by the 'task' ? > > How about > "Now, moving task between cgroup is disallowed while the source cgroup > containes kmem reference." ? > > Hmm.. we need to fix this task-move/rmdir issue before production use. > > > Thanks, > -Kame > Hi Kame, Let me tell you the direction I am going wrt task movement: The only reasons I haven't included so far, is that I believe it needs more testing, and as you know, I am right now more interested in getting past the initial barriers for inclusion. I am committed to fix anything that needs to be fixed - stylish or non-stylish before we remove the experimental flag. So what I …
creator: Glauber Costa
date: 2011-11-28T11:00:24-00:00

Re: [PATCH v6 01/10] Basic kernel memory functionality for the Memory Controller
type: item
description: On 11/28/2011 12:24 AM, KAMEZAWA Hiroyuki wrote: > On Fri, 25 Nov 2011 15:38:07 -0200 > Glauber Costa<glommer@parallels.com> wrote: > >> This patch lays down the foundation for the kernel memory component >> of the Memory Controller. >> >> As of today, I am only laying down the following files: >> >> * memory.independent_kmem_limit >> * memory.kmem.limit_in_bytes (currently ignored) >> * memory.kmem.usage_in_bytes (always zero) >> >> Signed-off-by: Glauber Costa<glommer@parallels.com> >> Reviewed-by: Kirill A. Shutemov<kirill@shutemov.name> >> CC: Paul Menage<paul@paulmenage.org> >> CC: Greg Thelen<gthelen@google.com> >> --- >> Documentation/cgroups/memory.txt | 36 ++++++++++++- >> init/Kconfig | 14 +++++ >> mm/memcontrol.c | 107 ++++++++++++++++++++++++++++++++++++-- >> 3 files changed, 150 insertions(+), 7 deletions(-) >> >> diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt >> index 06eb6d9..bf00cd2 100644 >> --- a/Documentation/cgroups/memory.txt >> +++ b/Documentation/cgroups/memory.txt >> @@ -44,8 +44,9 @@ Features: >> - oom-killer disable knob and oom-notifier >> - Root cgroup has no limit controls. >> >> - Kernel memory and Hugepages are not under control yet. We just manage >> - pages on LRU. To add more controls, we have to take care of performance. >> + Hugepages is not under control yet. We just manage pages on LRU. To add more >> + controls, we have to take care of performance. Kernel memory support is work >> + in progress, and the current version provides basically functionality. >> >> Brief summary of control files. >> >> @@ -56,8 +57,11 @@ Brief summary of control files. >> (See 5.5 for details) >> memory.memsw.usage_in_bytes # show current res_counter usage for memory+Swap >> (See 5.5 for details) >> + memory.kmem.usage_in_bytes # show current res_counter usage for kmem only. >> + (See 2.7 for details) >> memory.limit_in_bytes # set/show limit of memory usage >> memory.memsw.limit_in_bytes # set/show limit of memory+Sw…
creator: Glauber Costa
date: 2011-11-28T11:03:09-00:00

Re: [PATCH v6 01/10] Basic kernel memory functionality for the Memory Controller
type: item
description: On Mon, 28 Nov 2011 09:03:09 -0200 Glauber Costa <glommer@parallels.com> wrote: > On 11/28/2011 12:24 AM, KAMEZAWA Hiroyuki wrote: > > On Fri, 25 Nov 2011 15:38:07 -0200 > > Glauber Costa<glommer@parallels.com> wrote: > > > >> This patch lays down the foundation for the kernel memory component > >> of the Memory Controller. > >> > >> As of today, I am only laying down the following files: > >> > >> * memory.independent_kmem_limit > >> * memory.kmem.limit_in_bytes (currently ignored) > >> * memory.kmem.usage_in_bytes (always zero) > >> > >> Signed-off-by: Glauber Costa<glommer@parallels.com> > >> Reviewed-by: Kirill A. Shutemov<kirill@shutemov.name> > >> CC: Paul Menage<paul@paulmenage.org> > >> CC: Greg Thelen<gthelen@google.com> > >> --- > >> Documentation/cgroups/memory.txt | 36 ++++++++++++- > >> init/Kconfig | 14 +++++ > >> mm/memcontrol.c | 107 ++++++++++++++++++++++++++++++++++++-- > >> 3 files changed, 150 insertions(+), 7 deletions(-) > >> > >> diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt > >> index 06eb6d9..bf00cd2 100644 > >> --- a/Documentation/cgroups/memory.txt > >> +++ b/Documentation/cgroups/memory.txt > >> @@ -44,8 +44,9 @@ Features: > >> - oom-killer disable knob and oom-notifier > >> - Root cgroup has no limit controls. > >> > >> - Kernel memory and Hugepages are not under control yet. We just manage > >> - pages on LRU. To add more controls, we have to take care of performance. > >> + Hugepages is not under control yet. We just manage pages on LRU. To add more > >> + controls, we have to take care of performance. Kernel memory support is work > >> + in progress, and the current version provides basically functionality. > >> > >> Brief summary of control files. > >> > >> @@ -56,8 +57,11 @@ Brief summary of control files. > >> (See 5.5 for details) > >> memory.memsw.usage_in_bytes # show current res_counter usage for memory+Swap > >> (See 5.5 for details) > >> + memory.kmem.usage_in_bytes # show current res_counte…
creator: KAMEZAWA Hiroyuki
date: 2011-11-28T23:55:18-00:00

Re: [PATCH v6 02/10] foundations of per-cgroup memory pressure controlling.
type: item
description: On 11/28/2011 12:55 AM, KAMEZAWA Hiroyuki wrote: > On Fri, 25 Nov 2011 15:38:08 -0200 > Glauber Costa<glommer@parallels.com> wrote: > >> This patch replaces all uses of struct sock fields' memory_pressure, >> memory_allocated, sockets_allocated, and sysctl_mem to acessor >> macros. Those macros can either receive a socket argument, or a mem_cgroup >> argument, depending on the context they live in. >> >> Since we're only doing a macro wrapping here, no performance impact at all is >> expected in the case where we don't have cgroups disabled. >> >> Signed-off-by: Glauber Costa<glommer@parallels.com> >> CC: David S. Miller<davem@davemloft.net> >> CC: Hiroyouki Kamezawa<kamezawa.hiroyu@jp.fujitsu.com> >> CC: Eric W. Biederman<ebiederm@xmission.com> >> CC: Eric Dumazet<eric.dumazet@gmail.com> > > I have some comments on the style. Maybe a nitpick but many patches were > sent for fixing conding style in memcg recently. > > +static inline int *sk_memory_pressure(const struct sock *sk) > +{ > + return sk->sk_prot->memory_pressure; > +} > + > +static inline long sk_prot_mem(const struct sock *sk, int index) > +{ > + long *prot = sk->sk_prot->sysctl_mem; > + return prot[index]; > +} > + > > I don't think sk_prot_mem() is an easy to undestand name. > sk_prot_memory_limit() ? > >> +static inline int >> +kcg_sockets_allocated_sum_positive(struct proto *prot, struct mem_cgroup *cg) >> +{ >> + return percpu_counter_sum_positive(prot->sockets_allocated); >> +} >> + >> +static inline long >> +kcg_memory_allocated(struct proto *prot, struct mem_cgroup *cg) >> +{ >> + return atomic_long_read(prot->memory_allocated); >> +} >> > > I don't like 'kcg'. What it means ? > memory_cgrou_prot_socekts_allocated() ? and > memory_cgroup_prot_memory_allocated() ? > > And the variable for memory cgroup should be 'memcg'. > http://www.spinics.net/lists/linux-mm/msg26781.html > So, please rename. > > > >> #ifdef CONFIG_PROC_FS >> /* Called with local bh disabled */ >> diff --git a/include/net/tcp.h …
creator: Glauber Costa
date: 2011-11-29T09:19:12-00:00

Re: [PATCH v6 01/10] Basic kernel memory functionality for the Memory Controller
type: item
description: Sorry for jumping in that late but I was busy recently... On Fri 25-11-11 15:38:07, Glauber Costa wrote: > This patch lays down the foundation for the kernel memory component > of the Memory Controller. > > As of today, I am only laying down the following files: > > * memory.independent_kmem_limit Maybe has been already discussed but the name is rather awkward and it would deserve more clarification. It is independent in the way that it doesn't add up to the standard (user) allocations or it enables/disables accounting? > * memory.kmem.limit_in_bytes (currently ignored) What happens if we reach the limit? Are all kernel allocations considered or only selected caches? How do I find out which are those? AFAIU you have implemented it for network buffers at this stage but I guess that dentries will follow... > * memory.kmem.usage_in_bytes (always zero) > > Signed-off-by: Glauber Costa <glommer@parallels.com> > Reviewed-by: Kirill A. Shutemov <kirill@shutemov.name> > CC: Paul Menage <paul@paulmenage.org> > CC: Greg Thelen <gthelen@google.com> > --- > Documentation/cgroups/memory.txt | 36 ++++++++++++- > init/Kconfig | 14 +++++ > mm/memcontrol.c | 107 ++++++++++++++++++++++++++++++++++++-- > 3 files changed, 150 insertions(+), 7 deletions(-) > > diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt > index 06eb6d9..bf00cd2 100644 > --- a/Documentation/cgroups/memory.txt > +++ b/Documentation/cgroups/memory.txt > @@ -44,8 +44,9 @@ Features: > - oom-killer disable knob and oom-notifier > - Root cgroup has no limit controls. > > - Kernel memory and Hugepages are not under control yet. We just manage > - pages on LRU. To add more controls, we have to take care of performance. > + Hugepages is not under control yet. We just manage pages on LRU. To add more Hugepages are not Anyway this sounds outdated as we track both THP and hugetlb, right? > + controls, we have to take care of performance. Kernel memory support is work > + in progress, and the curr…
creator: Michal Hocko
date: 2011-12-14T16:38:44-00:00

Re: [PATCH v6 01/10] Basic kernel memory functionality for the Memory Controller
type: item
description: On Wed 14-12-11 17:38:44, Michal Hocko wrote: > Sorry for jumping in that late but I was busy recently... And obviously an old version of the patch in my mailbox. I will comment on the v9 now. Sorry... [...] -- Michal Hocko SUSE Labs SUSE LINUX s.r.o. Lihovarska 1060/12 190 00 Praha 9 Czech Republic
creator: Michal Hocko
date: 2011-12-14T16:45:46-00:00