From patchwork Fri Jul 29 21:56:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 73055 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1601282qga; Fri, 29 Jul 2016 14:57:14 -0700 (PDT) X-Received: by 10.98.9.11 with SMTP id e11mr72929612pfd.153.1469829412912; Fri, 29 Jul 2016 14:56:52 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 195si20379500pfz.17.2016.07.29.14.56.52; Fri, 29 Jul 2016 14:56:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754146AbcG2V4v (ORCPT + 8 others); Fri, 29 Jul 2016 17:56:51 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:34905 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753882AbcG2V4u (ORCPT ); Fri, 29 Jul 2016 17:56:50 -0400 Received: by mail-pf0-f175.google.com with SMTP id x72so36270832pfd.2 for ; Fri, 29 Jul 2016 14:56:50 -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=p7mwcQeyz699n3i9w5nKy6Oi2cmU9uKJsl3WYXyBjFg=; b=PtVmMmRKgm8C4qeQKQEdO8eDROktNka4vgLxQwA/5QTfAF0nJJ5Feo1hM5nWmk60C8 Ou/SbhclVwlND8z4oy2129onU3VTstEAT06a8SsVCa86Q5czlGH5Qm1VxRgdvf2UigrE SZ0ZuaVdZibCBvKT/YMblZ9fKv3GBLhfEffKE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=p7mwcQeyz699n3i9w5nKy6Oi2cmU9uKJsl3WYXyBjFg=; b=fpA/OKjrKt93RV5Nk6hLtGKF8+D66zrf8fG/nVHPon2bEfD69bhr+JSMUf0NrKsvwN t9IzjrQ/Ku/eceFZrumDzNoxOY00BGPl0/FDVKPhujGe1reZoBxVuQ8rwzrfBfMhNQ5F QLF4vb1NzBbJR2mxDqRwJ30AsHtNOHEMoRU1uDFC3mmwKhw9OTYkOObHQAiqsq4mMZmq xVG1f8Z5OAlu08b1kTaMkMchhG+UYbkKl5z31VuK7tFHL6aGfA9eC8b8RPU7vctaXEBe haEw2G7QPx9fOOw3uCrtTCgdVXHRSlSNfM2h8tgvO637cRmzHU8BFc4ixXeJDJPSI316 WlpQ== X-Gm-Message-State: AEkoouvXWLt5IHjuNwos7JPry1dycdL6MI845MNCcJs8uFaVOyHsFqDXReTdQic+qbm8SCGH X-Received: by 10.98.41.195 with SMTP id p186mr70449869pfp.81.1469829410192; Fri, 29 Jul 2016 14:56:50 -0700 (PDT) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id 81sm27196601pfm.90.2016.07.29.14.56.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jul 2016 14:56:49 -0700 (PDT) From: Lina Iyer To: ulf.hansson@linaro.org, khilman@kernel.org, rjw@rjwysocki.net, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: andy.gross@linaro.org, sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org, Lina Iyer , Thomas Gleixner Subject: [PATCH v2 08/14] timer: Export next wake up of a CPU Date: Fri, 29 Jul 2016 15:56:19 -0600 Message-Id: <1469829385-11511-9-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1469829385-11511-1-git-send-email-lina.iyer@linaro.org> References: <1469829385-11511-1-git-send-email-lina.iyer@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Knowing the sleep length of the CPU is useful for the power state determination on idle. The value is relative to the time when the call was invoked by the CPU. This doesn't work well when there is a need to know when the actual wakeup is. By reading the next wake up event of a CPU, governors can determine the first CPU to wake up (due to timer) amongst a cluster of CPUs and the sleep time available between the last CPU to idle and the first CPU to resume. This information is useful to determine if the caches and other common hardware blocks can also be put in idle during this common period of inactivity. Cc: Thomas Gleixner Signed-off-by: Lina Iyer --- include/linux/tick.h | 7 +++++++ kernel/time/tick-sched.c | 11 +++++++++++ 2 files changed, 18 insertions(+) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/tick.h b/include/linux/tick.h index 62be0786..92fa4b0 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -117,6 +117,7 @@ extern void tick_nohz_idle_enter(void); extern void tick_nohz_idle_exit(void); extern void tick_nohz_irq_exit(void); extern ktime_t tick_nohz_get_sleep_length(void); +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); #else /* !CONFIG_NO_HZ_COMMON */ @@ -131,6 +132,12 @@ static inline ktime_t tick_nohz_get_sleep_length(void) return len; } + +static inline ktime_t tick_nohz_get_next_wakeup(int cpu) +{ + return tick_next_period; +} + 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; } #endif /* !CONFIG_NO_HZ_COMMON */ diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 536ada8..5c7ac17 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -979,6 +979,17 @@ ktime_t tick_nohz_get_sleep_length(void) return ts->sleep_length; } +/** + * 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