Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp250934rdb; Tue, 31 Oct 2023 06:40:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+ltlMNbA4y+tJz4f/VgXle8Wrd+JAijJ2ravdktK8z4Iq3huCchE9MF9UYC26ZrqHIXq8 X-Received: by 2002:a17:903:11c3:b0:1cc:f41:8f82 with SMTP id q3-20020a17090311c300b001cc0f418f82mr3567260plh.16.1698759616207; Tue, 31 Oct 2023 06:40:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698759616; cv=none; d=google.com; s=arc-20160816; b=l1JiwJftclDEvfvxBAR1N9d33p1UkSVbcyN46PUdeUjLIwKsYADyZOejnbs9cmLnJL Qw2XMjmcRlFseqHr508tYjW1g14NnkqsSCi7NwEeR6J5okE0SJvry3zA8/ReIQ+UJLoD qwTE6fW9e7JjcZAzl/B96rygzEAT56qmTk4Atp2Qcj6ENbZ75zb2DdmY6QLotV70Uysi BIOXFvL3YVxBHtObZZtB/5rcdHfe52RF5kcbkrs6dc2sS50pSPCrvnF//9FkoISXlaIM 0tXFNtMdiaU9hx2D30jn8jk/NqLCVxdrSC1hY2cdHNlME3cct3kPTwR48Hhx6Ng8Z3+G bBBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=+R/StZ0rnd3KPlOJD7FBs4MnY5uMyxTojGwy+D7cBfE=; fh=6c6VpafDMPFb5WG82nMt8q8XnarrX56tzLx/arToBfI=; b=MNcKzFGV026L46epFsAWHy2IUXLUMSF6ClqX/dhbrvLMxVoWuNh/5EkIFPciyYQHxo GJWNAvZFn80l/ikBl0CAggY4tmEp1wTCoyxAtfm8FRBpzqOKXktRAT48SAlxlblDrdE4 7P51vYQDunGphnSZ6ue3W43AbtPb5LV0ktg16/C5ONkA9H+vm0I0cDi7bhBqo4UcZqKa jM7tz1W4JZ5dXsJnWv8GiNNcB39R+t8OVLJOpXlNObfizd8lM2BsJeU6As8O6Q/OZa9Q wg6Ti7r/ZuHAsR1PYTWuEoaAYBUKB91bJy8geXdLxp8WagZgQatUWdBqxAvC/vXNWoPr EjDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=dxs7i03D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id a14-20020a170902ecce00b001c3fa95ca18si1087580plh.333.2023.10.31.06.40.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 06:40:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=dxs7i03D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id CBD3F8083AC4; Tue, 31 Oct 2023 06:40:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344622AbjJaNj7 (ORCPT + 99 others); Tue, 31 Oct 2023 09:39:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344599AbjJaNj6 (ORCPT ); Tue, 31 Oct 2023 09:39:58 -0400 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D45EB9F for ; Tue, 31 Oct 2023 06:39:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=+R/StZ0rnd3KPlOJD7FBs4MnY5uMyxTojGwy+D7cBfE=; b=dxs7i03DmLPGojj/9w98djg9obg0R40MvthZamq0P5raUwyVO57WH+6U 17INflnLwHjfbd9T71diB3EpXtd5f7mYbfGzQXqDKekM0KkpBbOJfUeyb RspWzT5u8TpqsPMO8XTgrDUW+FLh0Gn0s+FJnhut8FfOmnhdAQ1kdG5zM k=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=keisuke.nishimura@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.03,265,1694728800"; d="scan'208";a="70220528" Received: from dt-aponte.paris.inria.fr (HELO keisuke-XPS-13-7390.paris.inria.fr) ([128.93.67.66]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2023 14:39:53 +0100 From: Keisuke Nishimura To: Ingo Molnar , Peter Zijlstra , Vincent Guittot Cc: linux-kernel@vger.kernel.org, Chen Yu , Shrikanth Hegde , Dietmar Eggemann , Mel Gorman , Valentin Schneider , Julia Lawall , Keisuke Nishimura Subject: [PATCH v3] sched/fair: Fix the decision for load balance Date: Tue, 31 Oct 2023 14:38:22 +0100 Message-Id: <20231031133821.1570861-1-keisuke.nishimura@inria.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Tue, 31 Oct 2023 06:40:06 -0700 (PDT) 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 Reviewed-by: Chen Yu Reviewed-by: Shrikanth Hegde Reviewed-by: Vincent Guittot --- kernel/sched/fair.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 2048138ce54b..921f4f65adef 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -11079,12 +11079,16 @@ static int should_we_balance(struct lb_env *env) continue; } - /* Are we the first idle CPU? */ + /* + * Are we the first idle core in a non-SMT domain or higher, + * or the first idle CPU in a SMT domain? + */ return cpu == env->dst_cpu; } - if (idle_smt == env->dst_cpu) - return true; + /* Are we the first idle CPU with busy siblings? */ + 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