Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2579012rdh; Mon, 30 Oct 2023 01:05:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwa1IBSbTFDfk35oCwmSZSD1nqHEjdO+OBvLzzvlApotFEbw9OruLahFgV6sFdjseqcCcZ X-Received: by 2002:a17:902:e2d5:b0:1cc:d05:eb61 with SMTP id l21-20020a170902e2d500b001cc0d05eb61mr7016540plc.23.1698653137941; Mon, 30 Oct 2023 01:05:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698653137; cv=none; d=google.com; s=arc-20160816; b=SPHSl3rNmH30HkA80ttRIgTDQ6ApQfDK9/5WF0j2J9IzAHngq+53ybzDrRhYXWHJVe GpY8KFVzK49jxXSb9nbznrMrr4x3UvAQbhvqOr7D+dKEt0hzlEqdKFCiv9oKwgTUyNCD Mp3nYLdJj1rG4eiwbQ+NKav7VLL97bvgeu4s4gS+XLe5YN9wzvMZiy1icKKshod5kLkD 3Bp5HgUFG5Gk3qnRl9IHCskS696pqS4o9PIihUqYyTmVMVVyb/eEpiOhQ/4hVZzMwgmx fsbtoHHmsvJBwADqEA80+hxb8l0V7RgW0nk/+T2S09K1oZp+i+dXSjqroBY+BYS4Tzv0 rOMw== 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=srma/SglYHbbGTJhMGvbCnTLsrQERoNryEVxhNzJCgU=; fh=mOWmXJvMtubaqS17Dd8kFHMYLkoNbx8h2TdXpVX94jk=; b=uijP+CV8GI/UjlE3j9fkmAAA4vvYLib8UtCtMZFN6PXxYIW7gPa9AbEYwR2RKl7yl3 DEVE5J9C3+aN47DjxaXeC2s3hi2ndDgm31aI4yOvZI4wm8bfiWu4zpYqijhi6iG1YZdD yU8KRNVk3ySTvhj0PKdIyr96ena0nV7PMPqPNqAHz/Odhvox+8nxVvbVNGEP/vSBtl1B 2wWRCQhk6YDbB7Ii+q6vEu4mqKxaetPdSlz01vlGa0TODG9DL3/jcvpOrBZ2HcsUUg/m elwqpDxThCQiAeRHofxPpr08/5ZXU7qReN+eRqiALlrcWzstOYV9RU7bTEQeaDQ74o5y Vq0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gaScPf+F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id f20-20020a170902f39400b001b9c992945fsi4578906ple.555.2023.10.30.01.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 01:05:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gaScPf+F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id DAAAA80A5F8C; Mon, 30 Oct 2023 01:05:36 -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 S231995AbjJ3IF1 (ORCPT + 99 others); Mon, 30 Oct 2023 04:05:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231963AbjJ3IF0 (ORCPT ); Mon, 30 Oct 2023 04:05:26 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41F8FB7 for ; Mon, 30 Oct 2023 01:05:20 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6bb4abb8100so3674372b3a.2 for ; Mon, 30 Oct 2023 01:05:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698653120; x=1699257920; 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=srma/SglYHbbGTJhMGvbCnTLsrQERoNryEVxhNzJCgU=; b=gaScPf+FKVUJT//BGycFN5lurXyKB6u7VEFpRKD6fv+jEMRYXSfG5n3QalrYsebKlg pVCmjBEji1l7wPf8qVQaP7v/2/Rbk69BQyMkpoAYNAoOeUlCS2QsHogyzaKmav7q2kS2 134Y9bkx10YIbP9P6WUs06pH/CH2NaUewQSveuKogleROW5devg25ytd01jhTy3BYUx1 2KyYglGYD+2sN4NbFDIIJuaatAVpNvBhH7zdGAEgbTVH/E/BVd346ITGjWxIwee9hch/ ockvdF1vogkY8ByvXQVe5xVLhj2iIXCKUbE+TfU0roP9olLFYLBUMuNF33yRe/o9FQ1g xVow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698653120; x=1699257920; 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=srma/SglYHbbGTJhMGvbCnTLsrQERoNryEVxhNzJCgU=; b=tW4usPMaX3I7WfMMCDlSbnU9F7EUHrXiX3AlsCIUPoyKTCMRCRigopXNEvzHX89FX4 TZEsfYTK2OFgDCJ5wnRsn4RxtoPSOWFtff6PIqgSmaoamBdJlgPtS7BwEcmk6NFOFwDW pAP1HF2WhyvrQ4CxNwbZyYoe5jBm7uW/OEYlL099mDuaCAjNd++LpQAnbU7XKQdc1W8g XBApoROlms2KJ/uM/8EK+MnnWxmf6QbA63ZHpH7Sf+W+CANKuOdnH+Qe/z08rgmOFMrF BjESStJbn66JHbfzBAdRZXqrcBYthFmDFFsf+4FH5hAnUoCLqN5MUq0oEujNwg7lYaBA /k1w== X-Gm-Message-State: AOJu0Yy3H9lWetSm1Xpl+tr5nvCZIxqpmlpQ76LreSnpdLKj3tjrqk0e 8HGSOMW8ot+Te7ZbLfr0o8vDwm0SdpiLez5O4x448cKK8yuUmrG2 X-Received: by 2002:a05:6a00:93aa:b0:6be:bf7:fda5 with SMTP id ka42-20020a056a0093aa00b006be0bf7fda5mr7891513pfb.12.1698653119271; Mon, 30 Oct 2023 01:05:19 -0700 (PDT) MIME-Version: 1.0 References: <20231027171742.1426070-1-keisuke.nishimura@inria.fr> <27d88cac-95d2-4861-b79c-410e3cfd96a9@linux.vnet.ibm.com> In-Reply-To: <27d88cac-95d2-4861-b79c-410e3cfd96a9@linux.vnet.ibm.com> From: Vincent Guittot Date: Mon, 30 Oct 2023 09:05:08 +0100 Message-ID: Subject: Re: [PATCH] sched/fair: Fix the decision for load balance To: Shrikanth Hegde Cc: Keisuke Nishimura , linux-kernel@vger.kernel.org, Dietmar Eggemann , Mel Gorman , Valentin Schneider , Julia Lawall , Ingo Molnar , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" 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_NONE, SPF_HELO_NONE,SPF_PASS 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]); Mon, 30 Oct 2023 01:05:37 -0700 (PDT) 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 > > > - 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 */ > > > + 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