Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1109705ybf; Thu, 27 Feb 2020 05:13:35 -0800 (PST) X-Google-Smtp-Source: APXvYqzMSJOA4iuC9tTeE7bJT7+o64oam8tBe8HDQqwS/3KytfPGozUl6G306cgvdnLlkZacopn6 X-Received: by 2002:a05:6830:110a:: with SMTP id w10mr3333949otq.300.1582809215290; Thu, 27 Feb 2020 05:13:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582809215; cv=none; d=google.com; s=arc-20160816; b=Vm78mPRTFJddtYXvFHwPf5E6Taf8MoqOWemUSeWZjQgEnP5n/IX9m6tM2Z/qhTLMl1 lCta7kgmdsI6/xs3WmsxZSvgt/hdlsXeFAEC4HP+voIDoxGRYXkSqhsFMBnu2HkuCe51 fkNwP/ms/QKei2bLHiJFYFS+omW0sC2uBBomOLSCcYchg9Dj0oN3sWPdXgyWEEW8c4CQ J7+67nGtfiwwixfYFZwa6kNIoeba2zZdjFZIxhASIVzty/hUjohDRYBK4yTF9Tz9IC4l wEry5nSkd6Sl7ooKaavbYJ0MvbcCnz9LEfNepmMjuwVR9nK7RhNC5tTi+hTqwQtbnHsN A0wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=hgDPuFgqNNjYp8TK2gleYVtj6m36FxOdqFNLJteFThk=; b=Z4bEh8mGIUPbnHZyX8CnC+DyPYZsbzxsOjAxdm8HpKTzTR2vHVMdRkkjrR/8edHdf1 lHVUrDoiUiMgQtfPw/mptlnb0QHn4aQru5jQQ6js2VaMfNZW1fh9gh4Nb6fGlvVYnVwT wt7HHfMr9xN9ZgFmCYS0wFOZIeXGX99j86ENkPIYY2V27f1kHjIe8EZBftMtHsWHLPc+ YnUSHeXxjUvHA65NFEJEPOH4t3ZFErNCL3nUKmEWxpSQhy7ENpgwXoXRsmoGTUcEQ4Fw DeZ6kQBrNORuCK/gkzNiEUFttrz6WypgMUNVRqSTn5CEy6hEff3QCxnE9vktCQovFDul V/Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x6GyZJy6; 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 d12si1405639otc.307.2020.02.27.05.13.23; Thu, 27 Feb 2020 05:13:35 -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=x6GyZJy6; 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 S1729140AbgB0NMX (ORCPT + 99 others); Thu, 27 Feb 2020 08:12:23 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:36278 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729125AbgB0NMX (ORCPT ); Thu, 27 Feb 2020 08:12:23 -0500 Received: by mail-lj1-f194.google.com with SMTP id r19so3360938ljg.3 for ; Thu, 27 Feb 2020 05:12:21 -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; bh=hgDPuFgqNNjYp8TK2gleYVtj6m36FxOdqFNLJteFThk=; b=x6GyZJy624MM4KUrgtjgaSsHLegnL3Bb7n2ZitPwN+zfj1Pg3KLtkB3ZCMl4nwFyEW hhP56CT/202FsxHWk7AqyRdlC+/0aJyEKba0lajgDUDeDU/KPGUXvM1qFiPQmrV/xN4/ sJ74v5eZ+AYFhk8VK9bK3C++p8ZGLVcJzywmvjh+RvSSzce6LPjbMdiqnmLfmYIWQSCf HIIDX4RdlkA5axhx505gaIvknMFrlKa0Vdwru1tu9XqfGzEWv0DKE3lvrjBPTfP9Y8eF 2aXqbguYzt3V6+F8RKmZIixVTeLcaeuwIh18hV43vaXfsaO4CBXSxnCgPt+hvrEbaNtq 6E7A== 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; bh=hgDPuFgqNNjYp8TK2gleYVtj6m36FxOdqFNLJteFThk=; b=C0uaIPCiVQKtAOMtyloiQuvzv/yu9ad7jp0Ecd1Irqcx9JfqNqWfVlkX+uYJURq64/ 8O2Nfpy5LI0DHMBTkNrdkwgUSdmAle0A/xr+pp9wBScYfR3gMETPI1P1HTaFt4CXPXJ8 cj+BEErnT2Ftse6SzBOhb2OOOT7Abdp0V+CF7uilKbLO5cDzZOO8Re2jGGWgFA0iDU1A nEBDxgYgWqjWuvt76mrRgZj0qHA2VNu8HCerYsy1u4Xh9tWF5Y1RKSmzifoTZbG78Q3v LlLu9WBrJ5X2ODLKnI53Lr6/JItyERnAQqg1g1LncWQoLrcdDi0JIJDF7oZbBy3/p89h fH9g== X-Gm-Message-State: ANhLgQ3Rv+ZABjDY+grvjaFrkDTKdL1Pf7ldWjUW9+392G0s14DTyXxX +0wZ4iSL9Tn+vEys6ao6GpfR9UIxFYjLBdzRLPIhUg== X-Received: by 2002:a2e:808a:: with SMTP id i10mr2789949ljg.151.1582809140984; Thu, 27 Feb 2020 05:12:20 -0800 (PST) MIME-Version: 1.0 References: <20200226181640.21664-1-vincent.guittot@linaro.org> <8f72ea72-f36d-2611-e026-62ddff5c3422@arm.com> <20200227131228.GA5872@geo.homenetwork> In-Reply-To: <20200227131228.GA5872@geo.homenetwork> From: Vincent Guittot Date: Thu, 27 Feb 2020 14:12:09 +0100 Message-ID: Subject: Re: [PATCH] sched/fair: fix runnable_avg for throttled cfs To: Tao Zhou Cc: Dietmar Eggemann , Ben Segall , Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt , Mel Gorman , linux-kernel , Phil Auld , Parth Shah , Valentin Schneider , Hillf Danton Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 27 Feb 2020 at 14:10, Tao Zhou wrote: > > Hi Dietmar, > > On Thu, Feb 27, 2020 at 11:20:05AM +0000, Dietmar Eggemann wrote: > > On 26.02.20 21:01, Vincent Guittot wrote: > > > On Wed, 26 Feb 2020 at 20:04, wrote: > > >> > > >> Vincent Guittot writes: > > >> > > >>> When a cfs_rq is throttled, its group entity is dequeued and its running > > >>> tasks are removed. We must update runnable_avg with current h_nr_running > > >>> and update group_se->runnable_weight with new h_nr_running at each level > > > > ^^^ > > > > Shouldn't his be 'curren' rather 'new' h_nr_running for > > group_se->runnable_weight? IMHO, you want to cache the current value > > before you add/subtract task_delta. > > /me think Vincent is right. h_nr_running is updated in the previous > level or out. The next level will use current h_nr_running to update > runnable_avg and use the new group cfs_rq's h_nr_running which was > updated in the previous level or out to update se runnable_weight. Yes that's what I want to say > > update_h_nr_running (E.G. in enqueue_task_fair) > > throttle_cfs_rq() > for() { > update_load_avg() > se_runnable() --> current h_nr_running > update_se_runnable() --> use group cfs_rq h_nr_running > updated in the prev level or out > update_h_nr_running > } > > Thanks, > Tao > > > >>> of the hierarchy. > > >> > > >> You'll also need to do this for task enqueue/dequeue inside of a > > >> throttled hierarchy, I'm pretty sure. > > > > > > AFAICT, this is already done with patch "sched/pelt: Add a new > > > runnable average signal" when task is enqueued/dequeued inside a > > > throttled hierarchy > > > > > >> > > >>> > > >>> Fixes: 9f68395333ad ("sched/pelt: Add a new runnable average signal") > > >>> Signed-off-by: Vincent Guittot > > >>> --- > > >>> This patch applies on top of tip/sched/core > > >>> > > >>> kernel/sched/fair.c | 10 ++++++++++ > > >>> 1 file changed, 10 insertions(+) > > >>> > > >>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > >>> index fcc968669aea..6d46974e9be7 100644 > > >>> --- a/kernel/sched/fair.c > > >>> +++ b/kernel/sched/fair.c > > >>> @@ -4703,6 +4703,11 @@ static void throttle_cfs_rq(struct cfs_rq *cfs_rq) > > >>> > > >>> if (dequeue) > > >>> dequeue_entity(qcfs_rq, se, DEQUEUE_SLEEP); > > >>> + else { > > >>> + update_load_avg(qcfs_rq, se, 0); > > >>> + se_update_runnable(se); > > >>> + } > > >>> + > > >>> qcfs_rq->h_nr_running -= task_delta; > > >>> qcfs_rq->idle_h_nr_running -= idle_task_delta; > > >>> > > >>> @@ -4772,6 +4777,11 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) > > >>> cfs_rq = cfs_rq_of(se); > > >>> if (enqueue) > > >>> enqueue_entity(cfs_rq, se, ENQUEUE_WAKEUP); > > >>> + else { > > >>> + update_load_avg(cfs_rq, se, 0); > > >> > > >> > > >>> + se_update_runnable(se); > > >>> + } > > >>> + > > >>> cfs_rq->h_nr_running += task_delta; > > >>> cfs_rq->idle_h_nr_running += idle_task_delta;