From: Johannes Weiner <hannes@cmpxchg.org> To: David Miller <davem@davemloft.net>, Andrew Morton <akpm@linux-foundation.org> Cc: Vladimir Davydov <vdavydov@virtuozzo.com>, Tejun Heo <tj@kernel.org>, Michal Hocko <mhocko@suse.cz>, netdev@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 00/14] mm: memcontrol: account socket memory in unified hierarchy Date: Thu, 12 Nov 2015 18:41:19 -0500 [thread overview] Message-ID: <1447371693-25143-1-git-send-email-hannes@cmpxchg.org> (raw) Hi, this is version 3 of the patches to add socket memory accounting to the unified hierarchy memory controller. Changes since v2 include: - Fixed an underflow bug in the mem+swap counter that came through the design of the per-cpu charge cache. To fix that, the unused mem+swap counter is now fully patched out on unified hierarchy. Double whammy. - Restored the counting jump label such that the networking callbacks get patched out again when the last memory-controlled cgroup goes away. The code was already there, so we might as well keep it. - Broke down the massive tcp_memcontrol rewrite patch into smaller logical pieces to (hopefully) make it easier to review and verify. --- Socket buffer memory can make up a significant share of a workload's memory footprint that can be directly linked to userspace activity, and so it needs to be part of the memory controller to provide proper resource isolation/containment. Historically, socket buffers were accounted in a separate counter, without any pressure equalization between anonymous memory, page cache, and the socket buffers. When the socket buffer pool was exhausted, buffer allocations would fail hard and cause network performance to tank, regardless of whether there was still memory available to the group or not. Likewise, struggling anonymous or cache workingsets could not dip into an idle socket memory pool. Because of this, the feature was not usable for many real life applications. To not repeat this mistake, the new memory controller will account all types of memory pages it is tracking on behalf of a cgroup in a single pool. Upon pressure, the VM reclaims and shrinks and puts pressure on whatever memory consumer in that pool is within its reach. For socket memory, pressure feedback is provided through vmpressure events. When the VM has trouble freeing memory, the network code is instructed to stop growing the cgroup's transmit windows. This series begins with a rework of the existing tcp memory controller that simplifies and cleans up the code while allowing us to have only one set of networking hooks for both memory controller versions. The original behavior of the existing tcp controller should be preserved. It then adds socket accounting to the v2 memory controller, including the use of the per-cpu charge cache and async memory.high enforcement from socket memory charges. Lastly, vmpressure is hooked up to the socket code so that it stops growing transmit windows when the VM has trouble reclaiming memory. include/linux/memcontrol.h | 71 ++++++---- include/net/sock.h | 149 ++------------------ include/net/tcp.h | 5 +- include/net/tcp_memcontrol.h | 1 - mm/backing-dev.c | 2 +- mm/memcontrol.c | 303 +++++++++++++++++++++++++++-------------- mm/vmpressure.c | 25 +++- mm/vmscan.c | 31 +++-- net/core/sock.c | 78 +++-------- net/ipv4/tcp.c | 3 +- net/ipv4/tcp_ipv4.c | 9 +- net/ipv4/tcp_memcontrol.c | 85 ++++-------- net/ipv4/tcp_output.c | 7 +- net/ipv6/tcp_ipv6.c | 3 - 14 files changed, 353 insertions(+), 419 deletions(-)
WARNING: multiple messages have this Message-ID (diff)
From: Johannes Weiner <hannes@cmpxchg.org> To: David Miller <davem@davemloft.net>, Andrew Morton <akpm@linux-foundation.org> Cc: Vladimir Davydov <vdavydov@virtuozzo.com>, Tejun Heo <tj@kernel.org>, Michal Hocko <mhocko@suse.cz>, netdev@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 00/14] mm: memcontrol: account socket memory in unified hierarchy Date: Thu, 12 Nov 2015 18:41:19 -0500 [thread overview] Message-ID: <1447371693-25143-1-git-send-email-hannes@cmpxchg.org> (raw) Hi, this is version 3 of the patches to add socket memory accounting to the unified hierarchy memory controller. Changes since v2 include: - Fixed an underflow bug in the mem+swap counter that came through the design of the per-cpu charge cache. To fix that, the unused mem+swap counter is now fully patched out on unified hierarchy. Double whammy. - Restored the counting jump label such that the networking callbacks get patched out again when the last memory-controlled cgroup goes away. The code was already there, so we might as well keep it. - Broke down the massive tcp_memcontrol rewrite patch into smaller logical pieces to (hopefully) make it easier to review and verify. --- Socket buffer memory can make up a significant share of a workload's memory footprint that can be directly linked to userspace activity, and so it needs to be part of the memory controller to provide proper resource isolation/containment. Historically, socket buffers were accounted in a separate counter, without any pressure equalization between anonymous memory, page cache, and the socket buffers. When the socket buffer pool was exhausted, buffer allocations would fail hard and cause network performance to tank, regardless of whether there was still memory available to the group or not. Likewise, struggling anonymous or cache workingsets could not dip into an idle socket memory pool. Because of this, the feature was not usable for many real life applications. To not repeat this mistake, the new memory controller will account all types of memory pages it is tracking on behalf of a cgroup in a single pool. Upon pressure, the VM reclaims and shrinks and puts pressure on whatever memory consumer in that pool is within its reach. For socket memory, pressure feedback is provided through vmpressure events. When the VM has trouble freeing memory, the network code is instructed to stop growing the cgroup's transmit windows. This series begins with a rework of the existing tcp memory controller that simplifies and cleans up the code while allowing us to have only one set of networking hooks for both memory controller versions. The original behavior of the existing tcp controller should be preserved. It then adds socket accounting to the v2 memory controller, including the use of the per-cpu charge cache and async memory.high enforcement from socket memory charges. Lastly, vmpressure is hooked up to the socket code so that it stops growing transmit windows when the VM has trouble reclaiming memory. include/linux/memcontrol.h | 71 ++++++---- include/net/sock.h | 149 ++------------------ include/net/tcp.h | 5 +- include/net/tcp_memcontrol.h | 1 - mm/backing-dev.c | 2 +- mm/memcontrol.c | 303 +++++++++++++++++++++++++++-------------- mm/vmpressure.c | 25 +++- mm/vmscan.c | 31 +++-- net/core/sock.c | 78 +++-------- net/ipv4/tcp.c | 3 +- net/ipv4/tcp_ipv4.c | 9 +- net/ipv4/tcp_memcontrol.c | 85 ++++-------- net/ipv4/tcp_output.c | 7 +- net/ipv6/tcp_ipv6.c | 3 - 14 files changed, 353 insertions(+), 419 deletions(-) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2015-11-12 23:42 UTC|newest] Thread overview: 159+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-11-12 23:41 Johannes Weiner [this message] 2015-11-12 23:41 ` [PATCH 00/14] mm: memcontrol: account socket memory in unified hierarchy Johannes Weiner 2015-11-12 23:41 ` [PATCH 01/14] mm: memcontrol: export root_mem_cgroup Johannes Weiner 2015-11-12 23:41 ` Johannes Weiner 2015-11-13 15:59 ` David Miller 2015-11-13 15:59 ` David Miller 2015-11-13 15:59 ` David Miller 2015-11-14 12:17 ` Vladimir Davydov 2015-11-14 12:17 ` Vladimir Davydov 2015-11-14 12:17 ` Vladimir Davydov 2015-11-12 23:41 ` [PATCH 02/14] mm: vmscan: simplify memcg vs. global shrinker invocation Johannes Weiner 2015-11-12 23:41 ` Johannes Weiner 2015-11-13 15:59 ` David Miller 2015-11-13 15:59 ` David Miller 2015-11-14 12:36 ` Vladimir Davydov 2015-11-14 12:36 ` Vladimir Davydov 2015-11-14 12:36 ` Vladimir Davydov 2015-11-14 15:06 ` Johannes Weiner 2015-11-14 15:06 ` Johannes Weiner 2015-11-12 23:41 ` [PATCH 03/14] net: tcp_memcontrol: properly detect ancestor socket pressure Johannes Weiner 2015-11-12 23:41 ` Johannes Weiner 2015-11-13 16:00 ` David Miller 2015-11-13 16:00 ` David Miller 2015-11-14 12:45 ` Vladimir Davydov 2015-11-14 12:45 ` Vladimir Davydov 2015-11-14 12:45 ` Vladimir Davydov 2015-11-14 12:45 ` Vladimir Davydov 2015-11-14 15:15 ` Johannes Weiner 2015-11-14 15:15 ` Johannes Weiner 2015-11-12 23:41 ` [PATCH 04/14] net: tcp_memcontrol: remove bogus hierarchy pressure propagation Johannes Weiner 2015-11-12 23:41 ` Johannes Weiner 2015-11-13 16:00 ` David Miller 2015-11-13 16:00 ` David Miller 2015-11-20 9:07 ` Vladimir Davydov 2015-11-20 9:07 ` Vladimir Davydov 2015-11-20 9:07 ` Vladimir Davydov 2015-11-12 23:41 ` [PATCH 05/14] net: tcp_memcontrol: protect all tcp_memcontrol calls by jump-label Johannes Weiner 2015-11-12 23:41 ` Johannes Weiner 2015-11-13 16:01 ` David Miller 2015-11-13 16:01 ` David Miller 2015-11-13 16:01 ` David Miller 2015-11-14 16:33 ` Vladimir Davydov 2015-11-14 16:33 ` Vladimir Davydov 2015-11-14 16:33 ` Vladimir Davydov 2015-11-16 17:52 ` Johannes Weiner 2015-11-16 17:52 ` Johannes Weiner 2015-11-16 17:52 ` Johannes Weiner 2015-11-12 23:41 ` [PATCH 06/14] net: tcp_memcontrol: remove dead per-memcg count of allocated sockets Johannes Weiner 2015-11-12 23:41 ` Johannes Weiner 2015-11-13 16:01 ` David Miller 2015-11-13 16:01 ` David Miller 2015-11-20 9:48 ` Vladimir Davydov 2015-11-20 9:48 ` Vladimir Davydov 2015-11-20 9:48 ` Vladimir Davydov 2015-11-12 23:41 ` [PATCH 07/14] net: tcp_memcontrol: simplify the per-memcg limit access Johannes Weiner 2015-11-12 23:41 ` Johannes Weiner 2015-11-20 9:51 ` Vladimir Davydov 2015-11-20 9:51 ` Vladimir Davydov 2015-11-20 9:51 ` Vladimir Davydov 2015-11-12 23:41 ` [PATCH 08/14] net: tcp_memcontrol: sanitize tcp memory accounting callbacks Johannes Weiner 2015-11-12 23:41 ` Johannes Weiner 2015-11-13 4:53 ` Eric Dumazet 2015-11-13 4:53 ` Eric Dumazet 2015-11-13 4:53 ` Eric Dumazet 2015-11-13 5:44 ` Johannes Weiner 2015-11-13 5:44 ` Johannes Weiner 2015-11-13 5:44 ` Johannes Weiner 2015-11-13 5:44 ` Johannes Weiner 2015-11-20 10:58 ` Vladimir Davydov 2015-11-20 10:58 ` Vladimir Davydov 2015-11-20 10:58 ` Vladimir Davydov 2015-11-20 18:42 ` Johannes Weiner 2015-11-20 18:42 ` Johannes Weiner 2015-11-20 18:42 ` Johannes Weiner 2015-11-12 23:41 ` [PATCH 09/14] net: tcp_memcontrol: simplify linkage between socket and page counter Johannes Weiner 2015-11-12 23:41 ` Johannes Weiner 2015-11-20 12:42 ` Vladimir Davydov 2015-11-20 12:42 ` Vladimir Davydov 2015-11-20 12:42 ` Vladimir Davydov 2015-11-20 18:56 ` Johannes Weiner 2015-11-20 18:56 ` Johannes Weiner 2015-11-23 9:36 ` Vladimir Davydov 2015-11-23 9:36 ` Vladimir Davydov 2015-11-23 9:36 ` Vladimir Davydov 2015-11-23 18:20 ` Johannes Weiner 2015-11-23 18:20 ` Johannes Weiner 2015-11-24 13:43 ` Vladimir Davydov 2015-11-24 13:43 ` Vladimir Davydov 2015-11-24 13:43 ` Vladimir Davydov 2015-11-24 13:43 ` Vladimir Davydov 2015-11-12 23:41 ` [PATCH 10/14] mm: memcontrol: generalize the socket accounting jump label Johannes Weiner 2015-11-12 23:41 ` Johannes Weiner 2015-11-13 10:43 ` Michal Hocko 2015-11-13 10:43 ` Michal Hocko 2015-11-14 13:29 ` Vladimir Davydov 2015-11-14 13:29 ` Vladimir Davydov 2015-11-14 13:29 ` Vladimir Davydov 2015-11-12 23:41 ` [PATCH 11/14] mm: memcontrol: do not account memory+swap on unified hierarchy Johannes Weiner 2015-11-12 23:41 ` Johannes Weiner 2015-11-13 10:37 ` Michal Hocko 2015-11-13 10:37 ` Michal Hocko 2015-11-14 13:23 ` Vladimir Davydov 2015-11-14 13:23 ` Vladimir Davydov 2015-11-14 13:23 ` Vladimir Davydov 2015-11-12 23:41 ` [PATCH 12/14] mm: memcontrol: move socket code for unified hierarchy accounting Johannes Weiner 2015-11-12 23:41 ` Johannes Weiner 2015-11-20 12:44 ` Vladimir Davydov 2015-11-20 12:44 ` Vladimir Davydov 2015-11-20 12:44 ` Vladimir Davydov 2015-11-12 23:41 ` [PATCH 13/14] mm: memcontrol: account socket memory in unified hierarchy memory controller Johannes Weiner 2015-11-12 23:41 ` Johannes Weiner 2015-11-16 15:59 ` Michal Hocko 2015-11-16 15:59 ` Michal Hocko 2015-11-16 18:18 ` Johannes Weiner 2015-11-16 18:18 ` Johannes Weiner 2015-11-16 18:18 ` Johannes Weiner 2015-11-16 18:18 ` Johannes Weiner 2015-11-18 16:22 ` Michal Hocko 2015-11-18 16:22 ` Michal Hocko 2015-11-18 21:48 ` Johannes Weiner 2015-11-18 21:48 ` Johannes Weiner 2015-11-19 13:50 ` Michal Hocko 2015-11-19 13:50 ` Michal Hocko 2015-11-19 16:52 ` Johannes Weiner 2015-11-19 16:52 ` Johannes Weiner 2015-11-19 16:52 ` Johannes Weiner 2015-11-20 13:10 ` Vladimir Davydov 2015-11-20 13:10 ` Vladimir Davydov 2015-11-20 13:10 ` Vladimir Davydov 2015-11-20 13:10 ` Vladimir Davydov 2015-11-20 19:25 ` Johannes Weiner 2015-11-20 19:25 ` Johannes Weiner 2015-11-20 19:25 ` Johannes Weiner 2015-11-23 10:00 ` Vladimir Davydov 2015-11-23 10:00 ` Vladimir Davydov 2015-11-23 10:00 ` Vladimir Davydov 2015-11-23 10:00 ` Vladimir Davydov 2015-11-23 19:31 ` Johannes Weiner 2015-11-23 19:31 ` Johannes Weiner 2015-11-12 23:41 ` [PATCH 14/14] mm: memcontrol: hook up vmpressure to socket pressure Johannes Weiner 2015-11-12 23:41 ` Johannes Weiner 2015-11-15 13:54 ` Vladimir Davydov 2015-11-15 13:54 ` Vladimir Davydov 2015-11-15 13:54 ` Vladimir Davydov 2015-11-16 18:53 ` Johannes Weiner 2015-11-16 18:53 ` Johannes Weiner 2015-11-17 20:18 ` Vladimir Davydov 2015-11-17 20:18 ` Vladimir Davydov 2015-11-17 20:18 ` Vladimir Davydov 2015-11-17 20:18 ` Vladimir Davydov 2015-11-17 22:22 ` Johannes Weiner 2015-11-17 22:22 ` Johannes Weiner 2015-11-17 22:22 ` Johannes Weiner 2015-11-18 16:02 ` Vladimir Davydov 2015-11-18 16:02 ` Vladimir Davydov 2015-11-18 16:02 ` Vladimir Davydov 2015-11-18 16:02 ` Vladimir Davydov 2015-11-18 18:27 ` Johannes Weiner 2015-11-18 18:27 ` Johannes Weiner
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1447371693-25143-1-git-send-email-hannes@cmpxchg.org \ --to=hannes@cmpxchg.org \ --cc=akpm@linux-foundation.org \ --cc=cgroups@vger.kernel.org \ --cc=davem@davemloft.net \ --cc=kernel-team@fb.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=mhocko@suse.cz \ --cc=netdev@vger.kernel.org \ --cc=tj@kernel.org \ --cc=vdavydov@virtuozzo.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.