Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1251919
| From | ebiederm@xmission.com (Eric W. Biederman) |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 4.3-rc6] proc: fix oom_adj value read from /proc/<pid>/oom_adj |
| Date | 2015-10-20 19:40 +0200 |
| Message-ID | <qlJ3c-2aM-35@gated-at.bofh.it> (permalink) |
| References | <qlEmS-3NZ-23@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
"Hongjie Fang (方洪杰)" <Hongjie.Fang@spreadtrum.com> writes:
> The oom_adj's value reading through /proc/<pid>/oom_adj is different
> with the value written into /proc/<pid>/oom_adj.
> Fix this by adding a adjustment factor.
*Scratches my head*
Won't changing the interpretation of what is written break existing
userspace applications that write this value?
Added a few more likely memory management suspects that might understand
what is going on here.
Eric
>
> Signed-off-by: Hongjie Fang <hongjie.fang@spreadtrum.com>
> ---
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index b25eee4..1ea0589 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -1043,6 +1043,7 @@ static ssize_t oom_adj_write(struct file *file, const char __user *buf,
> int oom_adj;
> unsigned long flags;
> int err;
> + int adjust;
>
> memset(buffer, 0, sizeof(buffer));
> if (count > sizeof(buffer) - 1)
> @@ -1084,8 +1085,10 @@ static ssize_t oom_adj_write(struct file *file, const char __user *buf,
> */
> if (oom_adj == OOM_ADJUST_MAX)
> oom_adj = OOM_SCORE_ADJ_MAX;
> - else
> - oom_adj = (oom_adj * OOM_SCORE_ADJ_MAX) / -OOM_DISABLE;
> + else{
> + adjust = oom_adj > 0 ? (-OOM_DISABLE-1) : -(-OOM_DISABLE-1);
> + oom_adj = (oom_adj * OOM_SCORE_ADJ_MAX + adjust) / -OOM_DISABLE;
> + }
>
> if (oom_adj < task->signal->oom_score_adj &&
> !capable(CAP_SYS_RESOURCE)) {
>
> --
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 4.3-rc6] proc: fix oom_adj value read from /proc/<pid>/oom_adj Hongjie Fang (方洪杰) <Hongjie.Fang@spreadtrum.com> - 2015-10-20 14:40 +0200
Re: [PATCH 4.3-rc6] proc: fix oom_adj value read from /proc/<pid>/oom_adj ebiederm@xmission.com (Eric W. Biederman) - 2015-10-20 19:40 +0200
Re: [PATCH 4.3-rc6] proc: fix oom_adj value read from /proc/<pid>/oom_adj Michal Hocko <mhocko@kernel.org> - 2015-10-21 11:40 +0200
Re: [PATCH 4.3-rc6] proc: fix oom_adj value read from /proc/<pid>/oom_adj David Rientjes <rientjes@google.com> - 2015-10-21 23:00 +0200
csiph-web