From nobody Tue Dec 30 14:57:39 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9350FC4167B for ; Tue, 14 Nov 2023 21:57:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234123AbjKNV5U (ORCPT ); Tue, 14 Nov 2023 16:57:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233991AbjKNV5R (ORCPT ); Tue, 14 Nov 2023 16:57:17 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36281D8; Tue, 14 Nov 2023 13:57:14 -0800 (PST) Date: Tue, 14 Nov 2023 21:57:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1699999032; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0qSSd9FGW8BlweZLwt59poRN99tZZYZnkIbBfiqtXHI=; b=EXz8nN4lwTCkPnTLjh0eUYjFGxBPOb5vvCYrTTN4d4JOMPxd84xvwjv7Lx87NdDQnqifq+ B3dQ6byB2uatTb4N6o41GJ+iWE4H7ZRT/D3JpEUGdXNT+6zuMUiyxwHgydiF0cbjuCbraY 4eoDyE7ntt4Mr3uBNjyns4X8v0OdmTbbxObusibDQvMgJMNYH4qYOmOyZkugk3Vy/R9rGj BYNznUCPckAdgjA+wGwGdSL++QJxWoV6QkLVr6gtgnIUUI4CXwv9PMkccX4sJ9Atu3lFJB kmWCdWXcfmyaKT1nvuYy7XQOyPtgZrBhDs/P+Og7q9FZWXJhUnxQ7o8t3zw97A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1699999032; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0qSSd9FGW8BlweZLwt59poRN99tZZYZnkIbBfiqtXHI=; b=4RH8QeqL91d3kCvARfa1ThU///aQZwW+Mhf5qvbUtDu1LpBZkaGaTjH+g0dNddAO7ixVLI Dvde76QgF4tiiDBw== From: "tip-bot2 for Keisuke Nishimura" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched/fair: Fix the decision for load balance Cc: Keisuke Nishimura , "Peter Zijlstra (Intel)" , Chen Yu , Shrikanth Hegde , Vincent Guittot , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231031133821.1570861-1-keisuke.nishimura@inria.fr> References: <20231031133821.1570861-1-keisuke.nishimura@inria.fr> MIME-Version: 1.0 Message-ID: <169999903219.391.2460827173392775023.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/urgent branch of tip: Commit-ID: 6d7e4782bcf549221b4ccfffec2cf4d1a473f1a3 Gitweb: https://git.kernel.org/tip/6d7e4782bcf549221b4ccfffec2cf4d1a= 473f1a3 Author: Keisuke Nishimura AuthorDate: Tue, 31 Oct 2023 14:38:22 +01:00 Committer: Peter Zijlstra CommitterDate: Tue, 14 Nov 2023 22:27:01 +01:00 sched/fair: Fix the decision for load balance 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 Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Chen Yu Reviewed-by: Shrikanth Hegde Reviewed-by: Vincent Guittot Link: https://lkml.kernel.org/r/20231031133821.1570861-1-keisuke.nishimura@= inria.fr --- 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 025d909..d7a3c63 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -11184,12 +11184,16 @@ static int should_we_balance(struct lb_env *env) continue; } =20 - /* 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 =3D=3D env->dst_cpu; } =20 - if (idle_smt =3D=3D env->dst_cpu) - return true; + /* Are we the first idle CPU with busy siblings? */ + if (idle_smt !=3D -1) + return idle_smt =3D=3D env->dst_cpu; =20 /* Are we the first CPU of this group ? */ return group_balance_cpu(sg) =3D=3D env->dst_cpu;