Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1523997imm; Thu, 19 Jul 2018 03:18:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfM3cIcO6n/WdNZDitch6VkUU7Bn6uVuEtEyFAqbcXOd2EemAifJpdScG7aZpwODW//9MJl X-Received: by 2002:a17:902:262:: with SMTP id 89-v6mr9495532plc.221.1531995525791; Thu, 19 Jul 2018 03:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531995525; cv=none; d=google.com; s=arc-20160816; b=vo333p3w1lK/JeGGeEYn1NzIPuNKPrso5YP0jXnigBBNqu6qUWBqrwkrC5iwURLaaF PZcxKZn114ISPcps1BwtilBc1yXlvevAxM7oiS9kQk9v328/aCSiGHJ62qe+q1DXR5ic xHq8YgZaKvXv3JhH1d/eeuKm/gk2NT1r005hRSNBuFxlLscDmVmqmroymXC7HcnO/uKS p974R/aXWuhpy9BEi+z5KS0qz8fp0uiFR5qELKzzGsxNwgT/K5S6CsAChNlcpHH05nWN +xAmk+jXgezU5hBI/C346QOAj9HDrWD9zwL8moEFF7uKPrk6v3ADavk22y9igoGjfxmS /UCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=42XcgXVuwBYWxlmlJLzklyjeq+EIsMFkF2jP2cruGhw=; b=szSCxJZ5qf/EvWGrO+7MXAbwbQGTDGE/N+YrmVUlWGOyPZS8pVN+2mzzVzaVF5btH+ DSTGgv4y3zgxjRwDmBQV4pKe71nEJkoVRDUHs4g3Ho1wCtXXiYipiZjswkLfpiHCZMar TvkOBzKUdbOqV3seg46kAZFQPcgK/5ywKJRp5WYOyWa17UpTiPCIJHKRiFVI48pvz5+b LLOH6hGs60olakcEvlh0lmN8QS1c7yuzHsGfA8+eq0ylFXgQfeNzSdhv1sfYSI8ldzQV 58P1HrWpzO/j0XW64OIsUALpnDYpsk2+hNAuyMjXIu2fpaNYUI+/2Qkd2KQg/ltPSNi4 eDhg== ARC-Authentication-Results: i=1; mx.google.com; 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 o5-v6si5125844plk.25.2018.07.19.03.18.31; Thu, 19 Jul 2018 03:18:45 -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; 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 S1731408AbeGSLAG (ORCPT + 99 others); Thu, 19 Jul 2018 07:00:06 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:54909 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727032AbeGSLAG (ORCPT ); Thu, 19 Jul 2018 07:00:06 -0400 Received: from 79.184.255.17.ipv4.supernova.orange.pl (79.184.255.17) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83) id 559307ae5c49beaf; Thu, 19 Jul 2018 12:17:36 +0200 From: "Rafael J. Wysocki" To: Ulf Hansson Cc: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org, Kevin Hilman , Lina Iyer , Lina Iyer , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Frederic Weisbecker , Ingo Molnar Subject: Re: [PATCH v8 06/26] timer: Export next wakeup time of a CPU Date: Thu, 19 Jul 2018 12:15:57 +0200 Message-ID: <2046813.qdTUchafZm@aspire.rjw.lan> In-Reply-To: <20180620172226.15012-7-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> <20180620172226.15012-7-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday, June 20, 2018 7:22:06 PM CEST Ulf Hansson wrote: > From: Lina Iyer > > Knowing the sleep duration of CPUs, is known to be needed while selecting > the most energy efficient idle state for a CPU or a group of CPUs. > > However, to be able to compute the sleep duration, we need to know at what > time the next expected wakeup is for the CPU. Therefore, let's export this > information via a new function, tick_nohz_get_next_wakeup(). Following > changes make use of it. > > Cc: Thomas Gleixner > Cc: Daniel Lezcano > Cc: Lina Iyer > Cc: Frederic Weisbecker > Cc: Ingo Molnar > Signed-off-by: Lina Iyer > Co-developed-by: Ulf Hansson > Signed-off-by: Ulf Hansson > --- > include/linux/tick.h | 8 ++++++++ > kernel/time/tick-sched.c | 10 ++++++++++ > 2 files changed, 18 insertions(+) > > diff --git a/include/linux/tick.h b/include/linux/tick.h > index 55388ab45fd4..e48f6b26b425 100644 > --- a/include/linux/tick.h > +++ b/include/linux/tick.h > @@ -125,6 +125,7 @@ extern bool tick_nohz_idle_got_tick(void); > extern ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next); > extern unsigned long tick_nohz_get_idle_calls(void); > extern unsigned long tick_nohz_get_idle_calls_cpu(int cpu); > +extern ktime_t tick_nohz_get_next_wakeup(int cpu); > extern u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time); > extern u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time); > > @@ -151,6 +152,13 @@ static inline ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next) > *delta_next = TICK_NSEC; > return *delta_next; > } > + > +static inline ktime_t tick_nohz_get_next_wakeup(int cpu) > +{ > + /* Next wake up is the tick period, assume it starts now */ > + return ktime_add(ktime_get(), TICK_NSEC); > +} > + > static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return -1; } > static inline u64 get_cpu_iowait_time_us(int cpu, u64 *unused) { return -1; } > > diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c > index da9455a6b42b..f380bb4f0744 100644 > --- a/kernel/time/tick-sched.c > +++ b/kernel/time/tick-sched.c > @@ -1089,6 +1089,16 @@ unsigned long tick_nohz_get_idle_calls(void) > return ts->idle_calls; > } > > +/** > + * tick_nohz_get_next_wakeup - return the next wake up of the CPU > + */ I'd add to the comment that this is to be invoked for idle CPUs only. > +ktime_t tick_nohz_get_next_wakeup(int cpu) > +{ > + struct clock_event_device *dev = per_cpu(tick_cpu_device.evtdev, cpu); > + > + return dev->next_event; > +} > + > static void tick_nohz_account_idle_ticks(struct tick_sched *ts) > { > #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE >