Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1318029rdh; Fri, 27 Oct 2023 10:27:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSLicbDPX5qJMh8rPuZY0KirKAtw27vI69XwXFYSr3HAu3XBzhA7yVkAyCw7r409zM3DPd X-Received: by 2002:a54:4794:0:b0:3b2:e761:fadd with SMTP id o20-20020a544794000000b003b2e761faddmr3210777oic.16.1698427622053; Fri, 27 Oct 2023 10:27:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698427622; cv=none; d=google.com; s=arc-20160816; b=pYEr9IEQHTtY7Ni2oOitFZA4pCiNkMsK92Twm9c1ztCfyh6rrx0G3fUgpIGKpTg8lv CF2wfyqPy/Ofn/ytdXvaEsLTHx6yB0Q+PjEsmgC/aB2FFVqLOyjof+NK6SSkcptA2feu /jkoPWv7pRB/8b/UtCL6HF3EOYERa9LA4+5TCrBihz5t5XCFuEiW8E1TFHYGi+tcmUaO p3rLYEKxC1Vrqr5OPYN8A9zSUQaas/t37eBYOXLFWZu3zQqBVJcSEM7WS3YO1ory1y29 qA/LLknwj1G2t5uhI2FulOmMHhmvzIC3Vkwlx+5Fy66ZuEi8Sg9yMFO6pJGGPgx+yeFi wMIQ== 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=h9F9MGQEWuO7FbcDirGpZveGbR00hMm8fS3YRyaKU7Q=; fh=AHtA0gNmgsgV/Lq7O8tJpacpfewa0eoIGo8ZHKFk3Xw=; b=cggZxHJSp9CTDy/qJEsrNgKJ41cCOSdbvwUTRNuVwW5zuQKcdKAY3pncgzpOupiPte GORJzZKscRXsffbfuqCVmObB3edkixu1biFnYsWI8T6Rbji/4/pin7xIv4LKEBB/J/yv E0kOdy16ElAL4ILwM9OzX/q9Z5VhEElgivAIwrRddggOZ5nNViJG9HYyVGpxS1LJtQpu D4Sa7FAe7sKHYgLDfbkCdekumYz1ZTm9HX2EQupTRG876aGqQn91SSAgP62g/ZANlChM GKFPyXWVwudHCKt5UmY3+0CzT+xmIB6wKImB/ePYLCwu0PAO4mTYL5drDKS+R+f59M7g xpTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=jzIIkwui; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id a68-20020a25ca47000000b00d9accbb84bbsi3603831ybg.469.2023.10.27.10.27.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 10:27:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=jzIIkwui; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id E285480793E8; Fri, 27 Oct 2023 10:25:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232483AbjJ0RZo (ORCPT + 99 others); Fri, 27 Oct 2023 13:25:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232381AbjJ0RZm (ORCPT ); Fri, 27 Oct 2023 13:25:42 -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 05309CC for ; Fri, 27 Oct 2023 10:25:39 -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=h9F9MGQEWuO7FbcDirGpZveGbR00hMm8fS3YRyaKU7Q=; b=jzIIkwuiXIENTVPNiKWjpFny6CwewVRxqTiOvzQxpAqDVglH7On4tLne 3ws+G/bmbYUWlsSAhsgw66AFzslIxj0G8sNLUF5/mtsdJnzReidQbmqGX N02Oa6TawMO10w3MFrrKAhpYjikfATqWYSQCn37XIsf+xazwUHljVgOBR Q=; 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,256,1694728800"; d="scan'208";a="69978968" 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; 27 Oct 2023 19:25:38 +0200 From: Keisuke Nishimura To: Ingo Molnar , Peter Zijlstra , Vincent Guittot Cc: linux-kernel@vger.kernel.org, Dietmar Eggemann , Mel Gorman , Valentin Schneider , Julia Lawall , Keisuke Nishimura Subject: [PATCH] sched/fair: Fix the decision for load balance Date: Fri, 27 Oct 2023 19:17:43 +0200 Message-Id: <20231027171742.1426070-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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Fri, 27 Oct 2023 10:25:53 -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 --- 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? */ + 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