Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1216762ybf; Thu, 27 Feb 2020 06:59:02 -0800 (PST) X-Google-Smtp-Source: APXvYqxlriyf+k8ZSTH9NeFlrQT3obvGBt7EMY7skui/IKFhF07Ex7lO6tDnJOrloXmypRKShBTI X-Received: by 2002:a05:6808:ab2:: with SMTP id r18mr1816339oij.129.1582815541909; Thu, 27 Feb 2020 06:59:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582815541; cv=none; d=google.com; s=arc-20160816; b=g8d4/w82w+zjKCLUS9Jjr4z5U1GJ3O8tDNxGkkCp0mMUd8iV+zPYNGPtTZwZIEwk/k OTbclIZf100WydEHDHy6fiT37UR9ov1eoIcs0+RDkAWaGtLglJyeXgiSqAcTnvKlcAwe niFj6rCm64DQZFMmgE3mvDgZzXb5hKlSmxw8nBu4xLGSwLRXtceCXJKD0mdNj+02HCmO fUDcefcgWCBN60pJcfPIRyjdXDjco0ni4xTbrscuCr4v+10TouO2le8cw8yiynB6g++e wdPT7oAFK84wMSuvJv2vbKgKXnp0GHsm0FIdPd9uSflLX2Gsv8+rU/846dcAnnqcEA4H 9iNQ== 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=aTf53l+ERC5tzgGssL0BoGJrw05AN4ObqwUxsfjBbYg=; b=lpqjbz/4epu8k28nPbysZUCd2wRsS6Ck8Ypr0HtL+xdDS3hd33WEWzNjxxrvyhVZun 4ISd7PtgqIF9nkV+P1eht8tccKSbMvGUvfghecyhkrZwpjoiAYgBsfMrPYcrU4jo4PHp L/e10ynz0PhU/4+ruoGqtYZhtQgxiP2/PvO/KZomRAASGs+xPQu4tVIc33NIWNphFPJU 8Vo0cIQRpYUOQbjiPZRCQsY3WBqz6b2rGKveV1q8XpPCx+GvMAW9KY7bYH3Dq5BF008z chLK9BER3yY9Qg+JAA2bljbaAAYJ7RvXF+GopTn48C8fLzN4qEcJj4A+byD0kKiUwYN7 vJCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="WgRm/FMp"; 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 u12si1396886oiv.13.2020.02.27.06.58.50; Thu, 27 Feb 2020 06:59:01 -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="WgRm/FMp"; 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 S1731695AbgB0O6R (ORCPT + 99 others); Thu, 27 Feb 2020 09:58:17 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:40366 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729983AbgB0O6Q (ORCPT ); Thu, 27 Feb 2020 09:58:16 -0500 Received: by mail-lf1-f68.google.com with SMTP id c23so2305523lfi.7 for ; Thu, 27 Feb 2020 06:58:15 -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=aTf53l+ERC5tzgGssL0BoGJrw05AN4ObqwUxsfjBbYg=; b=WgRm/FMpgAMUYeUo5G+W95Ep9TyZ3+12iwn9yu2TbN0mbhqC8/C8NdAhKm9pc1LnfT lBDciFBrXY7o2vRVi5f6Jz3/xNrPlJ8I8YoP+uI4i0T4ru3G4MCSBwmQ73muYHNmr3f8 RzExTPNy+JDdxh6TOv7NetqK2RWzCkl8QyT4Ehp9g1kikwZSFoZF5Qqo0mbgqYxsFuCh rtBwTwDo8X6BvROUEYaWN9Hpm4vlXFYKewVhyMUycqer3QPIrXaVZNykXcsf2UKR7wc3 4+SuPu5j/zfgBL6eqWL0Em1u8HGUpjcNwbEcai8t58ThkjcoVM9OsOjAQVVy5tHJVFtE 3NAw== 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=aTf53l+ERC5tzgGssL0BoGJrw05AN4ObqwUxsfjBbYg=; b=Vxvz2HOydu/RHargaiULmK1EN7N4aGLBOaF/7MsNN7Bywq3skEKORdMPlA4nqZX5ba pLuxcmykBhW3cT9njDpTq70vQiCOgzdmbZ2xygDT+3FsG7XxHaDui0fOr4SLYSEqculo Rumbbo0UmtEmvw1Y5gcGdi7Ft/RlKH71hSp7KNbwF1zhDqwGoGkbQcOvOVzFA5OsmZrX z6TsjXY0GnfPsbu92mfwkrMfUP7ICpithGLTgg7W3qvytWT+GQndCQDaeZ4FP1E0vWku iVagy4Q0RyztHVHPZdRuyhm08VbAO2tSiuwqwFJ31mKSveKqB5vJbarmI5U28ynAehQ0 hyew== X-Gm-Message-State: ANhLgQ2nBTHUvkBczIVZA0pyWrotHawdRETbY3Rbnu3DzznVZW0/WiBX AkXrkfGrC8mGnhWBrLEjPYx2FyRVTruo5hm6wnrbsw== X-Received: by 2002:a19:6903:: with SMTP id e3mr6662lfc.25.1582815493879; Thu, 27 Feb 2020 06:58:13 -0800 (PST) MIME-Version: 1.0 References: <20200226181640.21664-1-vincent.guittot@linaro.org> <8f72ea72-f36d-2611-e026-62ddff5c3422@arm.com> In-Reply-To: From: Vincent Guittot Date: Thu, 27 Feb 2020 15:58:02 +0100 Message-ID: Subject: Re: [PATCH] sched/fair: fix runnable_avg for throttled cfs To: Dietmar Eggemann Cc: Ben Segall , Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt , Mel Gorman , linux-kernel , Phil Auld , Parth Shah , Valentin Schneider , Hillf Danton , zhout@vivaldi.net 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, Vincent Guittot wrote: > > On Thu, 27 Feb 2020 at 12:20, 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 this be 'current' rather 'new' h_nr_running for > > group_se->runnable_weight? IMHO, you want to cache the current value > > before you add/subtract task_delta. > > hmm... it can't be current in both places. In my explanation, > "current" means the current situation when we started to throttle cfs > and "new" means the new situation after we finished to throttle the > cfs. I should probably use old and new to prevent any > misunderstanding. I'm about to send a new version to fix some minor changes: The if statement should have some { } as there are some on the else part Would it be better for you if i use old and new instead of current and new in the commit message ? > > That being said, we need to update runnable_avg with the old > h_nr_running: the one before we started to throttle the cfs which is > the value saved in group_se->runnable_weight. Once we have updated > runnable_avg, we save the new h_nr_running in > group_se->runnable_weight that will be used for next updates. > > > > > >>> 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;