[Devel] [PATCH RH9 v2 2/5] mm/memcontrol: fix available memory calculation in mem_cgroup_enough_memory
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Wed Sep 6 06:14:06 MSK 2023
The idea of mem_cgroup_enough_memory check is to return ENOMEM on
allocations when container memory cgroup is close to OOM.
In vz7 we have:
free = memcg->memsw.limit - page_counter_read(&memcg->memsw);
In vz9:
free = memcg->memsw.max - page_counter_read(&memcg->memory);
The error here is memsw -> memory change in rebase to vz8, after it we
do not care about swap usage at all. This leads to allowing allocations
even then all memory and swap are exhausted for container which is not
what we want.
https://jira.vzint.dev/browse/PSBM-149975
Fixes: 9417436f33d1 ("ve/mm: add heuristic check for memory overcommit")
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
mm/memcontrol.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 9287eed944d5..3a2099920756 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4283,7 +4283,7 @@ static int mem_cgroup_enough_memory(struct mem_cgroup *memcg, long pages)
long free;
/* unused memory */
- free = memcg->memsw.max - page_counter_read(&memcg->memory);
+ free = memcg->memsw.max - page_counter_read(&memcg->memsw);
/* reclaimable slabs */
free += memcg_page_state(memcg, NR_SLAB_RECLAIMABLE_B) >> PAGE_SHIFT;
--
2.41.0
More information about the Devel
mailing list