Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2634294rdh; Mon, 30 Oct 2023 03:16:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHET1xr5SlNRzfgyqYHqBUY6wl6x6BXIzAlFgwaw6NSonwk79JdBP+6droHo5bdSEPSmLIo X-Received: by 2002:a17:90a:1602:b0:27f:fe16:247a with SMTP id n2-20020a17090a160200b0027ffe16247amr8887592pja.17.1698660994734; Mon, 30 Oct 2023 03:16:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698660994; cv=none; d=google.com; s=arc-20160816; b=i8H2aYKFyvN2kuaggdMeRilB6aM/taypKNkwrgUXtUAK9v3PGfCfetO/QOtB90NOo6 ATemIGCAnpUMETHNq+2kXPAihDlPYMHRHRwpmAoMNoZLoHRuOeA95XnkQc1wk1i3DTxv uBH8coT79zhdDWMIatTAocrYDGpaFEGZ2amqv0OPu+UpufS5KGJLqJGJSsNXxZO/BE4d pG8J3iLVO+N49yCB0JRnE5spSCCIYj0fMYfAr53npTAa4ADAYVk4S9W9bo7giQ2ZkRhR mU0guHZw2GFadBL6vALYZRBj+O0eXoPrhf/WdCVWdt+1rgijb8WLERDYX3S/L8GpEqeD 6WSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=4ODO51XdUw0hVUvsJtE3A7b0/mN0G8++f9rKwPpZbZQ=; fh=srqTojkObBfYre0gOz5Yu9dau+vOnIiB06rAwml5qEI=; b=SnBhPGgfxkmmNXDTYYWlbdUogsq7x8v6DROzflhUbqWQZ2P1lgwVmUCoMv6x5lVk9T 4JQD2Pk38kf4eYAf6OLtkNldcKe6c+sMeuguaYQuXyANETMElaft2JatFmTXVOWOH2cV qndIGkm8/kywXQ0tC7vGD/CzadINKHZNrppvjJVTDjgAzLjXHN2hFvegl3nNCqAPR1Ot mfCO3mfkrlE719ha+nVtu9XzEelNCnmNG10Z1ObCaT3Bo6rIWktGdXDUjUkZavVIK76k 05hViGDqnziVb6yqJZMzUJYiOCr2m+L/cQYIOaZZB1G5vbp45mf5y0xQ3c/624DxpNzz oO6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=kOjRrNbg; 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 w3-20020a17090aad4300b0027652755c21si4079617pjv.142.2023.10.30.03.16.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 03:16:34 -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=kOjRrNbg; 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 6110A804C20E; Mon, 30 Oct 2023 03:16:31 -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 S232641AbjJ3KPe (ORCPT + 99 others); Mon, 30 Oct 2023 06:15:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232606AbjJ3KPI (ORCPT ); Mon, 30 Oct 2023 06:15:08 -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 4E89E387A for ; Mon, 30 Oct 2023 03:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=4ODO51XdUw0hVUvsJtE3A7b0/mN0G8++f9rKwPpZbZQ=; b=kOjRrNbg3qNLOQNMT0nFZUIA24WxoS646GsoXsb4WiyNdYX1BzRHk3/F ST8F4+pskz2zmNlXjYM5gPxsWR4y9dZtphsMyQUtgqFUTnM5z0cgflm78 J2VSXNtAEwgQ7yPDkXmVL1qTltxxWFqWvTCfrTXT0RCA+HQ8enFsV+c0p 8=; 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,263,1694728800"; d="scan'208";a="70099723" Received: from dt-aponte.paris.inria.fr (HELO [128.93.67.66]) ([128.93.67.66]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2023 11:02:15 +0100 Message-ID: Date: Mon, 30 Oct 2023 11:02:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] sched/fair: Fix the decision for load balance Content-Language: en-US To: Vincent Guittot , Shrikanth Hegde Cc: linux-kernel@vger.kernel.org, Dietmar Eggemann , Mel Gorman , Valentin Schneider , Julia Lawall , Ingo Molnar , Peter Zijlstra References: <20231027171742.1426070-1-keisuke.nishimura@inria.fr> <27d88cac-95d2-4861-b79c-410e3cfd96a9@linux.vnet.ibm.com> From: Keisuke Nishimura In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 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]); Mon, 30 Oct 2023 03:16:31 -0700 (PDT) On 30/10/2023 09:05, Vincent Guittot wrote: > On Mon, 30 Oct 2023 at 05:03, Shrikanth Hegde > wrote: >> >> >> >> On 10/27/23 10:47 PM, 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; >>> } >>> >> >> >> There is comment above this /* Are we the first idle CPU? */ >> Maybe update that comment as /* Are we the first idle core */ > > I was about to say the same but it's not always true. If we are at SMT > level, we look for an idle CPU in the core > Maybe I should update the comment with the additional contexts: /* * Are we the first idle core in a sched_domain not-sharing capacity, * or the first idle CPU in a sched_domain sharing capacity? */ >> >>> - if (idle_smt == env->dst_cpu) >>> - return true; >>> + /* Is there an idle CPU with busy siblings? */ >> nit: We can keep the comment style fixed in this function. >> /* Are we the first idle CPU with busy siblings */ >> OK, agreed. Should I create version 2? thanks, Keisuke >>> + 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; >> >> code changes LGTM >> Reviewed-by: Shrikanth Hegde