Received: by 10.192.165.156 with SMTP id m28csp2606156imm; Sun, 15 Apr 2018 05:04:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/37568leZFkpTeUavA1S7bih0paLnKvZ6lgwIfrHGvruvgP3bChKiKuHEYTZ14cayeFXlE X-Received: by 10.98.220.86 with SMTP id t83mr18015873pfg.60.1523793841769; Sun, 15 Apr 2018 05:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523793841; cv=none; d=google.com; s=arc-20160816; b=gUCS2aNCUV7bUhovFpCAG4aEgh0UOyhJWlSJ9JeW/eNy9yu6WVbG9iHLPuI0BrC7Po zcC8/+6NdegyK6Mwts/E28aau3ahFp7KOrYarXhGNNapWbTpr7h5mSMXYaeTwW1B5EgB wlHIjZ0PRX6vIRga8wtF64IFjvo+nqFDzAPULF4JlDyL1WN3qR8Yxbkyzfu/UR2xLVq/ c50293S42QN94jMOS0J2hs5y5PU5hesJtAQA7o/eXVkBxwZO5GIgAKVuZd78AKSupMw3 eXNaDLRQkmSpNS34a9Z0Ecp2DXp00HUSoTRmUNH2KabOVXVuCtxe5gvgaAOfaKDxnfdu HhPQ== 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=GetJmycHrNdlSiTQNPbjC6XxXmK/F4GthfQCoMlluTk=; b=V2+bpzjFC6uJggFbiPdCGxqyvO+0JKsK9qFJ4JC5O6zI8DMEj6ynAxXo+uu/8XHZKX iq85spKrbty/DNJ8sfkyKrZiw7pjOZ/HRZNZ6zLxur1iXkjIcULZj+0bMmqzCZVW9g3h C5SbSMHJzlNB1eBT1cH5cknWK5WTOlJ9vDgL/9lMJWJXamlK22ZExTcQwKRrqc6L+gLy V12qzvIgSEmL3PDV1pB/sDOwUoel3awmFofh7G//tZ4Y8IO1c6ub45z258yOI0AaYJ6D FR8gTjZM6piPsF6mOotlua6oCS9JVtS3q78WpABMpe5evpmsg8d3xP9BiiLH9xG3MQP4 a4mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=anA+kjOZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a35-v6si10022131pli.71.2018.04.15.05.03.48; Sun, 15 Apr 2018 05:04:01 -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=pass header.i=@linaro.org header.s=google header.b=anA+kjOZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752437AbeDOMCm (ORCPT + 99 others); Sun, 15 Apr 2018 08:02:42 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:34003 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751890AbeDOMCk (ORCPT ); Sun, 15 Apr 2018 08:02:40 -0400 Received: by mail-io0-f194.google.com with SMTP id d6so14956829iog.1 for ; Sun, 15 Apr 2018 05:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=GetJmycHrNdlSiTQNPbjC6XxXmK/F4GthfQCoMlluTk=; b=anA+kjOZeJZ4HJMg36kGhNp2dM25+Up0wa9UODJHBRagjjN7LgKkWm/egK7dG1JPNK aEPdjrZSJ7PjA7R/OmfIqy/if4ZrvAp7vJkfWHJIxnLnJ2tKWkzed4e4R7msJ17G0pi/ oybtIz+zs4BoEky36AVOWZmDNc6a2QULqTzaE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=GetJmycHrNdlSiTQNPbjC6XxXmK/F4GthfQCoMlluTk=; b=uBHZM4jnZmDJkXVK9oMVGhLMCuJTdpgd3at9CHJlZXjGir0ZiOQSntJG3P8PnBmosO OWKbyIx/7rIEglT29rt6G8B98/agMeb5neYc58JVo2kj/eGOhvCY+5gZwv2LWYn93b7w d/PHzacaxLi6EEtEqjgeW1PLKj8GOE5IY8fyV2/vjaMth6dVqdP/2pm0TTfjNko3IwiU BKf7uuzSpPOg5pIDpmlS4k9PJsud3WEcUDDvwMhj4LffRlqSsbS7tA4R3adS7rKKk8MG LlPxLNoI5jTHhrDcbm3LdruM8VUKN/huqJYz8ZO5qL9AMf4+ZP6zUrsxhRaNQKyXK0Y1 z6QQ== X-Gm-Message-State: ALQs6tCf15Qa4SovLDx6To0XwrNaLat1g/URiPVgpb3xF9SNcVtihwmC GCZoKkO6FOYp6Ox4VdedWsPhCSM3lNWBipAiDgvA4w== X-Received: by 10.107.20.88 with SMTP id 85mr19185393iou.218.1523793759659; Sun, 15 Apr 2018 05:02:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.115.74 with HTTP; Sun, 15 Apr 2018 05:02:39 -0700 (PDT) In-Reply-To: References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> <1523531671-27491-7-git-send-email-ulf.hansson@linaro.org> From: Ulf Hansson Date: Sun, 15 Apr 2018 14:02:39 +0200 Message-ID: Subject: Re: [PATCH v7 06/26] timer: Export next wakeup time of a CPU To: "Rafael J. Wysocki" Cc: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Linux PM , Kevin Hilman , Lina Iyer , Lina Iyer , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , Linux ARM , linux-arm-msm , Linux Kernel Mailing List , Frederic Weisbecker , Ingo Molnar 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 13 April 2018 at 10:47, Rafael J. Wysocki wrote: > On Thu, Apr 12, 2018 at 1:14 PM, 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 | 10 ++++++++++ >> kernel/time/tick-sched.c | 11 +++++++++++ >> 2 files changed, 21 insertions(+) >> >> diff --git a/include/linux/tick.h b/include/linux/tick.h >> index 389aa25..d341811 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,15 @@ 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) >> +{ >> + ktime_t t; >> + >> + /* Next wake up is the tick period, assume it starts now */ >> + return ktime_add(tick_nohz_get_sleep_length(&t), ktime_get()); >> +} > > Well, given that tick_nohz_get_sleep_length() is just the above in > this case, wouldn't it be simpler to return ktime_add(ktime_get(), > TICK_NSEC) from here? Yes! > >> + >> 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 646645e..08db7f3 100644 >> --- a/kernel/time/tick-sched.c >> +++ b/kernel/time/tick-sched.c >> @@ -1098,6 +1098,17 @@ 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 >> + */ >> +ktime_t tick_nohz_get_next_wakeup(int cpu) >> +{ >> + struct clock_event_device *dev = >> + per_cpu(tick_cpu_device.evtdev, cpu); > > I would avoid breaking the line, honestly. Alright, I have no problem with that. [,,,] Thanks for reviewing! Kind regards Uffe