From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752980AbbJHGuR (ORCPT ); Thu, 8 Oct 2015 02:50:17 -0400 Received: from mail113-249.mail.alibaba.com ([205.204.113.249]:53874 "EHLO us-alimail-mta2.hst.scl.en.alidc.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751605AbbJHGuN (ORCPT ); Thu, 8 Oct 2015 02:50:13 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e02c03308;MF=hillf.zj@alibaba-inc.com;NM=1;PH=DS;RN=6;SR=0; Reply-To: "Hillf Danton" From: "Hillf Danton" To: "'Oleg Nesterov'" Cc: "Andrew Morton" , "David Rientjes" , "'Kyle Walker'" , "'Michal Hocko'" , "linux-kernel" References: <04db01d10192$615ef0c0$241cd240$@alibaba-inc.com> In-Reply-To: <04db01d10192$615ef0c0$241cd240$@alibaba-inc.com> Subject: Re: [PATCH -mm v2 2/3] mm/oom_kill: cleanup the "kill sharing same memory" loop Date: Thu, 08 Oct 2015 14:43:49 +0800 Message-ID: <04df01d10194$b1035bf0$130a13d0$@alibaba-inc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQI3E9OEawEymYXz1lVBmFIMt4Jq6Z2U/SEQ Content-Language: zh-cn Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > Purely cosmetic, but the complex "if" condition looks annoying to me. > Especially because it is not consistent with OOM_SCORE_ADJ_MIN check > which adds another if/continue. > > Signed-off-by: Oleg Nesterov > --- > mm/oom_kill.c | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > > diff --git a/mm/oom_kill.c b/mm/oom_kill.c > index b6b8c78..c189ee5 100644 > --- a/mm/oom_kill.c > +++ b/mm/oom_kill.c > @@ -583,14 +583,18 @@ void oom_kill_process(struct oom_control *oc, struct task_struct *p, > * pending fatal signal. > */ > rcu_read_lock(); > - for_each_process(p) > - if (p->mm == mm && !same_thread_group(p, victim) && > - !(p->flags & PF_KTHREAD)) { > - if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) > - continue; > + for_each_process(p) { > + if (p->mm != mm) > + continue; > + if (same_thread_group(p, victim)) > + continue; > + if (unlikely(p->flags & PF_KTHREAD)) > + continue; Given the result of "grep -nr PF_KTHREAD linux-next/mm", it looks a helper function, like current_is_kswapd(), is needed. int task_is_kthread(struct task_struct *task) Other than that, Acked-by: Hillf Danton > + if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) > + continue; > > - do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, true); > - } > + do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, true); > + } > rcu_read_unlock(); > > mmput(mm); > -- > 2.4.3 > >