linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] mm, oom: keep oom_adj under or at upper limit when printing
@ 2020-10-19 21:52 Charles Haithcock
  2020-10-20 10:04 ` Alexey Dobriyan
  0 siblings, 1 reply; 2+ messages in thread
From: Charles Haithcock @ 2020-10-19 21:52 UTC (permalink / raw)
  To: adobriyan; +Cc: trivial, akpm, linux-fsdevel, Charles Haithcock

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>
---
 fs/proc/base.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 617db4e0faa0..37e57b21dbe5 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1048,6 +1048,8 @@ static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count,
 	else
 		oom_adj = (task->signal->oom_score_adj * -OOM_DISABLE) /
 			  OOM_SCORE_ADJ_MAX;
+	if (oom_adj > OOM_ADJUST_MAX)
+		oom_adj = OOM_ADJUST_MAX;
 	put_task_struct(task);
 	len = snprintf(buffer, sizeof(buffer), "%d\n", oom_adj);
 	return simple_read_from_buffer(buf, count, ppos, buffer, len);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] mm, oom: keep oom_adj under or at upper limit when printing
  2020-10-19 21:52 [PATCH net-next] mm, oom: keep oom_adj under or at upper limit when printing Charles Haithcock
@ 2020-10-20 10:04 ` Alexey Dobriyan
  0 siblings, 0 replies; 2+ messages in thread
From: Alexey Dobriyan @ 2020-10-20 10:04 UTC (permalink / raw)
  To: Charles Haithcock; +Cc: trivial, akpm, linux-fsdevel

On Mon, Oct 19, 2020 at 03:52:29PM -0600, Charles Haithcock wrote:
> 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.

> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -1048,6 +1048,8 @@ static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count,
>  	else
>  		oom_adj = (task->signal->oom_score_adj * -OOM_DISABLE) /
>  			  OOM_SCORE_ADJ_MAX;
> +	if (oom_adj > OOM_ADJUST_MAX)
> +		oom_adj = OOM_ADJUST_MAX;
>  	put_task_struct(task);

Should be done after PUT so that task is put as early as possible.

>  	len = snprintf(buffer, sizeof(buffer), "%d\n", oom_adj);
>  	return simple_read_from_buffer(buf, count, ppos, buffer, len);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-20 10:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 21:52 [PATCH net-next] mm, oom: keep oom_adj under or at upper limit when printing Charles Haithcock
2020-10-20 10:04 ` Alexey Dobriyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).