* + oom_kill-oom_score_adj-broken-for-processes-with-small-memory-usage.patch added to -mm tree
@ 2021-07-16 4:06 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2021-07-16 4:06 UTC (permalink / raw)
To: cminyard, mhocko, mm-commits, rientjes
The patch titled
Subject: oom_kill: oom_score_adj broken for processes with small memory usage
has been added to the -mm tree. Its filename is
oom_kill-oom_score_adj-broken-for-processes-with-small-memory-usage.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/oom_kill-oom_score_adj-broken-for-processes-with-small-memory-usage.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/oom_kill-oom_score_adj-broken-for-processes-with-small-memory-usage.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Corey Minyard <cminyard@mvista.com>
Subject: oom_kill: oom_score_adj broken for processes with small memory usage
If you have a process with less than 1000 totalpages, the calculation:
adj = (long)p->signal->oom_score_adj;
...
adj *= totalpages / 1000;
will always result in adj being zero no matter what oom_score_adj is,
which could result in the wrong process being picked for killing.
Fix by adding 1000 to totalpages before dividing.
I ran across this trying to diagnose another problem where I set up a
cgroup with a small amount of memory and couldn't get a test program to
work right.
I'm not sure this is quite right, to keep closer to the current behavior
you could do:
if (totalpages >= 1000) adj *= totalpages / 1000;
but that would map 0-1999 to the same value. But this at least shows the
issue. I can provide a test program the shows the issue, but I think it's
pretty obvious from the code.
Link: https://lkml.kernel.org/r/20210701125430.836308-1-minyard@acm.org
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/oom_kill.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
--- a/mm/oom_kill.c~oom_kill-oom_score_adj-broken-for-processes-with-small-memory-usage
+++ a/mm/oom_kill.c
@@ -233,8 +233,11 @@ long oom_badness(struct task_struct *p,
mm_pgtables_bytes(p->mm) / PAGE_SIZE;
task_unlock(p);
- /* Normalize to oom_score_adj units */
- adj *= totalpages / 1000;
+ /*
+ * Normalize to oom_score_adj units. You should never
+ * multiply by zero here, or oom_score_adj will not work.
+ */
+ adj *= (totalpages + 1000) / 1000;
points += adj;
return points;
_
Patches currently in -mm which might be from cminyard@mvista.com are
oom_kill-oom_score_adj-broken-for-processes-with-small-memory-usage.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-16 4:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16 4:06 + oom_kill-oom_score_adj-broken-for-processes-with-small-memory-usage.patch added to -mm tree akpm
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.