Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4463448ybb; Tue, 14 Apr 2020 07:49:05 -0700 (PDT) X-Google-Smtp-Source: APiQypJWVrLnQehWJmPQ/m0weoNvefIj9CQVivxnzmzDgZeieGq7v8w7Ccp+GsVQ5nzJTgUoKwdG X-Received: by 2002:a17:906:1352:: with SMTP id x18mr521620ejb.138.1586875745264; Tue, 14 Apr 2020 07:49:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586875745; cv=none; d=google.com; s=arc-20160816; b=TctaDS+NzqJCxCsEqox5vvTfJezPYUzwvE5kMfRRUBtzCgaDyQtQ8Uwdi5/BuIa9bD xuSXuku69Gs3BGzQ5Asqr4WS6d7/+PlIgonmMRY3SoX1J0sUhC7ihiIP0i8MrXNS8sml zOMk9xPtZFc0Qoab03rrL3jBmT/Q0T3tUdFZGrdgiQ2ONRKTFX83OLV5RQgpxXaduuUb GKxa3Hh/fsi7RLqkZIM1k0UcWSRtOBCe8BOIfnPLpmZya4FdVNDRkeXlh+Cc2gkg1D4g sWpzGgTIhJQjTQbXVqQR2mZ90bfsCg9jpItRusw64jCAzgkUzfxI8Tnm8Qf9rBku63xX WdWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=IHQRVLx2SQE97Miej6QF7cUPumlWCc/r2El9sm1eyXs=; b=fJfjwudXDyiRGyYxmRiDGLhf7Fomr/vmqcjwpAeZZOb5pOHfRslWwfq6XRH1JdnB8R y0LPJtWuxfWD9GGAPzENf59BeKGIULePve2ANCbhCIQGM4lTrEnncWW7S1W/Io07EiRE sNzf3zEVyC42n9gUqkgMHtbZ3xZV2t+9UtJmCNeU8/mZOD7ejp6ZxU7Dr0KYFFBJb2fw 4TtPGZY6TPd4gqcw3ox8GK5N7bj4xXd7Lbc4OHyk1/Cnwaedsrcwp+RJGxpeyhbJeMXo 8a5cMkam7YSp4hy3b91G4KXg3qmR5bTFj7IrF7rqfIvswuovcON+Z+1Dn+sxH0X+Yenr HugA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e8NsXpi7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o59si8671366eda.39.2020.04.14.07.48.41; Tue, 14 Apr 2020 07:49:05 -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; dkim=pass header.i=@linaro.org header.s=google header.b=e8NsXpi7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406592AbgDNHZV (ORCPT + 99 others); Tue, 14 Apr 2020 03:25:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406586AbgDNHZO (ORCPT ); Tue, 14 Apr 2020 03:25:14 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 240FDC0A3BDC for ; Tue, 14 Apr 2020 00:25:13 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id r17so8564673lff.2 for ; Tue, 14 Apr 2020 00:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IHQRVLx2SQE97Miej6QF7cUPumlWCc/r2El9sm1eyXs=; b=e8NsXpi76Rw/tiin1JzdrQpBcrU9kxharw4P9vLp4+s/4Nxgq/gt94GfOrLTlX2P6g VVK4LM957BsdVnvgl4CiM6Hf0LG1YeE9TTi7YSM6QFUq1EsQyy1MU8jn2/fcjLkRT3Ia 3p3GlrMqYaqOw/i+afDcQmSktbbecV1sPdm54E+I9JNu+bRahftGolJ2yW9sP58U2n3K cErgYMMd/nQ0PCfotNMEHwvNKoTReFI53nBr5Ue+mn+NC0yDl09yFLlgZgIGWDhLlHPW 1X04WLPRrvBWx0OLp0n43KUbNCiz2tX4+wmXsXoAlOXYaGlMZokpG7X88GFzxDgszBw6 wgoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IHQRVLx2SQE97Miej6QF7cUPumlWCc/r2El9sm1eyXs=; b=DJ0MZMR+t9BQAuFCIiA01Np7DgYU5RvruhjeZkcGLnjzZFhKBkWZZ16zSmiUjC3P2w xDcQlihPrU7rebxvk4gkLligXHjkFNxRklkW55198UxCr4HbDe+tTKbnjbiOkkvqRmp9 0XrDyaOQHqzI6huxDwPj4EoJWT5GNdiQ7sq6VpIsTnMxZD8g23nwiNM9bhD8uuvpdMZt v1T2wdSyC9R7gIt91bXWAOtIS69jjHW2U4GsAZAuiZd5GxR2G98iMoWfRn8i2u6qsWjs kLuC0YmlOst/6m3CXfBAZsGgbfvdpxAscBEo0rr4T4E4ElqOd0AcyyGFcMc/TS58gaug Y+Pg== X-Gm-Message-State: AGi0PuZOGLs9ygcUfO5HZ8/twvBReYWMeSXOt5WujLaJDZaW8xU0v65z IWw9DZoxZcWdCt9SZgLzpPifHxh87B8wa8UCkrG1vA== X-Received: by 2002:ac2:46f9:: with SMTP id q25mr13077605lfo.149.1586849111586; Tue, 14 Apr 2020 00:25:11 -0700 (PDT) MIME-Version: 1.0 References: <245c792f0e580b3ca342ad61257f4c066ee0f84f.1586594833.git.rocking@linux.alibaba.com> In-Reply-To: <245c792f0e580b3ca342ad61257f4c066ee0f84f.1586594833.git.rocking@linux.alibaba.com> From: Vincent Guittot Date: Tue, 14 Apr 2020 09:25:00 +0200 Message-ID: Subject: Re: [PATCH] sched/fair: Simplify the code of should_we_balance() To: Peng Wang Cc: Ingo Molnar , Peter Zijlstra , uri.lelli@redhat.com, Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 11 Apr 2020 at 11:21, 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 With the small fix in the comment below Reviewed-by: Vincent Guittot > --- > 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? */ /* Are we the first CPU of this group ? */ > + return group_balance_cpu(sg) == env->dst_cpu; > } > > /* > -- > 2.9.5 >