Re: [RFC 0/7] Introduce memory allocation speed throttle in memcg
From: yulei zhang <hidden>
Date: 2021-05-31 12:11:22
Also in:
linux-mm
On Thu, May 27, 2021 at 4:52 AM Shakeel Butt [off-list ref] wrote:
Adding linux-mm and related folks. On Wed, May 26, 2021 at 9:18 AM [off-list ref] wrote:quoted
From: Yulei Zhang <redacted> In this patch set we present the idea to suppress the memory allocation speed in memory cgroup, which aims to avoid direct reclaim caused by memory allocation burst while under memory pressure.I am assuming here direct reclaim means global reclaim.
Yep.
quoted
As minimum watermark could be easily broken if certain tasks allocate massive amount of memory in a short period of time, in that case it will trigger the direct memory reclaim and cause unacceptable jitters for latency critical tasks, such as guaranteed pod task in K8s. With memory allocation speed throttle(mst) mechanism we could lower the memory allocation speed in certian cgroup, usually for low priority tasks, so that could avoid the direct memory reclaim in time.Can you please explain why memory.high is not good enough for your use-case? You can orchestrate the memory.high limits in such a way that those certain cgroups hit their memory.high limit before causing the global reclaim. You might need to dynamically adjust the limits based on other workloads or unaccounted memory.
Yep, dynamically adjust the memory.high limits can ease the memory pressure and postpone the global reclaim, but it can easily trigger the oom in the cgroups, which may not be suitable in certain usage cases when we want the services alive. Using throttle to suppress the allocation may help keep the activities and doesn't impact others. Thanks.
quoted
And per-memcg interfaces are introduced under memcg tree, not visiable for root memcg. - <cgroup_root>/<cgroup_name>/memory.alloc_bps - 0 -> means memory speed throttle disabled - non-zero -> value in bytes for memory allocation speed limits - <cgroup_root>/<cgroup_name>/memory.stat:mst_mem_spd_max it records the max memory allocation speed of the memory cgroup in the last period of time slice - <cgroup_root>/<cgroup_name>/memory.stat:mst_nr_throttled it represents the number of times for allocation throttling Yulei Zhang (7): mm: record total charge and max speed counter in memcg mm: introduce alloc_bps to memcg for memory allocation speed throttle mm: memory allocation speed throttle setup in hierarchy mm: introduce slice analysis into memory speed throttle mechanism mm: introduce memory allocation speed throttle mm: record the numbers of memory allocation throttle mm: introduce mst low and min watermark include/linux/memcontrol.h | 23 +++ include/linux/page_counter.h | 8 + init/Kconfig | 8 + mm/memcontrol.c | 295 +++++++++++++++++++++++++++++++++++ mm/page_counter.c | 39 +++++ 5 files changed, 373 insertions(+) -- 2.28.0