The patch titled Subject: mm-oom-make-the-calculation-of-oom-badness-more-accurate-v3 has been added to the -mm tree. Its filename is mm-oom-make-the-calculation-of-oom-badness-more-accurate-v3.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-oom-make-the-calculation-of-oom-badness-more-accurate-v3.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-oom-make-the-calculation-of-oom-badness-more-accurate-v3.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: Yafang Shao <laoar.shao@xxxxxxxxx> Subject: mm-oom-make-the-calculation-of-oom-badness-more-accurate-v3 - fix the type of variable 'point' in oom_evaluate_task() - initialize oom_control->chosen_points in select_bad_process() per Michal - update the comment in proc_oom_score() per Michal Link: http://lkml.kernel.org/r/1594396651-9931-1-git-send-email-laoar.shao@xxxxxxxxx Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx> Acked-by: Michal Hocko <mhocko@xxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Qian Cai <cai@xxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/tty/sysrq.c | 1 - fs/proc/base.c | 10 +++++++--- mm/memcontrol.c | 1 - mm/oom_kill.c | 5 +++-- mm/page_alloc.c | 1 - 5 files changed, 10 insertions(+), 8 deletions(-) --- a/drivers/tty/sysrq.c~mm-oom-make-the-calculation-of-oom-badness-more-accurate-v3 +++ a/drivers/tty/sysrq.c @@ -382,7 +382,6 @@ static void moom_callback(struct work_st .memcg = NULL, .gfp_mask = gfp_mask, .order = -1, - .chosen_points = LONG_MIN, }; mutex_lock(&oom_lock); --- a/fs/proc/base.c~mm-oom-make-the-calculation-of-oom-badness-more-accurate-v3 +++ a/fs/proc/base.c @@ -554,10 +554,14 @@ static int proc_oom_score(struct seq_fil long badness; badness = oom_badness(task, totalpages); - if (badness != LONG_MIN) { - /* Let's keep the range of points as [0, 2000]. */ + /* + * Special case OOM_SCORE_ADJ_MIN for all others scale the + * badness value into [0, 2000] range which we have been + * exporting for a long time so userspace might depend on it. + */ + if (badness != LONG_MIN) points = (1000 + badness * 1000 / (long)totalpages) * 2 / 3; - } + seq_printf(m, "%lu\n", points); return 0; --- a/mm/memcontrol.c~mm-oom-make-the-calculation-of-oom-badness-more-accurate-v3 +++ a/mm/memcontrol.c @@ -1666,7 +1666,6 @@ static bool mem_cgroup_out_of_memory(str .memcg = memcg, .gfp_mask = gfp_mask, .order = order, - .chosen_points = LONG_MIN, }; bool ret; --- a/mm/oom_kill.c~mm-oom-make-the-calculation-of-oom-badness-more-accurate-v3 +++ a/mm/oom_kill.c @@ -306,7 +306,7 @@ static enum oom_constraint constrained_a static int oom_evaluate_task(struct task_struct *task, void *arg) { struct oom_control *oc = arg; - unsigned long points; + long points; if (oom_unkillable_task(task)) goto next; @@ -361,6 +361,8 @@ abort: */ static void select_bad_process(struct oom_control *oc) { + oc->chosen_points = LONG_MIN; + if (is_memcg_oom(oc)) mem_cgroup_scan_tasks(oc->memcg, oom_evaluate_task, oc); else { @@ -1124,7 +1126,6 @@ void pagefault_out_of_memory(void) .memcg = NULL, .gfp_mask = 0, .order = 0, - .chosen_points = LONG_MIN, }; if (mem_cgroup_oom_synchronize(true)) --- a/mm/page_alloc.c~mm-oom-make-the-calculation-of-oom-badness-more-accurate-v3 +++ a/mm/page_alloc.c @@ -3915,7 +3915,6 @@ __alloc_pages_may_oom(gfp_t gfp_mask, un .memcg = NULL, .gfp_mask = gfp_mask, .order = order, - .chosen_points = LONG_MIN, }; struct page *page; _ Patches currently in -mm which might be from laoar.shao@xxxxxxxxx are mm-oom-make-the-calculation-of-oom-badness-more-accurate.patch mm-oom-make-the-calculation-of-oom-badness-more-accurate-v3.patch