Received: by 10.213.65.68 with SMTP id h4csp1372501imn; Mon, 19 Mar 2018 02:13:43 -0700 (PDT) X-Google-Smtp-Source: AG47ELuWmk4nCZMv7RE0h8Fhz8vjzDaqF4Nth0TuRP3Fp1na+PGJrsyeHdNFCjlYJpLLHqK7TLMM X-Received: by 2002:a17:902:6ac1:: with SMTP id i1-v6mr8742927plt.152.1521450823190; Mon, 19 Mar 2018 02:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521450823; cv=none; d=google.com; s=arc-20160816; b=VMjl93L3mgyM/uvm+SYy2vzCfXZlnkVfj/ybHfQjA+rPfaC2KKcBio2XQxkudjzh3z 0zcqq+7Rl/dXmyPgGy11Vc1v3jdtoUdnjn/BcRk0gbjoAgTpgIE1fn7qSjj/WeH0Jfl0 SWG5Bmn2W3a5UzGmQGkO5yYQ2nt/EyaVDRugDJsbuBRG+O3buA0pLnFMDums538zWfln eHLc+46h4ml2A6baD21Jdeg1DeLjAQioeT4Wt0r25Zy/i+hT05GXBfTFuXWE9W5hYg+6 lVXvpIJhvDNa60P6OcjALx8JTdK5ISNshiY5LcbU2C3luEgtaAesgoAhmQyqm0szYsJf LNfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=+kBcyRITKOyGQoBtQxFf6UgR0w3QdzgJag40pUPg/a0=; b=L3o7a6BTn4JZpYeILgG8iNvzcRcj8bBZHbFzf+IOluZaTZuHAS5MBQfYuRnC1/XIFX JJXXZVASyvfhiiar3qWonKXyvyNuk8ud8dtBQjza3kNQc/eRSbpfJHKk0Kd1zX/PbQg5 nrqhIn/ZQn5vDUd8NwvCZOPpDgMSbKmLYZ48KnqBVcbfFbha+PQFrpAbG9os98kt1q49 JU7xw6O0noHYmI/zQrOwRsf0v6KBWDnWDAaSXczQ5j3bU0YN8jhmSPXCSKgbXsO1Bb6I pklRse1t7xc96dpJWrXWryYbd/Mixu79KbeXyQcncbhPBcj+6rc0+uuyTG0LASqLP1wu /GlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=StVJOtUf; 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 s6si9260131pgp.577.2018.03.19.02.13.28; Mon, 19 Mar 2018 02:13: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=@infradead.org header.s=merlin.20170209 header.b=StVJOtUf; 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 S932638AbeCSJMb (ORCPT + 99 others); Mon, 19 Mar 2018 05:12:31 -0400 Received: from merlin.infradead.org ([205.233.59.134]:46212 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932426AbeCSJM3 (ORCPT ); Mon, 19 Mar 2018 05:12:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+kBcyRITKOyGQoBtQxFf6UgR0w3QdzgJag40pUPg/a0=; b=StVJOtUfAxWQrhdUH4cd1om3z sgQOCmhAJZ4SdJJ5DDSwy7ynFuorZIKNf6UEKI9FfbHnrCD9zKtOj1VS13fQicUgOLl0RA0kcQY5o m/MY8F82Fx1teVEIql8woPChFHEfV0OGHeQw7OL5UKFs6pYTefbzAZAVR1Vbr6rabnoNcLVCezVrv gOOEYKrz7ZKS/MxTb5X9szc8IjdSopJTaHpmEi/M/OftDSGB4s02xiUUhotNkm7x+DaNCqzg+nxmW c2stmCQ5LEDz+0yXI79GrbbstOrkJJgurUBqmm8Uadg9syFi/1ttn7brtgE9nAQ0Z57o5i4QkkylO yFkKUsfGw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1exqpk-0000A1-Vz; Mon, 19 Mar 2018 09:12:02 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4CD1C2029F860; Mon, 19 Mar 2018 10:11:59 +0100 (CET) Date: Mon, 19 Mar 2018 10:11:59 +0100 From: Peter Zijlstra To: "Rafael J. Wysocki" Cc: Linux PM , Frederic Weisbecker , Thomas Gleixner , Paul McKenney , Thomas Ilsche , Doug Smythies , Rik van Riel , Aubrey Li , Mike Galbraith , LKML Subject: Re: [RFT][PATCH v5 4/7] cpuidle: Return nohz hint from cpuidle_select() Message-ID: <20180319091159.GF4043@hirez.programming.kicks-ass.net> References: <2142751.3U6XgWyF8u@aspire.rjw.lan> <2021405.tG9RYD54xL@aspire.rjw.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2021405.tG9RYD54xL@aspire.rjw.lan> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > 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? 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 ? > /** > * 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!