[Devel] [PATCH RHEL8 COMMIT] mm/memcg: fix cache growth above cache.limit_in_bytes
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Jul 30 20:24:07 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-305.3.1.vz8.7.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-305.3.1.vz8.7.1
------>
commit a3446e41114342a9a9880a32c77d867fc78a4733
Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
Date: Thu Jul 29 18:20:48 2021 +0300
mm/memcg: fix cache growth above cache.limit_in_bytes
Exceeding cache above cache.limit_in_bytes schedules high_work_func()
which tries to reclaim 32 pages. If cache generated fast enough or it allows
cgroup to steadily grow above cache.limit_in_bytes because we don't reclaim
enough. Try to reclaim exceeded amount of cache instead.
https://jira.sw.ru/browse/PSBM-106384
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
(cherry picked from commit 098f6a9add74a10848494427046cb8087ceb27d1)
https://jira.sw.ru/browse/PSBM-131957
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
---
mm/memcontrol.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 4a4a82c55225..58440b9cbb1f 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2538,6 +2538,8 @@ static unsigned long reclaim_high(struct mem_cgroup *memcg,
unsigned long nr_reclaimed = 0;
do {
+ long cache_overused;
+
if (page_counter_read(&memcg->memory) >
READ_ONCE(memcg->memory.high)) {
memcg_memory_event(memcg, MEMCG_HIGH);
@@ -2545,9 +2547,12 @@ static unsigned long reclaim_high(struct mem_cgroup *memcg,
nr_pages, gfp_mask, true);
}
- if (page_counter_read(&memcg->cache) > memcg->cache.max)
+ cache_overused = page_counter_read(&memcg->cache) -
+ memcg->cache.max;
+
+ if (cache_overused > 0)
nr_reclaimed += try_to_free_mem_cgroup_pages(memcg,
- nr_pages, gfp_mask, false);
+ cache_overused, gfp_mask, false);
} while ((memcg = parent_mem_cgroup(memcg)) &&
!mem_cgroup_is_root(memcg));
More information about the Devel
mailing list