Received: by 10.213.65.68 with SMTP id h4csp1461175imn; Mon, 19 Mar 2018 04:59:39 -0700 (PDT) X-Google-Smtp-Source: AG47ELvuAljlx1bUElFXsw/Ev8pNz4s+1uinoXq4bGtTqiYVsJRYtvVwrlB8oiSngCm3qgpqNjJu X-Received: by 2002:a17:902:146:: with SMTP id 64-v6mr12126402plb.30.1521460779083; Mon, 19 Mar 2018 04:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521460779; cv=none; d=google.com; s=arc-20160816; b=WnOOp+Dwy/7Roh+9qK9L20G6WJUkGOxp9bW4Gp0L1E45zFB2lmuO4tHhsgTGQnh/ny srVtNivwEYXQf8FjdvN5XUZhQT5MYiNw7/SFLsZUf50AG3wEeNSI+up6zhaBeZELGPRF 1W+k81/9tMkVuWW1Td5pI6eoIGoAQoZcU2j07fM66ASbYiBrJTrnDQ3xnRv7Ea8bsbLy wYliy28OwE39uv3oWmaasumn5nAqZbnp0BDmfQGMXuNhiEfQr4Lxen2aG80eMLRarilr HR5UNx26fazUZzSvwkzJJFTZZ2xexWEEFArKlr3fblLBoN+Kd1oezm8JW2PAR1oypGbm ILSw== 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=38iJDOgl199mceISqKrn3rVNj1hPaDqdUln51V3/Zmk=; b=TLqnhBsVykAxYQuAYtp6ENTawPGfn6gRFQShCRLLI5fIIXxyalALvE/BbNyJ6I8Drg TMuwrGbNTQq611kwUN2HAt6/s6v1QMfJHYVF9KHt1+gUvqFkeY3dJvQvrIv5QBVoQolW Oshl1lWpZH7LOceIWWgFb5Ao2Q8i7puX+f0AUERXC9P8wiC1Rns+Tos7wzJxyctC19GT yAhjfZga1TVixOJUbKzQd5Z1yJwn7mCmj5Pa5AdrrQcNk6BOLEGA10ixtVeuZrRUJMQV bqkVluclPe9XvrMGdmBkMG+E8Q8DeLvoWyK2eu40yCItqRP4lHAFTiRCds4qMZSOCWzs K9NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=V5qhMG1/; 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 w24-v6si11771900plq.553.2018.03.19.04.59.24; Mon, 19 Mar 2018 04:59:39 -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=V5qhMG1/; 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 S1755498AbeCSL6E (ORCPT + 99 others); Mon, 19 Mar 2018 07:58:04 -0400 Received: from mail-ot0-f177.google.com ([74.125.82.177]:41204 "EHLO mail-ot0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755418AbeCSL6C (ORCPT ); Mon, 19 Mar 2018 07:58:02 -0400 Received: by mail-ot0-f177.google.com with SMTP id i28-v6so12347327otf.8; Mon, 19 Mar 2018 04:58:02 -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=38iJDOgl199mceISqKrn3rVNj1hPaDqdUln51V3/Zmk=; b=V5qhMG1/RGj0irhyBuW37qCxuEpsDyLru55DUfRqF/y4p8ibxsZbbG9PksjzrSfRHF uaRf7plV5el8nFNCCmtukBo8bs388XpKA/B6KV9uscKfVf/M2XlSDg+1P4TK4FsMpThN ZF/TQ2xGB8O6xO5ZjS+wvPs8k4jpH6tEyadcLcpEPCIkuvJaKrkbt2a/++eXi6aYjvCx 8rjQXbZaD0hhxmy+gfSGq08vDDBzn2lPjw7R6tCL1bJA6h7KhxELYyfodozFO7tpgFeU ROrbj8+QVqKPpsjqVrY7pFmxBVPUBJzaLYJBFa2tr4+qCYqwOs4x+D9lPhqkSWnwxe0q b5zA== 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=38iJDOgl199mceISqKrn3rVNj1hPaDqdUln51V3/Zmk=; b=Y8zcL5lWaMzmF2nE+aaQ0vKHdwMUsSR28O3Hi3C/JheX/JYcQLpweb4bhcZPOGNdQo a3Jy0KfF7rvOX5HHlGsoxof0CsXeAcMyBW4KHOV4/wWl0F3vGjneC0Gm9E7VVdUEZbOX hQuIdBLsECyKhIH2RmOgSRiWmCzKueG7wyudOEWug8kmfBLiXMPVesZ/o559G+EttlQB 1fNeMUpFBnuFH13tEPR3QAHBtiWd2VSg/HHz5UR+owNBdnJ2ozQyqbPlAKUC4Ob0e8WU sb356EHGXcHzrAqKwwsbQFscI97Z7JtKNz1lCaijZMXVeJZSIJtU3dPtjOQuEEbHthn0 f8lQ== X-Gm-Message-State: AElRT7HWN2cs6vA8jpb8tQXGGU3/SoT/qhnlkj2+M+oi+nLEfoRFXczI D9YvoPj35g1NhTGwLo5CcykbdA875vYoRIQGXaQ= X-Received: by 2002:a9d:a43:: with SMTP id 61-v6mr7059091otg.370.1521460681554; Mon, 19 Mar 2018 04:58:01 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:9f7:0:0:0:0:0 with HTTP; Mon, 19 Mar 2018 04:58:00 -0700 (PDT) In-Reply-To: References: <2142751.3U6XgWyF8u@aspire.rjw.lan> <001a01d3be0a$ad3a0ed0$07ae2c70$@net> <2043615.lCdO10SMaB@aspire.rjw.lan> <20180319104900.GH4043@hirez.programming.kicks-ass.net> From: "Rafael J. Wysocki" Date: Mon, 19 Mar 2018 12:58:00 +0100 X-Google-Sender-Auth: g6Hj4WfBsjaYnMhuN88EKOKcHUQ 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 Mon, Mar 19, 2018 at 12:36 PM, Rafael J. Wysocki wrote: > On Mon, Mar 19, 2018 at 11:49 AM, Peter Zijlstra wrote: >> On Sun, Mar 18, 2018 at 05:15:22PM +0100, Rafael J. Wysocki wrote: >>> On Sun, Mar 18, 2018 at 12:00 PM, Rafael J. Wysocki wrote: >>> > @@ -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. >> >> My brain is just not willing to understand how that work this morning. >> Also it sounds really dodgy. > > Well, I guess I can't really explain it better. :-) > > The reason why this works better than the original v5 is because of > how menu_update() works AFAICS. Actually, it looks like menu_update() doesn't do the right thing when the tick isn't stopped at all, because data->next_timer_us is useless then. Let me try to fix that in a new respin of the series.