Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2765161imu; Thu, 29 Nov 2018 09:51:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/WuPncf7hUHXkicauGkNSItmrHXRo7dwxVpMyJgfysWda9RnrwyZAmyFrpouXRsJWDW7Z/B X-Received: by 2002:a62:c185:: with SMTP id i127mr2340990pfg.43.1543513916629; Thu, 29 Nov 2018 09:51:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543513916; cv=none; d=google.com; s=arc-20160816; b=SzBr84Q6mE4p/MADh0/rDjqQk226DTShzW5LN5wG/ysdyVrrWhoDY+HfqafjCZwQVG yhJtwBAo7hKkztiC3LE3Rkjy91Rx58tvvHWhYeneWO8TvURUgKwlVUPmLPyFmfOZlrFG EF7w7qw+pYUkaq8a8UC5O7bDUKYTB5ZNgPu4C/IP/NCHJeqFZSENVzX+2APxLPndjELS Fn8YSaYZw2lBQBQ/BnTGWRkXA91ap3I/NQZqeCHVkI8x67C4P+XE46/FlPNOtK4QoJQ3 5DNA+JgRqg9YMqX2na2n+ESQ0xBRxP4j4HRPRnR5cbZK4SmXZJVs5bftCOJGD/gtTN1L DGnQ== 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; bh=We8CaGvJmbhYNYzrL7xua655X98bhiXXYfxMtnIUbcg=; b=SLSIQzEscFY8nzFQqhxaLRPgVkg7VwmbFTn1NJqu+kft9KSwKgkr+3AVxZOowqDlLr 4wwkTQXCmNzQiTkYh141LH6g61KmlcGome6sZ4V7kYMvqWtuTx7haQYsu8WZmx7/yo3V JKlJE1aK9qaUk04GLcqXJdwelQD9frzgzejzEVOHXeDHDD+EXKpuSxNPAQzkKtYMg/Ct LaFKdcx+cPfwtITR44gV045psR+JqyN8gIdktL5f1chNEJCPRAAC8Kol7csQr5o5G1Ke nKBYF+hjMYNEolzOtkucXx/GGkUsbOh/QArbWb8+pWVAsgx60EoGZZLweXwDw2GuTSEJ MlyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="CxUDChM/"; 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 b8si2650778plx.383.2018.11.29.09.51.41; Thu, 29 Nov 2018 09:51:56 -0800 (PST) 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="CxUDChM/"; 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 S1730789AbeK3Ex0 (ORCPT + 99 others); Thu, 29 Nov 2018 23:53:26 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:39219 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730751AbeK3ExZ (ORCPT ); Thu, 29 Nov 2018 23:53:25 -0500 Received: by mail-lf1-f65.google.com with SMTP id n18so2100490lfh.6 for ; Thu, 29 Nov 2018 09:47:14 -0800 (PST) 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=We8CaGvJmbhYNYzrL7xua655X98bhiXXYfxMtnIUbcg=; b=CxUDChM/RBvhrA31XzUsCNP+4FezP+eXEflQmQnd54XH4DLPYar6y05JtbZh1VkOR9 SkqR/CZFgNzntsxd4Oe81r1RyldMKKKEpGM2IwKlpysWwwEyVbXW691jkPCx5rLzQP/r x2cpT4wVVole1llA1ynH/xIBV8qW3U8BBRoCI= 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=We8CaGvJmbhYNYzrL7xua655X98bhiXXYfxMtnIUbcg=; b=nBUgFg/RBPXNFnfQ5w38riUbZkpWEs9rAq7XeBZ3JFYhOFUYSxTMk6cTXR0DgH6mt4 wRUZWxS7Hcc2KxY5+Z4dd9cm1HOpMhuX9ZArmgtj/UFi7rFmiCzV12iwJxRrGsNEIj2+ HgIzg6cA/AiTanoVLwjfzU8LFwXPBtSaAcaYwi4sw1mFKMDfDXwcoC90BvGybAEIeSMU P3Bk3aOMHQtEKutCWmy7dmUwQIC2AddD8Qu0Nl+iwd48aOSGNRw++UCnzH3eF9eh794A XpHRXLnX76+L2FqXf9m9wlWQbyduuXD4i3tcLTyKBN++03SitI7XWNGorKI64GfGzQLo YKgg== X-Gm-Message-State: AA+aEWY4nT36VzCXNxY8W5J2mA19bN41b/iw4r4N7vVJ/QHpFjmNY5aA 8ZwjALgiKcFZOumvJPFPfuG8qA== X-Received: by 2002:a19:6806:: with SMTP id d6mr1607974lfc.48.1543513633779; Thu, 29 Nov 2018 09:47:13 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:13 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Lina Iyer , Thomas Gleixner , Frederic Weisbecker , Ingo Molnar Subject: [PATCH v10 03/27] timer: Export next wakeup time of a CPU Date: Thu, 29 Nov 2018 18:46:36 +0100 Message-Id: <20181129174700.16585-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-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 --- Changes in v10: - Updated function header of tick_nohz_get_next_wakeup(). --- include/linux/tick.h | 8 ++++++++ kernel/time/tick-sched.c | 13 +++++++++++++ 2 files changed, 21 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 69e673b88474..7a9166506503 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1089,6 +1089,19 @@ 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 + * @cpu: the particular CPU to get next wake up for + * + * Called 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 -- 2.17.1