Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp448362pxb; Thu, 5 Nov 2020 04:33:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsyUzW6JmrAaptuf7i/6UOIjMqw8zIViQRuRv474WFCmosfXcY2QdphHDwozEW9T2Y8f/p X-Received: by 2002:a17:906:4351:: with SMTP id z17mr2045657ejm.110.1604579629007; Thu, 05 Nov 2020 04:33:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604579628; cv=none; d=google.com; s=arc-20160816; b=K+BpAn1jPWWqIyP8jLT04xulkQHW/NkZSrMSkxI+WZI/MdrrR3GwGmhpjZ9hoRqA8M 1P77Ax2sbtbns3feBNOsR9dnLrS5qrn17jXjff8by7fRig2U1GBRPxruFgVFulfSurK5 I22mei2prc+Z2bzX/Ea37HsDPMMWyizOWl+sZTveRd+QtVg/kwRUaTpGyQUKflgouqmd 0F/KHGhvgDFc+91Om8Q6JYtNS0kWS3sWa4b11Fzpk+bL+euVyEPbvDOxej6x5SWwDvbk 6YS3fs4keGoqUE22WiPV2UKQtSI+ubTCwF9aB+iwwe+jWLesKPI8kMmNy/hcmYcyYnyE nmhg== 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=ShvudfQsrLd0EjdiPgpa7UMIQRNiU7jmZnEFRXbGMHA=; b=HNldDp02Al79KWOQdDxQLQMTNnpecT17TxBeOKisjjbLkMb7LIDoYSoQIuKt5FDUIj YhzZV9OhZGGGJbVDfUugQ0JVgZfHin7S5dxJPongydRfR2I2AlyXC473/JHvt6ndR5f2 GwxCXOKH66HzmZ52x3bUNtdiBFp8eifZIHWnVswDS0dwW672/QFjMM/KWnsIliSXgVzL yY62IHr9he+ZC6ry/giwFTA1lrhhBioly2YDOlHI4lWfRqNo2/OJ36NweYu3yWed1DwJ MDM8q2fWiljhxCjHSLK+Rt0NUnXhaW8mFM13Ejgl2+S9k5dud4Tux7Rqef6bObFGXqKD fo7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P1XgbaxT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id q3si1009015edv.85.2020.11.05.04.33.25; Thu, 05 Nov 2020 04:33:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P1XgbaxT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727275AbgKEMar (ORCPT + 99 others); Thu, 5 Nov 2020 07:30:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbgKEMaq (ORCPT ); Thu, 5 Nov 2020 07:30:46 -0500 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BBAAC0613CF for ; Thu, 5 Nov 2020 04:30:46 -0800 (PST) Received: by mail-lj1-x243.google.com with SMTP id m16so1378695ljo.6 for ; Thu, 05 Nov 2020 04:30:46 -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=ShvudfQsrLd0EjdiPgpa7UMIQRNiU7jmZnEFRXbGMHA=; b=P1XgbaxTDGYAgYuUP4t4ljJGR8TCc11Kb51CPtePOy0tg26wXlS/eWgX7PZIGl6ciT cPeEC8IuLGhMxRBeZWVkawam1uWZTAUPVAYDHNM+mQDahinYSpQxnVIz0K1G5DgNnmwk mCzdXo23jaG3gjREssvUF9FbBJWrZMmreTwwzP4FTD6gOSxLpCKiQAUGndovIc1GJDwA l3fO9k8IcfU4KQYz9ZkpF9vYzTxShoKhW5FNXZ1pN9DzQSDOrBVOYOnsGfV9o2P78LBD KP/7a3MdMDPcbEU8Q0wO6LifWP7Ekm7Ox1929CRl9Cz6Af67vWeMWVBJ1EihVqA9XAYa WHUA== 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=ShvudfQsrLd0EjdiPgpa7UMIQRNiU7jmZnEFRXbGMHA=; b=W0S2qS/x0q4aL4e1TqHDT9wPtxrtezEPJvS0RtLXkgluBDlU06Ls43Yu4ITuV36Ubl /c8bDyMKtCuWcGP/R+QlHP9X/c82UfHy7ToJBnNyIArd3FFwG7+PMkzk3qsSZ964IrVk cOvCYxNoqCKfBfTxvk35luz0KZIRPl54ATWLdMROYz6/VIOlTrqP85SzNzyB+i7wdhG5 q6mlPRkrMXVdEyaRFLTQmK5x08MPnNVxEtdT/R/GxmbYmh5QNL/6CnHI39hcNvC7zHH5 SmzPiRBbnYcUMDEWWPKtznltRFych+ykG3DO+zJqAkcLOMfCKQByYW65GxbtpT3McLYo 4ewQ== X-Gm-Message-State: AOAM530pJOwqlqknjhBmnXag5pp8ifBHTDR2ZEDum4wi7MEuOFrvNavi hbirVuQyXeA+dfulysFCBpTM3v1YjpFOlHbpH6qSVQ== X-Received: by 2002:a2e:9583:: with SMTP id w3mr854643ljh.25.1604579444748; Thu, 05 Nov 2020 04:30:44 -0800 (PST) MIME-Version: 1.0 References: <1604575253-2386-1-git-send-email-xuewen.yan@unisoc.com> In-Reply-To: <1604575253-2386-1-git-send-email-xuewen.yan@unisoc.com> From: Vincent Guittot Date: Thu, 5 Nov 2020 13:30:33 +0100 Message-ID: Subject: Re: [PATCH v2] sched: revise the initial value of the util_avg. To: Xuewen Yan Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , linux-kernel , xuewen.yan94@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 5 Nov 2020 at 12:22, Xuewen Yan wrote: > > According to the original code logic: > cfs_rq->avg.util_avg > sa->util_avg =3D -------------------- * se->load.weight > cfs_rq->avg.load_avg this should have been scale_load_down(se->load.weight) from the beginning > but for fair_sched_class: > se->load.weight =3D 1024 * sched_prio_to_weight[prio]; This is only true for 64bits platform otherwise scale_load and scale_load_down are nop > cfs_rq->avg.util_avg > so the -------------------- must be extremely small, the > cfs_rq->avg.load_avg > judgment condition "sa->util_avg < cap" could be established. > It's not fair for those tasks who has smaller nice value. > > Signed-off-by: Xuewen Yan > --- > kernel/sched/fair.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 290f9e3..079760b 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -794,7 +794,11 @@ void post_init_entity_util_avg(struct task_struct *p= ) > > if (cap > 0) { > if (cfs_rq->avg.util_avg !=3D 0) { We should now use cpu_util() instead of cfs_rq->avg.util_avg which takes into account other classes > - sa->util_avg =3D cfs_rq->avg.util_avg * se->load= .weight; > + if (p->sched_class =3D=3D &fair_sched_class) > + sa->util_avg =3D cfs_rq->avg.util_avg * = se_weight(se); > + else > + sa->util_avg =3D cfs_rq->avg.util_avg * = se->load.weight; Why this else keeps using se->load.weight ? Either we uses sa->util_avg =3D cfs_rq->avg.util_avg * se_weight(se); for all classes Or we want a different init value for other classes. But in this case se->load.weight is meaningless and we should simply set them to 0 although we could probably compute a value based on bandwidth for deadline class > + > sa->util_avg /=3D (cfs_rq->avg.load_avg + 1); > > if (sa->util_avg > cap) > -- > 1.9.1 > > ________________________________ > This email (including its attachments) is intended only for the person o= r entity to which it is addressed and may contain information that is privi= leged, confidential or otherwise protected from disclosure. Unauthorized us= e, dissemination, distribution or copying of this email or the information = herein or taking any action in reliance on the contents of this email or th= e information herein, by anyone other than the intended recipient, or an em= ployee or agent responsible for delivering the message to the intended reci= pient, is strictly prohibited. If you are not the intended recipient, pleas= e do not read, copy, use or disclose any part of this e-mail to others. Ple= ase notify the sender immediately and permanently delete this e-mail and an= y attachments if you received it in error. Internet communications cannot b= e guaranteed to be timely, secure, error-free or virus-free. The sender doe= s not accept liability for any errors or omissions. > =E6=9C=AC=E9=82=AE=E4=BB=B6=E5=8F=8A=E5=85=B6=E9=99=84=E4=BB=B6=E5=85=B7= =E6=9C=89=E4=BF=9D=E5=AF=86=E6=80=A7=E8=B4=A8=EF=BC=8C=E5=8F=97=E6=B3=95=E5= =BE=8B=E4=BF=9D=E6=8A=A4=E4=B8=8D=E5=BE=97=E6=B3=84=E9=9C=B2=EF=BC=8C=E4=BB= =85=E5=8F=91=E9=80=81=E7=BB=99=E6=9C=AC=E9=82=AE=E4=BB=B6=E6=89=80=E6=8C=87= =E7=89=B9=E5=AE=9A=E6=94=B6=E4=BB=B6=E4=BA=BA=E3=80=82=E4=B8=A5=E7=A6=81=E9= =9D=9E=E7=BB=8F=E6=8E=88=E6=9D=83=E4=BD=BF=E7=94=A8=E3=80=81=E5=AE=A3=E4=BC= =A0=E3=80=81=E5=8F=91=E5=B8=83=E6=88=96=E5=A4=8D=E5=88=B6=E6=9C=AC=E9=82=AE= =E4=BB=B6=E6=88=96=E5=85=B6=E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