Received: by 10.213.65.68 with SMTP id h4csp1396661imn; Mon, 19 Mar 2018 03:03:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELu5+6GThdj70oXgYoS3Ynxu1n0eEr6BPgGVigYz1PBBgE4fAe0J3zpGxWk6VTaXwZO2+/II X-Received: by 2002:a17:902:8c91:: with SMTP id t17-v6mr11920877plo.233.1521453837488; Mon, 19 Mar 2018 03:03:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521453837; cv=none; d=google.com; s=arc-20160816; b=jP5TychkVQtBuYMCRHxAQ43ue5YVOVBtt+vfUbf2jfPut7Ixs6837z0q819t9PH71n Jn7fQL2K5TP3AaYDyHR5cjtppUEr8kvjizyxO5yVqTQPTmj9wOu8sK6QuLUDHXTO8pBJ TRt1kAMNIHIKISR1CoN4DEszKRuLLU7ytK2sPFSStWE3UXx3DkT+UTlESrwI8ckpJowC /nBBopS4145wLfYjj8Ez9CeWMXirqEgb9k4a3Ocy4KSSjh1CM0Ue4Cv+aUhLxo+iWVxN ig1pVyrS3lcrK6lDSQAq4Na/pdFCm7rnvNrtBmFV6vi5tI6Gt7XAPIGaVs+s2pbILtTN b6eg== 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=tNkAPfYi6HvFqtVXHrUqAFlHrJMrmA1VPlN2dR8hixU=; b=HBQrphTxyW0mQFwBiL+sJLFJ1VFRuM+/GDijlwUn0CcofBRJfn1xzu5WRdYmMZsZiy QlCK8VRene6ukLTbxY7ZStaXbz5unsC5cbEP6MqYTLkhHr6U9IZiotR+Do06i9kDfmDD Vd3QqDYg9BW97Q+8gahSebm2qCTB9kY2CbgY2XKCaVESJKdX7tWoDDNlqbyq24o7B6i/ 3K2JPuUBLKqgPU99fPXAAwEttb30E5SF5VxtfA3qLtoiQXjA3a+oLl4tQ9bjr7E2Ppfw kwb/5wveAgF+QL/fCAYkUVxIPypwgIvmZMKxKStnVjXN7JXenIkzt6DXyxLhONrjdR7i HSpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=XxUScBhk; 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 x5-v6si12339860plm.443.2018.03.19.03.03.43; Mon, 19 Mar 2018 03:03:57 -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=XxUScBhk; 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 S932541AbeCSJjx (ORCPT + 99 others); Mon, 19 Mar 2018 05:39:53 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:39843 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752603AbeCSJjv (ORCPT ); Mon, 19 Mar 2018 05:39:51 -0400 Received: by mail-oi0-f67.google.com with SMTP id q71so3484119oic.6; Mon, 19 Mar 2018 02:39:51 -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=tNkAPfYi6HvFqtVXHrUqAFlHrJMrmA1VPlN2dR8hixU=; b=XxUScBhkLa6rjsMtwNMZHYMgctb8685KVedtcbyftpKslWLdMIT+lJ1oGHRgFD14Gx nfeFfmDD8yeeIkxXd9ZG/rZ6q2toCI2ljhdlMlgeQtKZb7pefpLEZKI5CSZXf1P74Sos neV9AjtAckLtJ48OX/ZTwMA4N2lUPQVmQLghQQdbOmutdvL/qIdShUBxBW0y0wWrRGHC Z+rAI2RfBd7l5Y0ZzAftwh2UOSzsdbfTkCXXWz0XThGXcTeC9jZ5CS+WfrDLGcLpO2ej bIgBbbpn5nMCqbtiW2h9jEHmYmDuoBed9Y6SPZqI9GoNXL3sG5OsPdWFTaPZm+cgYzf3 +kIg== 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=tNkAPfYi6HvFqtVXHrUqAFlHrJMrmA1VPlN2dR8hixU=; b=kBzcaJ525NeGJNP5LaGssQyUlwihRpfJv+s+9poufbYz9xiqOfl1tPgdQ8F/nxBgQY XtnA6DoO/haPCEs6lYJvKysOSng2Qs6UChEvCkNxgRqqQPaIeTJ9ABHvEk5cCRY6LCXH sGFg0h+C/hhE6eymWBWVkYz9+Ly2NJlFUn898ZGlerzLP+2UWfK7Y1+ZWpFggIEWqjTX U6b0uD25thntfJPTuYPtKseiFHkJ9HILJBMiJtZE5BH+8ZyTMhw7TD6jU0hMGwwB7l2d 6VTm8pkVjvvdVjInNKucicV1TcDQ7U13TpT93GOQXfSWLNvcKFMzhsfRF9/Yj1M/ux/D bb/Q== X-Gm-Message-State: AElRT7En20kWz2+3tNkp2ApYqqvWZ1rAdebnpYgJX1FqyyUq1Yiq1+Ui gntbOxMhjiI7pZuPE2OETlhIZ3UH4shEZEJXV9g= X-Received: by 10.202.224.132 with SMTP id x126mr6295625oig.120.1521452390570; Mon, 19 Mar 2018 02:39:50 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:9f7:0:0:0:0:0 with HTTP; Mon, 19 Mar 2018 02:39:50 -0700 (PDT) In-Reply-To: <20180319091159.GF4043@hirez.programming.kicks-ass.net> References: <2142751.3U6XgWyF8u@aspire.rjw.lan> <2021405.tG9RYD54xL@aspire.rjw.lan> <20180319091159.GF4043@hirez.programming.kicks-ass.net> From: "Rafael J. Wysocki" Date: Mon, 19 Mar 2018 10:39:50 +0100 X-Google-Sender-Auth: JEQH4RJCwBTdvqjtFvjKU0J4Gf4 Message-ID: Subject: Re: [RFT][PATCH v5 4/7] cpuidle: Return nohz hint from cpuidle_select() To: Peter Zijlstra Cc: "Rafael J. Wysocki" , Linux PM , Frederic Weisbecker , Thomas Gleixner , Paul McKenney , Thomas Ilsche , Doug Smythies , 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 10:11 AM, Peter Zijlstra wrote: > On Thu, Mar 15, 2018 at 11:11:35PM +0100, Rafael J. Wysocki wrote: > > I would suggest s/nohz_ret/stop_tick/ throughout, because I keep > forgetting which way around the boolean works and the new name doesn't > confuse. OK >> Index: linux-pm/drivers/cpuidle/governors/menu.c >> =================================================================== >> --- linux-pm.orig/drivers/cpuidle/governors/menu.c >> +++ linux-pm/drivers/cpuidle/governors/menu.c >> @@ -275,12 +275,16 @@ again: >> goto again; >> } >> >> +#define TICK_USEC_HZ ((USEC_PER_SEC + HZ/2) / HZ) > > Do we want to put that next to TICK_NSEC? That would be one change too far IMHO. > Also, there are only 2 users of the existing TICK_USEC, do we want to: > > s/TICK_USEC/USER_&/ > > and then rename the new thing to TICK_USEC ? Well, that can be done. >> /** >> * menu_select - selects the next idle state to enter >> * @drv: cpuidle driver containing state data >> * @dev: the CPU >> + * @nohz_ret: indication on whether or not to stop the tick >> */ >> +static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, >> + bool *nohz_ret) >> { >> struct menu_device *data = this_cpu_ptr(&menu_devices); >> struct device *device = get_cpu_device(dev->cpu); >> @@ -303,8 +307,10 @@ static int menu_select(struct cpuidle_dr >> latency_req = resume_latency; >> >> /* Special case when user has set very strict latency requirement */ >> + if (unlikely(latency_req == 0)) { >> + *nohz_ret = false; >> return 0; >> + } >> >> /* determine the expected residency time, round up */ >> data->next_timer_us = ktime_to_us(tick_nohz_get_sleep_length()); >> @@ -354,6 +360,7 @@ static int menu_select(struct cpuidle_dr >> if (latency_req > interactivity_req) >> latency_req = interactivity_req; >> >> + expected_interval = data->predicted_us; >> /* >> * Find the idle state with the lowest power while satisfying >> * our constraints. >> @@ -369,15 +376,30 @@ static int menu_select(struct cpuidle_dr >> idx = i; /* first enabled state */ >> if (s->target_residency > data->predicted_us) >> break; >> + if (s->exit_latency > latency_req) { >> + /* >> + * If we break out of the loop for latency reasons, use >> + * the target residency of the selected state as the >> + * expected idle duration so that the tick is retained >> + * as long as that target residency is low enough. >> + */ >> + expected_interval = drv->states[idx].target_residency; >> break; >> + } >> idx = i; >> } >> >> if (idx == -1) >> idx = 0; /* No states enabled. Must use 0. */ >> >> + /* >> + * Don't stop the tick if the selected state is a polling one or if the >> + * expected idle duration is shorter than the tick period length. >> + */ >> + if ((drv->states[idx].flags & CPUIDLE_FLAG_POLLING) || >> + expected_interval < TICK_USEC_HZ) >> + *nohz_ret = false; >> + >> data->last_state_idx = idx; >> >> return data->last_state_idx; > > Yes, much clearer, Thanks! But this has regressed since the v4, please see https://patchwork.kernel.org/patch/10291097/ Thanks!