From: ebiederm@xmission.com (Eric W. Biederman)
To: "Hongjie Fang (方洪杰)" <Hongjie.Fang@spreadtrum.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org
Subject: Re: [PATCH 4.3-rc6] proc: fix oom_adj value read from /proc/<pid>/oom_adj
Date: Tue, 20 Oct 2015 12:27:58 -0500 [thread overview]
Message-ID: <87zizdfo0x.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <65a10261038346b1a778443fd15f0980@SHMBX01.spreadtrum.com> ("Hongjie Fang \=\?utf-8\?B\?KOaWuea0quadsCkiJ3M\=\?\= message of "Tue, 20 Oct 2015 12:34:36 +0000")
"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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next parent reply other threads:[~2015-10-20 17:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <65a10261038346b1a778443fd15f0980@SHMBX01.spreadtrum.com>
2015-10-20 17:27 ` Eric W. Biederman [this message]
2015-10-21 6:10 ` 答复: " Hongjie Fang (方洪杰)
2015-10-21 9:37 ` Michal Hocko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zizdfo0x.fsf@x220.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=Hongjie.Fang@spreadtrum.com \
--cc=akpm@linux-foundation.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox