Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp20157ybb; Tue, 14 Apr 2020 17:58:22 -0700 (PDT) X-Google-Smtp-Source: APiQypLZLb/6UOgehVizTPwaCSDt22mqJNaXvi8UKdwoOcMlRgT4RSrQQzlTEmrCASPkutbj/5vd X-Received: by 2002:a17:906:960d:: with SMTP id s13mr2707784ejx.263.1586912302148; Tue, 14 Apr 2020 17:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586912302; cv=none; d=google.com; s=arc-20160816; b=IiwLe0I7DmuFJIwuseH3cl7RTXfhdP61n6ukMQ6Redz9xXkS06r5qZr7Aus8jlFCXJ bv77pPPYinCSHHI0i3UsJTRDiGh5oK0f5Bt1EuQuvff75h9YLvuc63su1QhPWUb8pqw2 0uEkMOpGyQprb85K4L+EHw1WyUQbbtPyLo3ypzx1fGT25OYa0vFUPkpkbiTcqfkhxZad SDQdINm+GJgHIqySYdcebN4kMdLSXZQv25ZHPgW1jYaEL8/A4wnYHXu9XFcHVzfJwHN4 0LyvIfNFDy62IIMKEFiDT5oOJWm4nJfdWR4SDaVnbxkSSkr4oOLyjXwCcUxq72uJ0jkW 71nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:date:in-reply-to:message-id :subject:cc:to:from:user-agent:references; bh=MUZVpk8IT2yspdMnT/9MwdL+rXBSC/r4oBVs4NZErQY=; b=uNvtJBSms5YtCv7CNF4lGZ5tz8CB1eUF3LhsH6UstgCx+ebhz6YfZlLyUaF2m3Y/8H RUr4z+wc7D+C0qTFE+Sd7wvRhd1jECEbMWPDSCIpynTbZqnZxeq7eEtonOairFdti11j 2RfpToYeEvriFNULNrjqOE9u65hDRTnSLNrx9Tgj/9v7obl3q0RvxnBA0V0krA0llaNT 7B69JI2zF+TzfE0Iel5Gv3OOzOBP2DbhPELbeNubVh2k7As2olzDPaeLso7zAfVVJSoe 7T0m8KbyfuVqX6/BzouhPHtZrdcuE5z/vkkCmmCmIze/KditVexK/vEzKR3Pm+EVP69o TYKA== 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 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i90si9369447edd.128.2020.04.14.17.57.59; Tue, 14 Apr 2020 17:58:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733286AbgDMUdE (ORCPT + 99 others); Mon, 13 Apr 2020 16:33:04 -0400 Received: from foss.arm.com ([217.140.110.172]:45986 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727877AbgDMUdD (ORCPT ); Mon, 13 Apr 2020 16:33:03 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0C14930E; Mon, 13 Apr 2020 13:33:02 -0700 (PDT) Received: from e113632-lin (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ADB4E3F6C4; Mon, 13 Apr 2020 13:33:00 -0700 (PDT) References: <245c792f0e580b3ca342ad61257f4c066ee0f84f.1586594833.git.rocking@linux.alibaba.com> <6f372bce-151e-79e1-2fda-d8b2bcf777d6@linux.alibaba.com> User-agent: mu4e 0.9.17; emacs 26.3 From: Valentin Schneider To: Peng Wang Cc: 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, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched/fair: Simplify the code of should_we_balance() Message-ID: In-reply-to: <6f372bce-151e-79e1-2fda-d8b2bcf777d6@linux.alibaba.com> Date: Mon, 13 Apr 2020 21:32:37 +0100 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/04/20 09:42, Peng Wang wrote: > 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. >> It's not really changing much, but if it helps making it a bit more readable, why not. Small nit below. Reviewed-by: Valentin Schneider >> 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? */ Nit: That should be either "the balance CPU" or "the first CPU in the group balance mask" >> + return group_balance_cpu(sg) == env->dst_cpu; >> } >> >> /* >> > > +juri.lelli@redhat.com