Received: by 10.213.65.68 with SMTP id h4csp972029imn; Sun, 18 Mar 2018 09:16:43 -0700 (PDT) X-Google-Smtp-Source: AG47ELucuhopm0lTLzevyHum293Jmoe7ZqRcB0cmOy/xX7BemGxZA2YGcrtVjKA5D4gFWe1bSSTB X-Received: by 2002:a17:902:8c97:: with SMTP id t23-v6mr9670846plo.372.1521389803179; Sun, 18 Mar 2018 09:16:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521389803; cv=none; d=google.com; s=arc-20160816; b=TTsvSyUYf9mIKyjVm9mG8mug6zdyIxeQzfW/MKk2PHRdtv43A6H2Yj0ziXka1sTLIt 4I3iizs4sDDp5z2Cz/dCs/hlbysXbnM8IM/6YnK38sCJ600eqdq1QlB0g7eRoFLfoqsy XL2vq4lPoYhq5mHNw8k9jdqCDWKKRl2XC6HXIRkSzyjM1mNHCiNSfjA5In/Pzu00/2F6 W3F/HbXuvvRhLF9Y8jjxYyR5xm4GNPUYfZSY+xzOSNKpEkU+2NOouTJ2hTeDP8ml22ji zgRWM9ABkXKFfBbv9kEWQ7TIIcUk7o6I1xxOcqIut9lwJOYsQ6T4sbbr4EfuUsBpNj2b sz2g== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=7kFVDOYum7ihJ9vIIo4B6z2cKhCiP8YNG3u/X3Yd+as=; b=P+PfFDJpTDUnG+kRjY0OmRcH4DN3M4WVSen18aZat6hM+GtROkzOPTyEdWMAvNi8+a qI8dPQkqdpLVSg1XnSSV46N6DmF3cxJoiMD3Uu2+Ma/BDtnOjXGB/Utrzd3127Y1x3SN l08d0+isd7fbTxAJ2915ZauZn05aYeSeY7wrBT24UNHSOmN+QfEtwzHQgvvZ2Ilb8rmq ppmAXb2vUCw41I6HxOUsfpm3pEYKewJpv1u33uThYMtLCwqghxojPhLl4lCklHbd5Dpj 1upHXVXtmsvL79m6Y/kwUEcmvhCgmSU4KsY4ozce2GlhYiozIrIDAGKyVLPvVEqHGRx1 CZpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mPPBaotU; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1si8307566pgs.208.2018.03.18.09.16.28; Sun, 18 Mar 2018 09:16:43 -0700 (PDT) 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=fail header.i=@gmail.com header.s=20161025 header.b=mPPBaotU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754166AbeCRQPZ (ORCPT + 99 others); Sun, 18 Mar 2018 12:15:25 -0400 Received: from mail-ot0-f193.google.com ([74.125.82.193]:47100 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751515AbeCRQPY (ORCPT ); Sun, 18 Mar 2018 12:15:24 -0400 Received: by mail-ot0-f193.google.com with SMTP id g97-v6so14982805otg.13; Sun, 18 Mar 2018 09:15:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=7kFVDOYum7ihJ9vIIo4B6z2cKhCiP8YNG3u/X3Yd+as=; b=mPPBaotUcO/gvJbtL+OiHcmIGX1Z5iPsi+0GKiWjyYXfl8R0ivndJrgOvfhOy6XbkC CllkdUL6Z6kEZctPOvRlb8mYQ2zQjcbGk3vvNqYANdHfXgZ8lqvb7CLUXBQIlDzLWG3D gbcNDwrMluZDK97BRhgKo2Zh3lxTu75yklR5cqw8qQTJTzic43SzEXODvkPgGutc9SGi TSaiOTEwWeAtNhBzrTQex6NtMYDLW+As5/wpbnniP8jGX7w4NCiFww5LztW9Ujei447r erA3CA7ErOcNBL95uENqyH5l1mfceaecBaRvzOyZoGXLfKyw8KO2Q4Ylgvx5RSUg20KZ zUrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=7kFVDOYum7ihJ9vIIo4B6z2cKhCiP8YNG3u/X3Yd+as=; b=hKGUW3ihh5DeZWx05xzbq5MgW7AecpdVEwcexxifoV63M6fVdFYrjXqjF4wOzOOTP/ CNWoD7Sm3/UORwq1OJG3q1O8tREeQ+AjPAFYiGtxNfuZjtPMKz9wbScaBdp/gEcYAhst OQozuREr3yCvQgsVBUlBN6clIF028OTTzF4Wy6TXoBp5+7ySYr25jccvCgbh1Qx/QTh9 KzQnQmJVOl8UqA4q2JuDsu8JfGGpscjNR57hrkRyVf6TLAwSBZQBolHhB3C51DdO4Tmj vIOsj1rY9u0iVcF6QvPoRzzDj+bqaj5hMHjyfkdb5Li42uiPbsNT06ThOfac/tbfLXUi aFoQ== X-Gm-Message-State: AElRT7G0V36SWBBkC/JWUn7fUWAVJ/QJzazgN72zvqUIwHw6KMe0OXiK UCF3DNkZ29wNU/bYCd/1LnwLjhcPKdbUMkLRYSg= X-Received: by 2002:a9d:a43:: with SMTP id 61-v6mr5519719otg.370.1521389723347; Sun, 18 Mar 2018 09:15:23 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:9f7:0:0:0:0:0 with HTTP; Sun, 18 Mar 2018 09:15:22 -0700 (PDT) In-Reply-To: <2043615.lCdO10SMaB@aspire.rjw.lan> References: <2142751.3U6XgWyF8u@aspire.rjw.lan> <001a01d3be0a$ad3a0ed0$07ae2c70$@net> <2043615.lCdO10SMaB@aspire.rjw.lan> From: "Rafael J. Wysocki" Date: Sun, 18 Mar 2018 17:15:22 +0100 X-Google-Sender-Auth: JgYxTmec280t8Z2z6CS57x5e0-o Message-ID: Subject: Re: [RFT][PATCH v5 0/7] sched/cpuidle: Idle loop rework To: Peter Zijlstra Cc: Doug Smythies , Thomas Ilsche , Linux PM , Frederic Weisbecker , Thomas Gleixner , Paul McKenney , Rik van Riel , Aubrey Li , Mike Galbraith , LKML 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 Sun, Mar 18, 2018 at 12:00 PM, Rafael J. Wysocki wrote: > On Saturday, March 17, 2018 5:11:53 PM CET Doug Smythies wrote: >> On 2018.03.17 Thomas Ilsche wrote: >> >> > Over the last week I tested v4+pollv2 and now v5+pollv3. With v5, I >> > observe a particular idle behavior, that I have not seen before with >> > v4. On a dual-socket Skylake system the idle power increases from >> > 74.1 W (system total) to 85.5 W with a 300 HZ build and even to >> > 138.3 W with a 1000 HZ build. A similar Haswell-EP system is also >> > affected. >> >> I confirm your idle findings. There is a regression between V4 and V5. >> The differences on my test computer are much less than on yours, >> probably because I have only 8 CPUs. >> >> http://fast.smythies.com/rjw_idle.png >> >> 1000 Hz kernel only. > > Doug, Thomas, > > Thank you both for the reports, much appreciated! > > Below is a drop-in v6 replacement for patch [4/7]. > > With this new patch applied instead of the [4/7] the behavior should be much > more in line with the v4 behavior, so please try it if you can and let me know > if that really is the case on your systems. > > Patches [5-7/7] from the original v5 apply on top of it right away for me, > but I've also created a git branch you can use to pull all of the series > with the below included: > > git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git \ > idle-loop > > Thanks! > > --- > From: Rafael J. Wysocki > Subject: [PATCH v6] cpuidle: Return nohz hint from cpuidle_select() > > Add a new pointer argument to cpuidle_select() and to the ->select > cpuidle governor callback to allow a boolean value indicating > whether or not the tick should be stopped before entering the > selected state to be returned from there. > > Make the ladder governor ignore that pointer (to preserve its > current behavior) and make the menu governor return 'false" through > it if: > (1) the idle exit latency is constrained at 0, > (2) the selected state is a polling one, or > (3) the selected state is not deep enough. > > Since the value returned through the new argument pointer is not > used yet, this change is not expected to alter the functionality of > the code. > > Signed-off-by: Rafael J. Wysocki > --- [cut] > @@ -354,6 +360,7 @@ static int menu_select(struct cpuidle_dr > if (latency_req > interactivity_req) > latency_req = interactivity_req; > > + expected_interval = TICK_USEC_HZ; > /* > * Find the idle state with the lowest power while satisfying > * our constraints. > @@ -367,17 +374,44 @@ static int menu_select(struct cpuidle_dr > continue; > if (idx == -1) > idx = i; /* first enabled state */ > - if (s->target_residency > data->predicted_us) > + if (s->target_residency > data->predicted_us) { > + /* > + * Retain the tick if the selected state is shallower > + * than the deepest available one with target residency > + * within the tick period range. > + * > + * This allows the tick to be stopped even if the > + * predicted idle duration is within the tick period > + * range to counter the effect by which the prediction > + * may be skewed towards lower values due to the tick > + * bias. > + */ > + expected_interval = s->target_residency; > break; BTW, I guess I need to explain the motivation here more thoroughly, so here it goes. The governor predicts idle duration under the assumption that the tick will be stopped, so if the result of the prediction is within the tick period range and it is not accurate, that needs to be taken into account in the governor's statistics. However, if the tick is allowed to run every time the governor predicts idle duration within the tick period range, the governor will always see that it was "almost right" and the correction factor applied by it to improve the prediction next time will not be sufficient. For this reason, it is better to stop the tick at least sometimes when the governor predicts idle duration within the tick period range and the idea here is to do that when the selected state is the deepest available one with the target residency within the tick period range. This allows the opportunity to save more energy to be seized which balances the extra overhead of stopping the tick. HTH