From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F05BC43141 for ; Wed, 20 Jun 2018 17:22:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4943220836 for ; Wed, 20 Jun 2018 17:22:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linaro.org header.i=@linaro.org header.b="dZi7K4N7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4943220836 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754554AbeFTRWv (ORCPT ); Wed, 20 Jun 2018 13:22:51 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:41696 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754501AbeFTRWr (ORCPT ); Wed, 20 Jun 2018 13:22:47 -0400 Received: by mail-lf0-f65.google.com with SMTP id d24-v6so462090lfa.8 for ; Wed, 20 Jun 2018 10:22:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZU7eQCdNUvVwVHNHQGUhwppj4DPi+mJPY3V/YyeaLt0=; b=dZi7K4N7GvETn6Hq9kRuFwIXXLI+F66+gwDmPH4DzgMvs0Pv1Eg4DTtOCmQQc5jjOg 1btH/zuEhKyYjPoJQPkRcfLRcwiISg6bRMbUA7wu0f3W4lf8UVMtybWTjIcedaEar8IH dFxJymLVGiVAWN2gIk6wVuXw5OqgwOlKgY6o4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZU7eQCdNUvVwVHNHQGUhwppj4DPi+mJPY3V/YyeaLt0=; b=O4tJsbFxQKl8AR3it5REOnduqzy4xuJOY4+ReWjhCMy50tLmmRf1KnlQeRySOqSBcO mY2tUZfbHmsZuIz1ANQkIlhaOP+wfgtoiU7JUpACbt1ys+UKhODDQTQ0f6nm0z2rhSev kKXcTcln6DxxTwGiCSUG3MkpuZCuWAMktO5na6b/xKk9IUZ0KzPQTyHhk1/5B1374KZ/ gMJVYk/iBHJaDr+v3e3D7/TeO9+a4C7uStVmNQ6opwd6wAQolux61r1qmFU1J2XpBQAv soKIFOSMaLSGcU2yByJ+c3UXSQtOYP6CWbgx22LjMnWrF4JCBE+Ry7pKEAqXXuAteBbM gIXA== X-Gm-Message-State: APt69E0h50Zza6cfJQG7ZXkO98B0w/iRJtjrrHIyo165NvFgKuuvpmqR KFL55edbb1UYWyLnZX2Z/ZQtNg== X-Google-Smtp-Source: ADUXVKLI5PAJJ9M0tBJGD4D4qY5SXbv264nb5hwS+QxygTGi2rPcN2hdXUkSOnAKqhPzvLQMt3Uo1Q== X-Received: by 2002:a2e:43db:: with SMTP id z88-v6mr14397880lje.24.1529515365948; Wed, 20 Jun 2018 10:22:45 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id b2-v6sm514441lji.85.2018.06.20.10.22.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:45 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , 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: [PATCH v8 06/26] timer: Export next wakeup time of a CPU Date: Wed, 20 Jun 2018 19:22:06 +0200 Message-Id: <20180620172226.15012-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 + */ +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 -- 2.17.1