Received: by 2002:a05:6a10:144:0:0:0:0 with SMTP id 4csp73766pxw; Fri, 8 Apr 2022 01:10:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQBgWmQcH3HHkmQh6fcO2/7TNdZAkkcVih5CTe35gcHLxyJz+5IXG5nQB73z/JEfDxVPrZ X-Received: by 2002:a17:90b:4a84:b0:1cb:29bd:db3e with SMTP id lp4-20020a17090b4a8400b001cb29bddb3emr5653109pjb.112.1649405413129; Fri, 08 Apr 2022 01:10:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649405413; cv=none; d=google.com; s=arc-20160816; b=B0Vomrd6TFEIgSz7eLuuFB1GTySwFrzkj8vlTiPWTxJBrRsWwFzklU0YdWe6MyhzdZ Jy3frFCZ2hwtCPlnj8DfbJ90fRX15GDVv7Wuk25b8JnmDxThZfhb5vQuPs/HESYq4h4q 3wD88CBWCQshFUxf82OFFoRm7IMPFRAnYuILBqGonh4IkV5QjNYBtzAtCbJcSZ+Qhogm Xdm+5tAVaBPJD4fcPiHDFN6o4KA2ukcDurRx/vtLpFVPKZO7g3dxQPd+cPBZQc1gqrSx obQ32OBzRZf1MnihngoRCxTzj0hMvzILr87xSKLRJl4H4t/NUSOdxK1bkVZ9KDpOfXft t8Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=gyVHJgcaGws8+cVL82BQrcMAUaEUFmtsrDoHZpP9Ojk=; b=QhSZelEYXir0STcMFeRfAaPKfRjqcdBiO57k4MrT7dVieAZ2bwQ+cbcMx+pEw8SkPo FS3d8EDMksBnYBAdZ6gs4/h4fTlNRzqhFRydvP34BUHgyTZSx8zGtPkXk9KSB5a7lUZa +CRyf9DMh90nsN73kP0GoEldL9qqkkfT0OFt/l+bLLAR9e6fa3QpOeXRUYKj/nQdqDNs PoeDq8cBzcMR0PeBQh4jMHBGyvM/W0ZaVpEruVzpK1nADdeOqfkwPqkZ4tHZB5eCZsq3 BIYZZ4HexbrA9Pa5hzQET+WWMeMW56B+VVzvuFpRZN2DzHl1QdN48Uwhk3nPfAA3EcYP bN2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dhqIlFXZ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d17-20020a170903231100b00153b2d1642bsi298876plh.51.2022.04.08.01.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 01:10:13 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dhqIlFXZ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 21EA71B8FE3; Fri, 8 Apr 2022 00:42:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229803AbiDHHll (ORCPT + 99 others); Fri, 8 Apr 2022 03:41:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229765AbiDHHlj (ORCPT ); Fri, 8 Apr 2022 03:41:39 -0400 Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BFF11A9C84 for ; Fri, 8 Apr 2022 00:39:37 -0700 (PDT) Received: by mail-yb1-xb2a.google.com with SMTP id g9so13646719ybj.9 for ; Fri, 08 Apr 2022 00:39:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=gyVHJgcaGws8+cVL82BQrcMAUaEUFmtsrDoHZpP9Ojk=; b=dhqIlFXZce/V/NaNITP2d+qKkbo2bzcVsQfMKCMYYpq6X0Ss6UNioUmKIs4EWlXsdF /y8O2WvCnG0M7Lv3HejtYw4QE0Nt46xqTeGHQ+VrjQzz/mkhWsIMmBCzkp3VRy7eJbuE 0tKvdhjW6ZHfUZbEo92RH/hwdD6H84zpeYfiekNpoDIeVZoF+1HFqjUA0r4J287liiBY pK3Is4XMhTsXGYvdF7pcfZa4tHu7H0ed1uytjEVhO8teN9u2vLo35BkmoKiIJSFcfQPy BSb6BlyIiS/1XPN+rVtryBX8FyFVswHCXR2M3CmJJN50MZidBWgimCCM8gX5NOHpStlH 6bOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=gyVHJgcaGws8+cVL82BQrcMAUaEUFmtsrDoHZpP9Ojk=; b=L3luDchvn/SnrlFK3mOoLAXDMklGFcwi0h1KABqeldnrPklf5JXKlCQNa4dpMWYqK4 SG2dwiYV+jePBE2q0xxqKX9N9WDVurh0Z87M8E7Vd0M0jedvGc0ak5C63djfkjKwxxeJ onB1qzPXhNJTWjDa7edEAYbmV2L/UwQYq/4opCIGRBEZP+fLx1ev15EqAn16VDzFW0kF zirMZ4dzu+ygiJE1dSe0+eoCB68ex9ZSnOLlRwByxHJ8IFwQpjSyy3Cr8yJPHGQ2RbjU ff+1o47ZjFEibH+g9DOGP9fPQDF6TIJw/P4jbBIV0Kj1kxZglkqRpItaMleTrDrHHvlU 9GPw== X-Gm-Message-State: AOAM530mqzvrFuuIAOsvmrYzKDrh0Tlpqcp4olNOxJc1RSMdFB9xdYaR vJfmljBoz5rFG9xfMiSxLchuT+kuP3CPzqDRqoG5lg== X-Received: by 2002:a25:c5d2:0:b0:636:e78a:866d with SMTP id v201-20020a25c5d2000000b00636e78a866dmr13760235ybe.225.1649403576296; Fri, 08 Apr 2022 00:39:36 -0700 (PDT) MIME-Version: 1.0 References: <1649245580-27256-1-git-send-email-zgpeng@tencent.com> In-Reply-To: From: Vincent Guittot Date: Fri, 8 Apr 2022 09:39:25 +0200 Message-ID: Subject: Re: [PATCH] sched/fair: Simplify the scene where both local and busiest are group_fully_busy To: =?UTF-8?B?5b2t5b+X5Yia?= Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, Dietmar Eggemann , rostedt@goodmis.org, Benjamin Segall , mgorman@suse.de, bristot@redhat.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no 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 On Thu, 7 Apr 2022 at 04:38, =E5=BD=AD=E5=BF=97=E5=88=9A wrote: > > When the type of the local group is group_has_spare, it does not affect i= t, and it also has the opportunity > > to pull the process to the local cpu. > My point is : local group is group_fully_busy busiest group is group_fully_busy but local cpu is idle or newly idle otherwise we would have already returned Currently, calculate_imbalance returns imbalance=3D0 because it is based on avg_load which is not set for busiest group. Instead of skipping calculate_imbalance, we might compute an imbalance similarly to what is done for spare_capacity because local cpu being idle is an opportunity to run something else > > > This patch deals with scenarios where both the local group and the busies= t group type are group_fully_busy. > > In this scenario, because the avg_load of the group of type group_fully_b= usy is not calculated, this value is 0. > > Therefore, the condition of local->avg_load >=3D busiest->avg_load in cal= culate_imbalance is satisfied, so the > > imbalance will be set to 0; Therefore, in this scenario, the original log= ic has no chance to pull the process to > > the local cpu for execution. I think it can be judged at the upper level= , and there is no need to go into > > calculate_imbalance to do some useless work. > > > Vincent Guittot =E4=BA=8E2022=E5=B9=B44=E6= =9C=886=E6=97=A5=E5=91=A8=E4=B8=89 23:41=E5=86=99=E9=81=93=EF=BC=9A >> >> On Wed, 6 Apr 2022 at 13:46, zgpeng wrote: >> > >> > When both local and busiest group are group_fully_busy type, because >> > the avg_load of the group of type group_fully_busy is not calculated, = the >> > avg_load value is equal to 0. In this case, load balancing will not ac= tually >> > done, because after a series of calculations in the calculate_imbalanc= e, it >> > will be considered that load balance is not required. Therefore,it is = not >> > necessary to enter calculate_imbalance to do some useless work. >> > >> > Signed-off-by: zgpeng >> > Reviewed-by: Samuel Liao >> > --- >> > kernel/sched/fair.c | 12 ++++++++++++ >> > 1 file changed, 12 insertions(+) >> > >> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> > index 9f75303..cc1d6c4 100644 >> > --- a/kernel/sched/fair.c >> > +++ b/kernel/sched/fair.c >> > @@ -9634,6 +9634,18 @@ static struct sched_group *find_busiest_group(s= truct lb_env *env) >> > * busiest doesn't have any tasks waiting to r= un >> > */ >> > goto out_balanced; >> > + >> >> We are there because both local and busiest are not overloaded, local >> is idle or newly_idle and there might be an opportunity to pull a >> waiting task on local to use this local cpu. I wonder if we should not >> cover this opportunity in calculate_imbalance instead of skipping it >> >> > + if (local->group_type =3D=3D group_fully_busy) >> > + /* >> > + * If local group is group_fully_busy, the cod= e goes here, >> > + * the type of busiest group must also be grou= p_fully_busy. >> > + * Because the avg_load of the group_fully_bus= y type is not >> > + * calculated at present, it is actually equal= to 0. In this >> > + * scenario, load balance is not performed. th= erefore, it can >> > + * be returned directly here, and there is no = need to do some >> > + * useless work in calculate_imbalance. >> > + */ >> > + goto out_balanced; >> > } >> > >> > force_balance: >> > -- >> > 2.9.5 >> >