From patchwork Tue Mar 1 21:15:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 8470321 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E6C9E9F8A8 for ; Tue, 1 Mar 2016 21:16:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 189FA2034A for ; Tue, 1 Mar 2016 21:16:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 391FB20304 for ; Tue, 1 Mar 2016 21:16:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753640AbcCAVQP (ORCPT ); Tue, 1 Mar 2016 16:16:15 -0500 Received: from mail-pf0-f169.google.com ([209.85.192.169]:36254 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753317AbcCAVQO (ORCPT ); Tue, 1 Mar 2016 16:16:14 -0500 Received: by mail-pf0-f169.google.com with SMTP id l6so22277670pfl.3 for ; Tue, 01 Mar 2016 13:16: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=oI/zILOfCA6m2YRTcSDJlKn+Y1H8z9kVBHMdazwbYcM=; b=EfpFa3SwmEj5LpXV2kuzvUWllWP7ilzh8BnHMDzeH/leUYLKbP6Qa/oZbT6mrcUigU Q3gBGOMHz1hteCUKb0VFpUhfTdIsQxD3lhRxR5rRmAihXfLD0KYVBfoDHu/fR7qaltpu eOAqGfvr5HbKQ7DFL/IBJ2CmYCP82iyE+HAN8= 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=oI/zILOfCA6m2YRTcSDJlKn+Y1H8z9kVBHMdazwbYcM=; b=A1sTyfgJq6lpIcmM83kstxKL/TcR9GnnQOc9zNjyLsOKNGCVDEKnf5CvIVFdAN4TvD 2K8kcf0sSLi8Naz8gIy1NKYlRHWPTbkaOermsFbelTzh8AZorai4Iy304ezNrK0EvaIE kpxBqorj8zf1pvqSr9MnNLdBwihGFGoPfdqcDE3GbVz4jrV7+0FEIxVLbH9gL50zJjHd n53Wcm7YLHM0jDPGgkGVp5rCFsXXeln7iBdKSPtbbm4WGLTbutWrXxOaNqzjt71hcejo KOBZa29I9mGALzH7mJru+Xha696spSPY1WRE6A+o3MYYwrlkNfOtzyVnyPwgShbg4EGB zxiA== X-Gm-Message-State: AD7BkJLWxfFtYW9wlLAS81FcMHKf7/iuhJ56SzsksQPw5z084DdktrZSxk28qDmrM+FqGdyF X-Received: by 10.98.7.14 with SMTP id b14mr33637258pfd.40.1456866973682; Tue, 01 Mar 2016 13:16:13 -0800 (PST) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id kw10sm47749328pab.0.2016.03.01.13.16.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Mar 2016 13:16:12 -0800 (PST) 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: geert@linux-m68k.org, k.kozlowski@samsung.com, msivasub@codeaurora.org, agross@codeaurora.org, sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org, lorenzo.pieralisi@arm.com, ahaslam@baylibre.com, mtitinger@baylibre.com, Lina Iyer , Thomas Gleixner Subject: [RFC v3 05/12] timer: Export next wake up of a CPU Date: Tue, 1 Mar 2016 14:15:24 -0700 Message-Id: <1456866931-37851-7-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456866931-37851-1-git-send-email-lina.iyer@linaro.org> References: <1456866931-37851-1-git-send-email-lina.iyer@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Knowing the sleep length of the CPU is useful for the power state determination on idle. However, when the common sleep time between multiple CPUs is needed, the sleep length of a CPU is not useful. 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 | 10 ++++++++++ kernel/time/tick-sched.c | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/linux/tick.h b/include/linux/tick.h index 97fd4e5..b8a2e06 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -104,6 +104,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 */ @@ -118,6 +119,15 @@ static inline ktime_t tick_nohz_get_sleep_length(void) return len; } + +static inline ktime_t tick_nohz_get_next_wakeup(int cpu) +{ + ktime_t len = { .tv64 = NSEC_PER_SEC/HZ }; + + /* Next wake up is the tick period, assume it starts now */ + return ktime_add(len, ktime_get()); +} + 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 0b17424..f0ddaec 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -888,6 +888,19 @@ 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 + * + * Called with interrupts disabled on 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