Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1036645imm; Wed, 20 Jun 2018 10:29:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKNexyhvNxIvvgQwxPb2kixUU6bpcVRrw6L5M+iLNa/7B73rnXg5aYFFoq0kiYhISUs0838 X-Received: by 2002:a63:8048:: with SMTP id j69-v6mr19867377pgd.429.1529515762095; Wed, 20 Jun 2018 10:29:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515762; cv=none; d=google.com; s=arc-20160816; b=AsXdi8aASd0+ND0J6aU7FljeGvBmtRjCPpUFkCrrib4zCfObQnKbMWMEdZLVcu2K0+ /RwQgptNl+mQjN1TNqTBPwB8Yuj4jiJY+ihAGYcip403tIBsc9WGIP2wBe/de2MGXe9Y lc5ynRaDtwHkTKk2CVp5e9BpTVn8wwvwWNw8MFnQauVCSPipV4WRplI1Mg5llmQ82gNs JUGz3FD95N3J2TiH51JfHzDSqmMUXu4uyOB2EzutyLoaBTneEZA221nY7+qbJHZNN9gc Gja+fl5ZsioE2jD/Y79iXF525sJUEsT29MhWgMeXBk7ZXibQL/1VhIgz8xuF3k+/oqCK e42w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ZU7eQCdNUvVwVHNHQGUhwppj4DPi+mJPY3V/YyeaLt0=; b=MJptvhXLtzgMOl9LYE6Id9rbHG7KXwriCweg8mcFL5JFZgPRChbIWA9VVdr16jnxAX GO5SoszvSkd9WhiCpgM/bEpP/Qrhng7fiT/mxQ01Rel/m/BjsGclfENIQu+cTtj7XyoL 3RnirssIl6Yh9/CgKg5UhkyzYVvUbJ2Sg0S+gxt+iOtFGbtyg8soDZUFgEd67v2IFloW yprNuNI+1i7ILLR6SD4U4NcIUMamvgp7+TRMD+op0s8DiqQFHNBDri8Jq4e7S5ZdgAUs WdpFe0hfp+/Muklo4irrO6dc8yea9FJwQvdPRBRKMhvIqdLpsjnerrJY+VweyWEn527W SX+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dZi7K4N7; 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 j73-v6si1618708pge.129.2018.06.20.10.29.08; Wed, 20 Jun 2018 10:29:22 -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=dZi7K4N7; 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 S1754547AbeFTRWv (ORCPT + 99 others); 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-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