Linux-Fsdevel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH net-next] mm, oom: keep oom_adj under or at upper limit when printing [v2]
@ 2020-10-20 16:51 Charles Haithcock
  2020-10-26  7:33 ` Michal Hocko
  0 siblings, 1 reply; 2+ messages in thread
From: Charles Haithcock @ 2020-10-20 16:51 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.

v2: moved the change to after put task to make sure the task is
    released asap
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..eafabeaf21d1 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -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);
 }
-- 
2.25.1


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

* Re: [PATCH net-next] mm, oom: keep oom_adj under or at upper limit when printing [v2]
  2020-10-20 16:51 [PATCH net-next] mm, oom: keep oom_adj under or at upper limit when printing [v2] Charles Haithcock
@ 2020-10-26  7:33 ` Michal Hocko
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Hocko @ 2020-10-26  7:33 UTC (permalink / raw)
  To: Charles Haithcock; +Cc: adobriyan, trivial, akpm, linux-fsdevel

On Tue 20-10-20 10:51:30, 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.
> 
> v2: moved the change to after put task to make sure the task is
>     released asap
> Signed-off-by: Charles Haithcock <chaithco@redhat.com>

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
Acked-by: Michal Hocko <mhocko@suse.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..eafabeaf21d1 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -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);
>  }
> -- 
> 2.25.1
> 

-- 
Michal Hocko
SUSE Labs

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-20 16:51 [PATCH net-next] mm, oom: keep oom_adj under or at upper limit when printing [v2] Charles Haithcock
2020-10-26  7:33 ` Michal Hocko

Linux-Fsdevel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-fsdevel/0 linux-fsdevel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-fsdevel linux-fsdevel/ https://lore.kernel.org/linux-fsdevel \
		linux-fsdevel@vger.kernel.org
	public-inbox-index linux-fsdevel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-fsdevel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git