Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5396249ybf; Wed, 4 Mar 2020 23:54:41 -0800 (PST) X-Google-Smtp-Source: ADFU+vsYcOcrEPi1TtcyH6yVlgdI2ot1MejENdNA+/WwVXb5d2wkJBtmnPBEwANkj/C1dXcj0Kl/ X-Received: by 2002:a05:6808:9a5:: with SMTP id e5mr4518870oig.168.1583394880935; Wed, 04 Mar 2020 23:54:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583394880; cv=none; d=google.com; s=arc-20160816; b=zKOwl1BDiWAvfxHSm6j8t2vzEAdCQWXmjv05tL2utmaLZO2aXz0f4jvB+bt3VHQWGe 7tgfHrHpF53kKX92pRmzKdjBvmRAD2ooZR911XfF7sbcm6DlvHd5s2HRZs3fF+KF74yV +ELfkMIJhHw+p9zSP5DI7ePi1rlo3rpYKaKkqiLCePjnSeDFJDsvR/fQIpttU9fJEW/8 rTNeBS2j6WxVL+puLVTqTQDRKEpbeVMcxEsOvFZuknetYsUm4JY3UjhZzsiK5shXbc+5 33Xyb10gfPuzA430e4iGXyJDhGiEYsMy2iFsvbcL3bygRhcXXhIizBKvPcF2+kfsgRxv tyQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=1Vo7v3A29qLhL95wUBh6dD5eErodqSEdH9NgC3IKBcE=; b=THvPcegswwUC3oiQY82BnzPMHyjlJYsB7IEdazYtfjd0zfvLnyICM7VeGhP0J5Me3B 10V5tCMl9WFSjJq9wrvJ1uUU5ZLDB5sJLLxoUbporDZW0X2cBqh1TgiPjL1moSCI3HQN NnqUdLXPAObY7QBUnHHIL32SVp0FcasjJbZc9srQlUWZnT5Nub4ifBRCo/3OcVpXTugt 1Y5jRqAkXAZiGFhxesWLMBr+66Jr8iuYGQDpRFHf0bsGbUbgTh0GMf2pPUvttJnBfd3Z LFMLv2OE5LJXBU2jDX26ItW1pPSsKlgSKwFzSOSSVJ6Lnu+H38pLdWVFkdiKtLk8VrJX yX/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=at3VFiob; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5si2822582oti.22.2020.03.04.23.54.28; Wed, 04 Mar 2020 23:54:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=at3VFiob; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725955AbgCEHyB (ORCPT + 99 others); Thu, 5 Mar 2020 02:54:01 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34147 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbgCEHyB (ORCPT ); Thu, 5 Mar 2020 02:54:01 -0500 Received: by mail-lj1-f196.google.com with SMTP id j19so2686470lji.1 for ; Wed, 04 Mar 2020 23:54:00 -0800 (PST) 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=1Vo7v3A29qLhL95wUBh6dD5eErodqSEdH9NgC3IKBcE=; b=at3VFiobWlcoKRKBqRBBR4dPdUy3MfwRIWfL32V4+Pk6F99EfdSqYf+kYqbcV2BvtU tIJvg/rCUgDZjkA2ILJi4FARJ3yGpcd3ZtHC6g7PAnxpGyujHbX/gSVrnbj+AGTR8ALc i8MxK21jFKMsK0ThiSwUeWimpHeqLC+AJKlxrq07rxnPvmS4yClqY+84bE4Q5nCavZKA MG8wDrOmXuBynBjcm1hhgM9w02ANxVUggNxgGj4PvkZ/608SORfPit9fVOhkMnMZg8r1 6zC/HbIfZv6843V1Vxs6jIvxfKIfyruOZSH8EA6h8ZlqMqzzDJZN9d8jLId9wLFcofHg QZ9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=1Vo7v3A29qLhL95wUBh6dD5eErodqSEdH9NgC3IKBcE=; b=ltZRxQn+t84ejo4d8ME+yVlNDqBDvt7qYdeqVMed3gpeDXB4ieYoafldpg2C5eWeGm /NClj5xCLjFMCM1Vr1DyGGmXV/5A3B8vXF6Jm9CeW3tc6gKURJPGjUi9q4iyDIbmxfzp PArn4+FF+b4DfnhG0Uh4SE/qspSxIj7tLtFWieBr8WNdqHWs3B3W6fQ7DZecZDasu86P TCa+22MkF5QN8J99TAq1VDyqv7T24koFoUWXZWOElvhYuWNDdG+SfFucLIQbvjCXbRCS BS/U5QoKBIIZ324xWJmtLTl1BjFZ+ar3D1C722thWdZKscH+cHZNo6UWEiVpOQq4INir 7Wyw== X-Gm-Message-State: ANhLgQ0YGunt5F7fbMqSOldAVw1zgpmAjpV8DsQPpZdY8wec5ksXoIi2 uVNgjOE57MLF0dyRM4g8gq1OkDtPpT3GyIvXd8m2tw== X-Received: by 2002:a2e:80cc:: with SMTP id r12mr4198517ljg.154.1583394839550; Wed, 04 Mar 2020 23:53:59 -0800 (PST) MIME-Version: 1.0 References: <44fa1cee-08db-e4ab-e5ab-08d6fbd421d7@linux.alibaba.com> <20200303195245.GF2596@hirez.programming.kicks-ass.net> <1180c6cd-ff61-2c9f-d689-ffe58f8c5a68@linux.alibaba.com> In-Reply-To: <1180c6cd-ff61-2c9f-d689-ffe58f8c5a68@linux.alibaba.com> From: Vincent Guittot Date: Thu, 5 Mar 2020 08:53:48 +0100 Message-ID: Subject: Re: [RFC PATCH] sched: fix the nonsense shares when load of cfs_rq is too, small To: =?UTF-8?B?546L6LSH?= Cc: Ben Segall , Peter Zijlstra , Ingo Molnar , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Mel Gorman , "open list:SCHEDULER" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 5 Mar 2020 at 02:14, =E7=8E=8B=E8=B4=87 wrote: > > > > On 2020/3/5 =E4=B8=8A=E5=8D=882:47, bsegall@google.com wrote: > [snip] > >> Argh, because A->cfs_rq.load.weight is B->se.load.weight which is > >> B->shares/nr_cpus. > >> > >>> While the se of D on root cfs_rq is far more bigger than 2, so it > >>> wins the battle. > >>> > >>> This patch add a check on the zero load and make it as MIN_SHARES > >>> to fix the nonsense shares, after applied the group C wins as > >>> expected. > >>> > >>> Signed-off-by: Michael Wang > >>> --- > >>> kernel/sched/fair.c | 2 ++ > >>> 1 file changed, 2 insertions(+) > >>> > >>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > >>> index 84594f8aeaf8..53d705f75fa4 100644 > >>> --- a/kernel/sched/fair.c > >>> +++ b/kernel/sched/fair.c > >>> @@ -3182,6 +3182,8 @@ static long calc_group_shares(struct cfs_rq *cf= s_rq) > >>> tg_shares =3D READ_ONCE(tg->shares); > >>> > >>> load =3D max(scale_load_down(cfs_rq->load.weight), cfs_rq->avg.lo= ad_avg); > >>> + if (!load && cfs_rq->load.weight) > >>> + load =3D MIN_SHARES; > >>> > >>> tg_weight =3D atomic_long_read(&tg->load_avg); > >> > >> Yeah, I suppose that'll do. Hurmph, wants a comment though. > >> > >> But that has me looking at other users of scale_load_down(), and doesn= 't > >> at least update_tg_cfs_load() suffer the same problem? > > > > I think instead we should probably scale_load_down(tg_shares) and > > scale_load(load_avg). tg_shares is always a scaled integer, so just > > moving the source of the scaling in the multiply should do the job. > > > > ie > > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index fcc968669aea..6d7a9d72d742 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -3179,9 +3179,9 @@ static long calc_group_shares(struct cfs_rq *cfs_= rq) > > long tg_weight, tg_shares, load, shares; > > struct task_group *tg =3D cfs_rq->tg; > > > > - tg_shares =3D READ_ONCE(tg->shares); > > + tg_shares =3D scale_load_down(READ_ONCE(tg->shares)); > > > > - load =3D max(scale_load_down(cfs_rq->load.weight), cfs_rq->avg.= load_avg); > > + load =3D max(cfs_rq->load.weight, scale_load(cfs_rq->avg.load_a= vg)); > > > > tg_weight =3D atomic_long_read(&tg->load_avg); > > Get the point, but IMHO fix scale_load_down() sounds better, to > cover all the similar cases, let's first try that way see if it's > working :-) The problem with this solution is that the avg.load_avg of gse or cfs_rq might stay to 0 because it uses scale_load_down(se/cfs_rq->load.weight) > > Regards, > Michael Wang > > > > > > >