Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1263782ybf; Thu, 27 Feb 2020 07:44:28 -0800 (PST) X-Google-Smtp-Source: APXvYqxg4AzDmJViQZcha5nbEw3yN5WwR1O3URhp4xblbfYZu5lxEsDKfsRMQQLzb36kUlZA0IKT X-Received: by 2002:a05:6830:1d4:: with SMTP id r20mr221316ota.107.1582818268096; Thu, 27 Feb 2020 07:44:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582818268; cv=none; d=google.com; s=arc-20160816; b=kiuyNz7YXeSUJ6fHrvM2zRzzuliWA/BtyWrwk1Y0quhkeJrFn6niUK/IyhkBbvX/dj dRp/zFZ22fC4NPYIs39xJZ1TXInUVpSgaY4u60h/Xa29s+DPsyz5Ad6sEyeq51/ltqcj CsF6lrejrkiP5DqQsLoxRENcmDm9ZRsfqagY25ARAyiSyR07Ggbsdl9grgEotHHbuzSW QwJIpAl+eQLSe417oW+QTscn2iYNjzR1uXpTGAAKi9zTGx3e3Gap9nM6SXWyvE+T/QdT 8QEX160FY+7I9OPf21hf9s0qDemFv6shaXqfVs0TE5QMN6p+pjDv8HGYKh9ZRd+y1zid 4v4w== 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=r9syb0EuTMFRZmvzXG0o95S31OaTn3/XSsmj6a7wCaI=; b=h5pJ59s69wrC/70sUKg+3xSHpG3ZcYdrOBFPMnL0SkLh6K4gqwhXZY01bn0dgNRYkR omsOS28iDVjY0XxuPSVH+aIDeRY3T0fUxHFhMkIm1sQjw9W+QuLNkNzrG50F/yS7eU/b AZ4HjsjDH75U0UxQIGG/fKzC2919bTVv+B7KckqHENwMhhbh+RvlQSqMKIls1yTeLKwp fzM6vGKqF7ql11vZIwnkVUUa3yO89DUcDai0QpgYcl5ZGVb3jMebwo1tVaAjPjmdYh52 Mn8MXS8hSWRBT1YX+p77853VeukIOpeD/ENhvNfn2IdZTNtABGHwa6AZW4yWcu4pjEGK GTeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JgOOQNHN; 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 a5si1681929oti.22.2020.02.27.07.44.15; Thu, 27 Feb 2020 07:44:28 -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=JgOOQNHN; 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 S1729368AbgB0Pjm (ORCPT + 99 others); Thu, 27 Feb 2020 10:39:42 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:34420 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729207AbgB0Pjm (ORCPT ); Thu, 27 Feb 2020 10:39:42 -0500 Received: by mail-lj1-f193.google.com with SMTP id x7so3982130ljc.1 for ; Thu, 27 Feb 2020 07:39:40 -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=r9syb0EuTMFRZmvzXG0o95S31OaTn3/XSsmj6a7wCaI=; b=JgOOQNHN8EQzsavUAuP7X5E+4Iof3SDJzl4QtKXNt4UX5j/cFJi9or+XRIfwp+El/7 AMiKvrvZinHP6vm38Npqly13hR5jpKT3eNaJpu/wA+cr0MnQZWC0CcsA2uAVDEWzoUnt EQqiDI8eOanC41fV2silCVJFX9LGrR9z5njhA9VgUx69HpU51lHVuSrskR80b2wmMYGz xH0CPx+tGTCFgxLexiIGie7TK7wq8tEPZA99cQdjH7L2VPdKVxdMD0SzZgnkECvd60nA or1Kp6UyWu/ljXBPJmxRh/CL02ICVRsdYg83BGm9V9f6YbHw2kAFrEu5HEJGO41MLRCz e+3g== 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=r9syb0EuTMFRZmvzXG0o95S31OaTn3/XSsmj6a7wCaI=; b=RdAHDhpmef5BR3vj+cm/bsyviotB3UZCJ4tvUpZmjnVDZJ7VxvC/QxU8kBtNlmUiN4 oIhFcv3lSBNHAqNiwTA9qE3+LoTj7mPb/bqXOdSRxmqFdVJrPQjVnAt4fg9q29lj18at TX1skVwVaFlN0VmcHuT/fEcf2oc5p+VRvx2pamDPIkdjeDc4Z4fNDp6dmB+FJOrbDM0i tcUbz50oubvd1bpv1PHasThaqRqn6VU1lP4509SPX3H3Se4oMnrhmH2nMQPqy1CePrCo F/Dyp3eDHykYDvoJvhtdoUo61AEmhlOVMJ0dD9fsQ/tN75LqWjVUC7w0ykGYcy1wJMLp NHkg== X-Gm-Message-State: ANhLgQ0bh3e+tjlR/p+n839ln8eG6byiKJFwSawALsYtj8+DW/nyDL7J TTR3hMADqWq6MRtQDwNCCt9cUeB8hDXq65MCmkXm5w== X-Received: by 2002:a2e:96c6:: with SMTP id d6mr82283ljj.4.1582817979525; Thu, 27 Feb 2020 07:39:39 -0800 (PST) MIME-Version: 1.0 References: <20200226181640.21664-1-vincent.guittot@linaro.org> <8f72ea72-f36d-2611-e026-62ddff5c3422@arm.com> <20200227153444.GB30178@pauld.bos.csb> In-Reply-To: <20200227153444.GB30178@pauld.bos.csb> From: Vincent Guittot Date: Thu, 27 Feb 2020 16:39:28 +0100 Message-ID: Subject: Re: [PATCH] sched/fair: fix runnable_avg for throttled cfs To: Phil Auld Cc: Dietmar Eggemann , Ben Segall , Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt , Mel Gorman , linux-kernel , 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 16:34, Phil Auld wrote: > > On Thu, Feb 27, 2020 at 03:58:02PM +0100 Vincent Guittot wrote: > > 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 ? > > > > Seems better to me. You could also consider "the old" and "the new". ok, will do > > Cheers, > Phil > > > > > > > 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; > > > > -- >