[Devel] [PATCH rh7] mm, memcg, oom_gurantee: change memcg oom overdraft formula

Andrey Ryabinin aryabinin at virtuozzo.com
Thu Apr 25 17:10:38 MSK 2019


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>
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index dc5940bbf026..e69273a5d314 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1995,7 +1995,7 @@ unsigned long mem_cgroup_overdraft(struct mem_cgroup *memcg)
 
 	guarantee = ACCESS_ONCE(memcg->oom_guarantee);
 	usage = page_counter_read(&memcg->memsw);
-	return div64_u64(1000 * usage, guarantee + 1);
+	return usage > guarantee ? (usage - guarantee) : 0;
 }
 
 unsigned long mem_cgroup_total_pages(struct mem_cgroup *memcg, bool swap)
-- 
2.21.0



More information about the Devel mailing list