Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm, oom: keep oom_adj under or at upper limit when printing

For oom_score_adj values in the range [942,999], the current
calculations will print 16 for oom_adj. This patch simply limits the
output so output is inline with docs.

Signed-off-by: Charles Haithcock <chaithco@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Link: https://lkml.kernel.org/r/20201020165130.33927-1-chaithco@redhat.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Charles Haithcock and committed by
Linus Torvalds
66606567 6993d0fd

+2
+2
fs/proc/base.c
··· 1049 1049 oom_adj = (task->signal->oom_score_adj * -OOM_DISABLE) / 1050 1050 OOM_SCORE_ADJ_MAX; 1051 1051 put_task_struct(task); 1052 + if (oom_adj > OOM_ADJUST_MAX) 1053 + oom_adj = OOM_ADJUST_MAX; 1052 1054 len = snprintf(buffer, sizeof(buffer), "%d\n", oom_adj); 1053 1055 return simple_read_from_buffer(buf, count, ppos, buffer, len); 1054 1056 }