Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5095885ybf; Wed, 4 Mar 2020 17:15:52 -0800 (PST) X-Google-Smtp-Source: ADFU+vtal4zS1ihvza7XdOlFkBL/+lF7DMx7/oPZZ58k/KkyZ9sFXGjiAcacjwccLHwxNzefAzOg X-Received: by 2002:a05:6830:11d4:: with SMTP id v20mr4379257otq.372.1583370952441; Wed, 04 Mar 2020 17:15:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583370952; cv=none; d=google.com; s=arc-20160816; b=qB8YsC5zlf6WGPJwDzqYVVqQVg/s4xwK71diQNF1OS1zNzveGH9PtX3ItqTgWVJAVK u+gvO26BvCrDf+cSkILO6KS679a6JQ9f7hRYfktHN8acVPUEyYVhDDV9ACRbBsq50x4m +idzejQILd5wZbVWaQfiWq9ef2gfb4iH/qCvoAfgc6f6vnp1C1uOi95AWKLTxGCtAh3f 44tPpFmbydCqhfdQ5yi2pEFSqrmT2tSYS9LVuJGimRDqZMM/KuclUtH4K+6MeR2xyWpd DwHweZXyGmIkskDH/Ux2OAWRPxUc0YSmewiAE8iLr9rkL3Sa75xVtdK3EZbN1jK348kt KMTw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=nSiRyvKi80j+p0OGsC30r44jz/Exiqo3OVCFSEHWA8g=; b=Y4i9cJpWDpblFZu8STAEdFtAOn5acb23eOVQ9cmxZQaJObvKLKj+eXuv3Jxoymqh2w juvoczxdMir/IJUjFGk9pY0MfbWahI5GiJpnrWxJ4lAH6duFvhZD8Ayzy6HVbBeNPusx 1R/0eh+Mwu9RxFjC0vAxtbXEk6ouY935Jpsv8gwGC/LxEXu31gII0yQEqEgZAREOzYVH SAYRI2CVTd5+BPVJPyHTlhz8u2nFRwogA+LVhdyUI48Mm3g3EsNrdsOl9nXvYvAR2KB+ tdM7VHQGWUoCkteQOpiewLaRybnGwe5qe+mAGsXviQDVFmGlhjZWuIsx4yJBfA2f27Bp 1qOQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10si2123380oic.77.2020.03.04.17.15.39; Wed, 04 Mar 2020 17:15:52 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725825AbgCEBOw (ORCPT + 99 others); Wed, 4 Mar 2020 20:14:52 -0500 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:35406 "EHLO out30-130.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbgCEBOv (ORCPT ); Wed, 4 Mar 2020 20:14:51 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R501e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=yun.wang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0TrgZIAX_1583370887; Received: from testdeMacBook-Pro.local(mailfrom:yun.wang@linux.alibaba.com fp:SMTPD_---0TrgZIAX_1583370887) by smtp.aliyun-inc.com(127.0.0.1); Thu, 05 Mar 2020 09:14:48 +0800 Subject: Re: [RFC PATCH] sched: fix the nonsense shares when load of cfs_rq is too, small To: bsegall@google.com, Peter Zijlstra Cc: Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Mel Gorman , "open list:SCHEDULER" References: <44fa1cee-08db-e4ab-e5ab-08d6fbd421d7@linux.alibaba.com> <20200303195245.GF2596@hirez.programming.kicks-ass.net> From: =?UTF-8?B?546L6LSH?= Message-ID: <1180c6cd-ff61-2c9f-d689-ffe58f8c5a68@linux.alibaba.com> Date: Thu, 5 Mar 2020 09:14:47 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/3/5 上午2: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 *cfs_rq) >>> tg_shares = READ_ONCE(tg->shares); >>> >>> load = max(scale_load_down(cfs_rq->load.weight), cfs_rq->avg.load_avg); >>> + if (!load && cfs_rq->load.weight) >>> + load = MIN_SHARES; >>> >>> tg_weight = 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 = cfs_rq->tg; > > - tg_shares = READ_ONCE(tg->shares); > + tg_shares = scale_load_down(READ_ONCE(tg->shares)); > > - load = max(scale_load_down(cfs_rq->load.weight), cfs_rq->avg.load_avg); > + load = max(cfs_rq->load.weight, scale_load(cfs_rq->avg.load_avg)); > > tg_weight = 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 :-) Regards, Michael Wang > > >