mm, oom: keep oom_adj under or at upper limit when printing [v2]
Subsystems (2)
PATCH 1/1 mm, oom: keep oom_adj under or at upper limit when printing [v2]
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.
v2: moved the change to after put task to make sure the task is
released asap
--- fs/proc/base.c | 2 ++ 1 file changed, 2 insertions(+)
fs/proc/base.c +2 -0
@@ -1049,6 +1049,8 @@ static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count, oom_adj = (task->signal->oom_score_adj * -OOM_DISABLE ) /OOM_SCORE_ADJ_MAX ;put_task_struct (task); +if (oom_adj >OOM_ADJUST_MAX ) + oom_adj =OOM_ADJUST_MAX ; len =snprintf (buffer,sizeof (buffer),"%d\n" , oom_adj);return simple_read_from_buffer (buf, count, ppos, buffer, len); }
Signature · 1 line
2.25.1
Quoted 7 lines · Charles Haithcock
For
oom_score_adjvalues in the range [942,999], the current calculations will print 16 foroom_adj. This patch simply limits the output so output is inline with docs.v2: moved the change to after put task to make sure the task is
released asapSigned-off-by Charles Haithcock <[email protected]>
OK, this seems to be broken since the scaling has been introduced. oom_score is deprecated but it is true that the fix is trivial. Now that you have added this clamping we can drop the oom_score_adj == OOM_SCORE_ADJ_MAX branch as well.
Have you found out this by code inspeciton or some userspace actually cares?
Anyway
Quoted 20 lines
--- fs/proc/base.c | 2 ++ 1 file changed, 2 insertions(+)fs/proc/base.c +2
-0@@ -1049,6 +1049,8 @@ static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count, oom_adj = (task->signal->oom_score_adj * -OOM_DISABLE ) /OOM_SCORE_ADJ_MAX ;put_task_struct (task); +if (oom_adj >OOM_ADJUST_MAX ) + oom_adj =OOM_ADJUST_MAX ; len =snprintf (buffer,sizeof (buffer),"%d\n" , oom_adj);return simple_read_from_buffer (buf, count, ppos, buffer, len); }Signature · 1 line
2.25.1
Signature · 2 lines
Michal Hocko SUSE Labs