[Devel] [PATCH RH8 2/2] mm, memcg, oom_gurantee: change memcg oom overdraft formula
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Fri Jun 11 17:29:42 MSK 2021
From: Andrey Ryabinin <aryabinin at virtuozzo.com>
Currently our oom killer kill tasks from cgroup with max overdraft.
Overdraft formula looks like this "usage/(gurantee + 1)". Which makes
all cgroups without gurantee (default) to be a first candidates for oom
kill since "usage_cgrp1"/"hundreds of megabytes" always < usage_cgrp2/1.
Change overdraft formula to simple "usage > guarantee ? usage - guarantee : 0".
Unrelated note: oom_guarantee is 0 by default and not inherited from parent
cgroup. Not going to change it since currently ther is no necessity for it.
Also this would require from userspace to make sure that oom_guarantee set
for all sub cgroups of cgroups like machine.slice wich has unreacheable high
oom_guarantee and we don't want this high guarantee on sub groups.
https://pmc.acronis.com/browse/VSTOR-22575
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
Reviewed-by: Konstantin Khorenko <khorenko at virtuozzo.com>
https://jira.sw.ru/browse/PSBM-127846
(cherry-picked from vz7 commit 0996bb7c7837 ("mm, memcg, oom_gurantee:
change memcg oom overdraft formula"))
Fixes: 02ccefe3c24f ("memcg: add oom_guarantee")
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 47d8069a026f..4d8cb7b4cd9a 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1364,7 +1364,7 @@ unsigned long mem_cgroup_overdraft(struct mem_cgroup *memcg)
guarantee = READ_ONCE(memcg->oom_guarantee);
usage = page_counter_read(&memcg->memsw);
- return div64_u64(1000 * usage, guarantee + 1);
+ return usage > guarantee ? (usage - guarantee) : 0;
}
bool mem_cgroup_dcache_is_low(struct mem_cgroup *memcg, int vfs_cache_min_ratio)
--
2.31.1
More information about the Devel
mailing list