Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2577926rdh; Mon, 30 Oct 2023 01:03:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHd4ecOsiscl97bPthlmuzKs6SVOYaEjOEg3+HiJ7lnwM55Atm8Ol31jL/3JyLaJhs+YT3d X-Received: by 2002:a05:6a21:7906:b0:17b:1ab9:5790 with SMTP id bg6-20020a056a21790600b0017b1ab95790mr6292963pzc.50.1698652994819; Mon, 30 Oct 2023 01:03:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698652994; cv=none; d=google.com; s=arc-20160816; b=RroN9bpjInfRVht3lu0N9QijGyKchWnTW/6QWFawYp08Pz53ladcKSp15mjEE9SuEO ucFhisT/0X5Q+vRW1bAVjclGF+GgpTUQeArkusq/eb9h+q7nSYCezDSAeak0l/iMvRms FMKm0hlB/CvfztZ9iw/YgODUUJ6ND9i2vNPfYR27z23CgmC4oLqtydXULCRIAKIGGePI GX/C9TMEkTwXIWFiAR7xzQbCCDUs2pp26MyIQSYLXL8lDsCNY0BO6xSzisXilrfUzYBc ycg1ZvfzRXUj11xHJ1K2l5XYuAI4rxIPNWztkEq6kxTYibU28HwQ6vPK+2aVi5OgLrLj hq0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=OBLQaO2WMbtm/heOlZQXC4I4OJH/epBfW9GD5VTLDEE=; fh=yXU9b2vxG4kt5j0xtj5QnI0dwDqasGjqABapTuAEZdU=; b=FllJRvXrJ2gYyPs5bA7TbDAu2FVke8/nhqhZa8sKq4w9UZO5DAIYrOJ9juGZJG71n7 kIuJ44fF6+x9XI87aSueYrfPqDbpJs+ytQGVU6CxEBwVQ8952FyxFcpEqvEXdYtQJ6OS D14BMCa1EQnEzf56B6QWpW7+DftlnCB8RxLnX39a8Ay+k4rodgbMAY38TU1tA+llnX+A cRx/oVCuQtd7uBVj0tST5NtxARkDaF+o9qTl2+VJk2Wq3H0pVbVg1HMECWXiwgzdGfmJ ao98Gm680fCS4gZt2ySrmRU0xA29v5er/oyu73FnAc45OIBgBmF1PP70etvMp1ZgtGX1 bOxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S27nNnTm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id o4-20020a656a44000000b00577960a815csi4753428pgu.188.2023.10.30.01.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 01:03:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S27nNnTm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 32E7E8098482; Mon, 30 Oct 2023 01:03:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231963AbjJ3ICz (ORCPT + 99 others); Mon, 30 Oct 2023 04:02:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231741AbjJ3ICy (ORCPT ); Mon, 30 Oct 2023 04:02:54 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C2E8A2 for ; Mon, 30 Oct 2023 01:02:52 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-3580b94ac2eso14864495ab.0 for ; Mon, 30 Oct 2023 01:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698652971; x=1699257771; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=OBLQaO2WMbtm/heOlZQXC4I4OJH/epBfW9GD5VTLDEE=; b=S27nNnTm7ETgdvw9/GPHaTggpPaXW8SVsKkU2Gjzd7p0UJjnLW0fOo1tTV4tMkQF6A UUPZBLLQg7GoTIKgR4QmZNivFivq7G09wj2pdIp6J/btuFgwJi+oC8Vn3V0v3JEy/9Mn uFVEu/ouUbmjiHB4unKCQIqr8KlhHxxFQMPHMC5LPxlFIK5GiY2jG9LwwqxhAvzHqTCC A6LprgW3UcKl3ehGM98dELNc2u5npZ+hjbcC+4dzv8IDPYBEXkGXQ1i+R4jodd+OPCGF FyoMMMwMOBcP15RyhoHWVL74tBWwfPwf8y/4zGeoYDhxwpgbneFRtLRANLFAV1Jm3TWP qD2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698652971; x=1699257771; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OBLQaO2WMbtm/heOlZQXC4I4OJH/epBfW9GD5VTLDEE=; b=CKioWv7rs1jotrq4VzxhkxuxWuxGX+4Y529m9fWmCFBT/a674jRFTwGwW17Pji4WMa eqDzv6fg+ctrnSczXcplw0dynwD2ZCfjJVRf9M/4BnRXr7pmoF9SDtnVuLG3ja1i2weh Y69qYY/Ax2/MUaiUVnv0O0R4mZF9ZSDIs/ayqVcpb3u1i04nQS35KgWbs+OWISxxDkvZ 5ZFNXOZ2lNF/SvlU/SyBeJCDn+duWrTL+nDtrX4vs6Jmrqxsgz7fN1IZfX/ysjf0i8BX vpuMlJ5l36L1exc5g7wNLN/jgijRRiNbByonkaTbgIASYqLEEIAvG//7SuqS+DehGtyH J+Rg== X-Gm-Message-State: AOJu0YxxqvdPCFI3hjs2NfDswGwqleBWPWuMtefUMs0e8k6facSvIEdj X4HL5gOARF8v9cHwU4z0c7EfrDxdF05XO/3/KcRAoQ== X-Received: by 2002:a05:6e02:156a:b0:357:9f55:ec41 with SMTP id k10-20020a056e02156a00b003579f55ec41mr12409466ilu.31.1698652971658; Mon, 30 Oct 2023 01:02:51 -0700 (PDT) MIME-Version: 1.0 References: <20231027171742.1426070-1-keisuke.nishimura@inria.fr> In-Reply-To: <20231027171742.1426070-1-keisuke.nishimura@inria.fr> From: Vincent Guittot Date: Mon, 30 Oct 2023 09:02:40 +0100 Message-ID: Subject: Re: [PATCH] sched/fair: Fix the decision for load balance To: Keisuke Nishimura Cc: Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org, Dietmar Eggemann , Mel Gorman , Valentin Schneider , Julia Lawall Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 30 Oct 2023 01:03:12 -0700 (PDT) On Fri, 27 Oct 2023 at 19:25, Keisuke Nishimura wrote: > > should_we_balance is called for the decision to do load-balancing. > When sched ticks invoke this function, only one CPU should return > true. However, in the current code, two CPUs can return true. The > following situation, where b means busy and i means idle, is an > example because CPU 0 and CPU 2 return true. > > [0, 1] [2, 3] > b b i b > > This fix checks if there exists an idle CPU with busy sibling(s) > after looking for a CPU on an idle core. If some idle CPUs with busy > siblings are found, just the first one should do load-balancing. > > Fixes: b1bfeab9b002 ("sched/fair: Consider the idle state of the whole core for load balance") > Signed-off-by: Keisuke Nishimura > --- > kernel/sched/fair.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 2048138ce54b..eff0316d6c7d 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -11083,8 +11083,9 @@ static int should_we_balance(struct lb_env *env) > return cpu == env->dst_cpu; > } > > - if (idle_smt == env->dst_cpu) > - return true; > + /* Is there an idle CPU with busy siblings? */ Nit. I agree with Shrikanth that we should keep using similar comment : /* Are we the first idle CPU with busy siblings */ Reviewed-by: Vincent Guittot > + if (idle_smt != -1) > + return idle_smt == env->dst_cpu; > > /* Are we the first CPU of this group ? */ > return group_balance_cpu(sg) == env->dst_cpu; > -- > 2.34.1 >