Skip to content

Commit 6660656

Browse files
chaithcotorvalds
authored andcommitted
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>
1 parent 6993d0f commit 6660656

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fs/proc/base.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,8 @@ static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count,
10491049
oom_adj = (task->signal->oom_score_adj * -OOM_DISABLE) /
10501050
OOM_SCORE_ADJ_MAX;
10511051
put_task_struct(task);
1052+
if (oom_adj > OOM_ADJUST_MAX)
1053+
oom_adj = OOM_ADJUST_MAX;
10521054
len = snprintf(buffer, sizeof(buffer), "%d\n", oom_adj);
10531055
return simple_read_from_buffer(buf, count, ppos, buffer, len);
10541056
}

0 commit comments

Comments
 (0)