Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2268558ybb; Sun, 12 Apr 2020 01:43:40 -0700 (PDT) X-Google-Smtp-Source: APiQypIAj7NJEXZbNA2mK46NPIXZfrmiQzEl8GhlmKLHLlrooxg5PZ1r2EBrr7zC1NFEp+t4GveV X-Received: by 2002:aed:3284:: with SMTP id z4mr606932qtd.22.1586681020378; Sun, 12 Apr 2020 01:43:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586681020; cv=none; d=google.com; s=arc-20160816; b=DGtL98CI8YmedfRyUegKSWu2upWp6dppejoIuALVy0MU+HKL+2IG5MAPe0PIrzPfGw 8n7lZOIsmoQBXqbDVsujMJq6YCZpLep17DBOu3s3vJJPCdilf+Vb0QWBIYc3iSz4Y1lr 3ewWUEvZYEM5492d3A9h+Z41NqMhr9gy+tKsc/yLRK2qmIG2nAJdu4Q/ZE4KBoSilSV0 RpQ8OTwh+Smug3qME8cbHPlN8YIDITLY1t/N1uDRDXsc08Ft80qnNoU6K1uqPzQJuBaH AfuAS16Dfgyj8gH+ealDe2KM/NF/U6anmJt2crCRdSSgs+10fHwUiL3W3jybPsiJZU94 MZXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:references:cc:to:subject :from; bh=dSouYUwU9l8R35T6R8KCYXbtFjjGiSqLk04c7nF7njk=; b=xCmAFIUcpt3QNmDKZmHr4udOmKlp5JHShreBQU4jioDhW2n9J7GpygAynMc/xCmmVj okIsS8Z4GIbBq189QHd6BPki0qgEeFgW39EnKLtUVYLCV4zvYtj7UOvB726nz7HW10XS LllRUP2tSGiXCTc9n2x2gWic8yI/k9NqGQ2yyOG8VoyQjOw7Om6t8mjWdH6hkEAnAgzo vvqmM7SYiult1j/0Q1K9f19QQDwITJMFK8MgM9TDSjS2hfnd5fymHZhKYHeeBZvww1za EcN0WbVMKs/n3MbiWUI4jJjyIWJ2u+WYdeaVzyQIuod1pBOpeIDEqYUO14uFPgOxVHEk vTxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o6si736601qtm.385.2020.04.12.01.43.25; Sun, 12 Apr 2020 01:43:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726658AbgDLIm0 (ORCPT + 99 others); Sun, 12 Apr 2020 04:42:26 -0400 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:57124 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725903AbgDLImZ (ORCPT ); Sun, 12 Apr 2020 04:42:25 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R311e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04407;MF=rocking@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0TvGWLBf_1586680942; Received: from 30.25.201.141(mailfrom:rocking@linux.alibaba.com fp:SMTPD_---0TvGWLBf_1586680942) by smtp.aliyun-inc.com(127.0.0.1); Sun, 12 Apr 2020 16:42:22 +0800 From: Peng Wang Subject: Re: [PATCH] sched/fair: Simplify the code of should_we_balance() To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de Cc: linux-kernel@vger.kernel.org References: <245c792f0e580b3ca342ad61257f4c066ee0f84f.1586594833.git.rocking@linux.alibaba.com> Message-ID: <6f372bce-151e-79e1-2fda-d8b2bcf777d6@linux.alibaba.com> Date: Sun, 12 Apr 2020 16:42:21 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <245c792f0e580b3ca342ad61257f4c066ee0f84f.1586594833.git.rocking@linux.alibaba.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/11/20 5:20 PM, Peng Wang wrote: > We only consider group_balance_cpu() after there is no idle > cpu. So, just do comparison before return at these two cases. > > Signed-off-by: Peng Wang > --- > kernel/sched/fair.c | 16 +++++----------- > 1 file changed, 5 insertions(+), 11 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 1ea3ddd..81b2c647 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -9413,7 +9413,7 @@ static int active_load_balance_cpu_stop(void *data); > static int should_we_balance(struct lb_env *env) > { > struct sched_group *sg = env->sd->groups; > - int cpu, balance_cpu = -1; > + int cpu; > > /* > * Ensure the balancing environment is consistent; can happen > @@ -9434,18 +9434,12 @@ static int should_we_balance(struct lb_env *env) > if (!idle_cpu(cpu)) > continue; > > - balance_cpu = cpu; > - break; > + /* Are we the first idle CPU? */ > + return cpu == env->dst_cpu; > } > > - if (balance_cpu == -1) > - balance_cpu = group_balance_cpu(sg); > - > - /* > - * First idle CPU or the first CPU(busiest) in this sched group > - * is eligible for doing load balancing at this and above domains. > - */ > - return balance_cpu == env->dst_cpu; > + /* Are we the first balance CPU of this group? */ > + return group_balance_cpu(sg) == env->dst_cpu; > } > > /* > +juri.lelli@redhat.com