Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4288497ybf; Wed, 4 Mar 2020 00:49:12 -0800 (PST) X-Google-Smtp-Source: ADFU+vslT0C9ZplZ/sAfFJ2saCVXKVPu6i9wUEkR0xoFWO6SnFa+ldjMzV/nh7OvWysIbre98b3o X-Received: by 2002:a05:6830:1051:: with SMTP id b17mr1562239otp.158.1583311752474; Wed, 04 Mar 2020 00:49:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583311752; cv=none; d=google.com; s=arc-20160816; b=QagzK/GZard6Bz9IK3BIuP1N9HER5HjBQN3YL0egA6u1qccV1bVtMU2dvbRqC5ZxA0 YuZvM4OJLeDvzx/aivAPfEaqxvQCl0BBS9SqEbm8bEVkSajnKMHOcecvohGOPiFVrUNz ITxVqATgxFA+zlgE0/L22gzYqUsMW6ihBu469u+YLgFbw4Jl+Nm+nTUZi26bzrbT7VZT 0ILg+4iXtbLu508irqlc0PTlsmVTbGmZmIHtsynEKyGpUIwhvOtNJN0pb0f52+c8/JqN dmWFW7gKc73FLvkPvsM0RGlIdIu7rlZ497eIpdo4aBGnnHnDtztevcdIAdwJwG/3rlbH DlmA== 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=1/muAEJRVDtA9WVzLEvKEtzqnYqmcLx2KuHECoY8Shs=; b=rseFyFMBjTJL36OD9DM0HCCwkazyGCxVjy05jvjzOuhX6k/tw12lpw5WbCeaWGuRkP OqRN3ruC1jHy2H2vm1rGdw5XWKg6EI0Twyq613z2ApEJP4i9vOqdlBqQZ27sqOhDhsZE gxEFUH7y80HLKQnXIb2aLcJuvt35rnI68Na9qUREEaetjGQUTSZSoyrwhFQ2B4qPl4lK gjQUsbY3tltPbH9AjVWu919B5jgqxF5vKMXTJIDN5ObyqIQyiqu7PJsHUptZCZKCeMYi ex+YLuOQXYCfD6o85N/x6oTpmHvSl1sHFpKhNR3BXPwkLjXbcT3ycOYc8VaH5n0pDd9k iefw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Mp/9m0Fk"; 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 d5si741491oij.139.2020.03.04.00.49.00; Wed, 04 Mar 2020 00:49:12 -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="Mp/9m0Fk"; 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 S2387672AbgCDIrs (ORCPT + 99 others); Wed, 4 Mar 2020 03:47:48 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:43230 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387624AbgCDIrr (ORCPT ); Wed, 4 Mar 2020 03:47:47 -0500 Received: by mail-lf1-f65.google.com with SMTP id s23so797605lfs.10 for ; Wed, 04 Mar 2020 00:47: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=1/muAEJRVDtA9WVzLEvKEtzqnYqmcLx2KuHECoY8Shs=; b=Mp/9m0FkAjBaUAP9dyLVOInMUfOesS6gQR/kqiAysxRIY1oojdvpJU4o9WZIBD3e5Y TOZlEcldPZahrilm3hs4AQWlS/dCaKKNoFGFKSw8nX1Qpds9pjEbIu0M1Uxqs53BzpnU fVCaFmK1SjGugd0f99DUh+JMNZHsCVyBrCPjSA6lch7kFgsUzloq4JBV3oFp194FdYUX xyHPeMN5rTzV/cHYoc0YVOt8ViEkETwwlqiiOuW5QcuG44rDjRt/RMwgl4zh8Xfy79iJ Na4vkcBJ3dQnc+RaNqbfctBIstOEOpNX+8/VNFtjoxqmrjCibyWzPvxKC6/f2SpvS7nF kgww== 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=1/muAEJRVDtA9WVzLEvKEtzqnYqmcLx2KuHECoY8Shs=; b=UoH7kjji0OpbpvyPBXhoe7Oknq1bypsFfpmPLqwbnR/34H1L4J+PXLDRWlBF1ZXj8c 3CdEH70EJhMmWMeQM6mckSM345VLtzoIlFtrhqJciFkZvoiRy8TZkCO8AJKdwH0IWeZD 5ynGjcfR8bQfNcuqBGpYNEh9jbrik0xEh7JzzV8TjI4mAd0wLz5cLruMxD4RYzPc1uXF tDOaEVnjaSDI5rC3OfvKGHtSkZ1By5SEfsZmHvKKZ0BJSg1ANZHLkqzYN3V9IF6qsdX9 ywUpiqDwcBQipOePQNyniwcvjsBONE7f7JU2ixLKrQ6AWdEHy1EIdkE85umo8z1GUVDq QxJw== X-Gm-Message-State: ANhLgQ1W39eB7rxUZU9pBPTbQfFyElgYWPSCErRTZ164HWkgjAC30O6P BHEzEifgomDkrk9UfOKRcplmOi3uHPTz9Rlwa+uSRg== X-Received: by 2002:ac2:596d:: with SMTP id h13mr1384751lfp.190.1583311665884; Wed, 04 Mar 2020 00:47:45 -0800 (PST) MIME-Version: 1.0 References: <44fa1cee-08db-e4ab-e5ab-08d6fbd421d7@linux.alibaba.com> <20200303195245.GF2596@hirez.programming.kicks-ass.net> <241603dd-1149-58aa-85cf-43f3da2de43f@linux.alibaba.com> In-Reply-To: <241603dd-1149-58aa-85cf-43f3da2de43f@linux.alibaba.com> From: Vincent Guittot Date: Wed, 4 Mar 2020 09:47:34 +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: Peter Zijlstra , Ingo Molnar , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , 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 Wed, 4 Mar 2020 at 02:19, =E7=8E=8B=E8=B4=87 wrote: > > > > On 2020/3/4 =E4=B8=8A=E5=8D=883:52, Peter Zijlstra wrote: > [snip] > >> The reason is because we have group B with shares as 2, which make > >> the group A 'cfs_rq->load.weight' very small. > >> > >> And in calc_group_shares() we calculate shares as: > >> > >> load =3D max(scale_load_down(cfs_rq->load.weight), cfs_rq->avg.load_= avg); > >> shares =3D (tg_shares * load) / tg_weight; > >> > >> Since the 'cfs_rq->load.weight' is too small, the load become 0 > >> in here, although 'tg_shares' is 102400, shares of the se which > >> stand for group A on root cfs_rq become 2. > > > > Argh, because A->cfs_rq.load.weight is B->se.load.weight which is > > B->shares/nr_cpus. > > Yeah, that's exactly why it happens, even the share 2 scale up to 2048, > on 96 CPUs platform, each CPU get only 21 in equal case. > > > > >> 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 =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? > > Good point :-) I'm not sure but is scale_load_down() supposed to scale sm= all > value into 0? If not, maybe we should fix the helper to make sure it at > least return some real load? like: > > # define scale_load_down(w) ((w + (1 << SCHED_FIXEDPOINT_SHIFT)) >> SCHED= _FIXEDPOINT_SHIFT) you will add +1 of nice prio for each device should we use instead # define scale_load_down(w) ((w >> SCHED_FIXEDPOINT_SHIFT) ? (w >> SCHED_FIXEDPOINT_SHIFT) : MIN_SHARES) Regards, Vincent > > Regards, > Michael Wang > > >