Re: [PATCH net-next] mm, oom: keep oom_adj under or at upper limit when printing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux