Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3439760pxb; Tue, 20 Apr 2021 08:21:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3kO2nWsj5TqqjNpt4XsqVPWVHWPox2jv5SKysqZimZRaR07yqYYo9JNvriXLxB7kj984y X-Received: by 2002:a17:90a:4608:: with SMTP id w8mr5428762pjg.132.1618932097908; Tue, 20 Apr 2021 08:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618932097; cv=none; d=google.com; s=arc-20160816; b=T74yDqQVO8i6G0+K33EwcFFe6GNju+IN0zIXHXpmJDGVZ+rTxoZIQ3Yep1kXEAHBFo oOd8XJ/nTgKSosHcTRJSZhFJx6H8dWeDeJ38647pm3DPgtvvQNbqGr2K9hwkZwP3ju8j U64GH88s7bmxXmif+ViTYMJwBCwI2S01P/UEPYgy6gBDbifTBdXXgBKQzk0ae3pvpRON 1pCzFmTb+NaZIwZ6WfxRLXVfhihdiPStOvHplu54ys29EN17g4xedYCdDIhgn+vKv68a rjg76e/gk42DVCljSTKc9q2hPkZU9DbnRaOU+eC/Ggb7j1DZDQ4War06fXytVAKiSAa1 qX3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id; bh=I8y30QqhOmYS7cecSuzDrp5hCEw2ZBz9z2WjpOVSrYI=; b=TGuIu88fTCOxXR9VnXo/fBWatMA0jDlgxGBiJRizaIlhIIpvX3B423eff4p7Ij80uW TOracWX1kmh8Kg5KaM0BGKvDRumYpnXEtV/JDbc6LQXTbQPLj+mCUMvoQPppxy/mhNDc DFCo75KzsxW/fQvctWFBKjJm2Qspv9zPz0iJCRJFiia/iYSxUDnr9wkWZyQamk2QOEB5 vBOvU28GbrQS3xFZo0EUPqB+Jv5A0DDLE9ZrvTt3LwIZuAN+8blVrWVBxSTB1L8FMyB0 HWSfWieMBB/sODdYhezx86YNnABdpyxQxZB9tMV9JfjyL62a9XhyWoQdPkczPrhr23vn NPdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c1si24548998pfv.158.2021.04.20.08.21.25; Tue, 20 Apr 2021 08:21:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232504AbhDTPVP (ORCPT + 99 others); Tue, 20 Apr 2021 11:21:15 -0400 Received: from shelob.surriel.com ([96.67.55.147]:54008 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232174AbhDTPVP (ORCPT ); Tue, 20 Apr 2021 11:21:15 -0400 Received: from imladris.surriel.com ([96.67.55.152]) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1lYsB2-0002O2-MJ; Tue, 20 Apr 2021 11:20:36 -0400 Message-ID: <5e21452a727dcd6d3257496a2c42f49bd16e9cb5.camel@surriel.com> Subject: Re: [PATCH v2] sched,fair: skip newidle_balance if a wakeup is pending From: Rik van Riel To: Vincent Guittot Cc: linux-kernel , Kernel Team , Peter Zijlstra , Ingo Molnar , Dietmar Eggemann , Mel Gorman , Valentin Schneider Date: Tue, 20 Apr 2021 11:20:36 -0400 In-Reply-To: References: <20210419125134.5cab12ea@imladris.surriel.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-EQ+bP/elTcYHGVQ0YZqy" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Sender: riel@shelob.surriel.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-EQ+bP/elTcYHGVQ0YZqy Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 2021-04-20 at 11:04 +0200, Vincent Guittot wrote: > On Mon, 19 Apr 2021 at 18:51, Rik van Riel wrote: > >=20 > > @@ -10688,7 +10697,7 @@ static int newidle_balance(struct rq > > *this_rq, struct rq_flags *rf) > > if (this_rq->nr_running !=3D this_rq->cfs.h_nr_running) > > pulled_task =3D -1; > >=20 > > - if (pulled_task) > > + if (pulled_task || this_rq->ttwu_pending) >=20 > This needs at least a comment to explain why we must clear > this_rq->idle_stamp when this_rq->ttwu_pending is set whereas it is > also done during sched_ttwu_pending() >=20 > > this_rq->idle_stamp =3D 0; I spent some time staring at sched_ttwu_pending and the functions it calls, but I can't seem to spot where it clears rq->idle_stamp, except inside ttwu_do_wakeup where it will end up adding a non-idle period into the rq->avg_idle, which seems wrong. If we are actually idle, and get woken up with a ttwu_queue task, we do not come through newidle_balance, and we end up counting the idle time into the avg_idle number. However, if a task is woken up while the CPU is in newidle_balance, because prev !=3D idle, we should not count that period towards rq->avg_idle, for the same reason we do so when we pulled a task. I'll add a comment in v3 explaining why idle_stamp needs to be 0. --=20 All Rights Reversed. --=-EQ+bP/elTcYHGVQ0YZqy Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEKR73pCCtJ5Xj3yADznnekoTE3oMFAmB+8UQACgkQznnekoTE 3oNf9gf/fqJNMjAsb+l+f0a8DZOeWp0jOFn9CKfgNVt8IIdBSl42GLR8WlUa6YBa DMITTb+oFqIFlg2SNVbP3dZ3BnVY7oscerSqoMijvJesIWW1JqdNyH2LiFIBqSA+ fmXSEhkb16e1OGh7rY0JuO1zISj2HIoMV2nr5TQFdn9t2xK9Rdim8rsYBQ4oT/kT fDwyWbCv+3DBGr/wythDgFrvQfprN/1MLjnRK24Mw0U55gttDObdERKcnY0GKNFb DmHiVdbwg28P5UUhG3+gWYwlKbMR+4nKbg9yGZ+J/PCJP/GFFNN4q6SrzpxaAGQk V/ePa0wO8Va1ApMyJgQq47Qc7xZsMA== =UM3R -----END PGP SIGNATURE----- --=-EQ+bP/elTcYHGVQ0YZqy--