From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752914AbbJTRgX (ORCPT ); Tue, 20 Oct 2015 13:36:23 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:46865 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752658AbbJTRgV convert rfc822-to-8bit (ORCPT ); Tue, 20 Oct 2015 13:36:21 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: =?utf-8?B?SG9uZ2ppZSBGYW5nICjmlrnmtKrmnbAp?= Cc: "gregkh\@linuxfoundation.org" , "linux-kernel\@vger.kernel.org" , Andrew Morton , References: <65a10261038346b1a778443fd15f0980@SHMBX01.spreadtrum.com> Date: Tue, 20 Oct 2015 12:27:58 -0500 In-Reply-To: <65a10261038346b1a778443fd15f0980@SHMBX01.spreadtrum.com> ("Hongjie Fang \=\?utf-8\?B\?KOaWuea0quadsCkiJ3M\=\?\= message of "Tue, 20 Oct 2015 12:34:36 +0000") Message-ID: <87zizdfo0x.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-XM-AID: U2FsdGVkX18BdO91Ik34b9zc7f0zMkQPjJ4hRfsVbmk= X-SA-Exim-Connect-IP: 67.3.201.231 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 BAYES_20 BODY: Bayes spam probability is 5 to 20% * [score: 0.1346] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_05 8+ unique symbols in subject * 0.0 T_TooManySym_03 6+ unique symbols in subject * 0.0 T_TooManySym_04 7+ unique symbols in subject * 0.0 T_TooManySym_01 4+ unique symbols in subject * 0.0 T_TooManySym_02 5+ unique symbols in subject X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: =?ISO-8859-1?Q?*;Hongjie Fang (=e6=96=b9=e6=b4=aa=e6=9d=b0) ?= X-Spam-Relay-Country: X-Spam-Timing: total 436 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 4.3 (1.0%), b_tie_ro: 3.3 (0.8%), parse: 0.74 (0.2%), extract_message_metadata: 11 (2.5%), get_uri_detail_list: 1.10 (0.3%), tests_pri_-1000: 4.4 (1.0%), tests_pri_-950: 1.18 (0.3%), tests_pri_-900: 0.98 (0.2%), tests_pri_-400: 20 (4.7%), check_bayes: 19 (4.4%), b_tokenize: 5.0 (1.1%), b_tok_get_all: 8 (1.8%), b_comp_prob: 1.41 (0.3%), b_tok_touch_all: 2.3 (0.5%), b_finish: 0.58 (0.1%), tests_pri_0: 233 (53.4%), tests_pri_500: 157 (36.1%), poll_dns_idle: 149 (34.3%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 4.3-rc6] proc: fix oom_adj value read from /proc//oom_adj X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Wed, 24 Sep 2014 11:00:52 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Hongjie Fang (方洪杰)" writes: > The oom_adj's value reading through /proc//oom_adj is different > with the value written into /proc//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 > --- > 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)) { > > --