From patchwork Fri Aug 26 20:17:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 9301973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6D13D60B16 for ; Fri, 26 Aug 2016 20:18:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F93929649 for ; Fri, 26 Aug 2016 20:18:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5280229657; Fri, 26 Aug 2016 20:18:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC0FD29651 for ; Fri, 26 Aug 2016 20:18:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754185AbcHZUSp (ORCPT ); Fri, 26 Aug 2016 16:18:45 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:34799 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754142AbcHZUSk (ORCPT ); Fri, 26 Aug 2016 16:18:40 -0400 Received: by mail-pa0-f41.google.com with SMTP id fi15so30162700pac.1 for ; Fri, 26 Aug 2016 13:18:39 -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=+Gh03scdBX+vQSoEbthZrL7lCl1gOAc/8ZUQE2+ADY8=; b=CQr0kZi2crdNPd5WqaUnR38Tgy+2hpBRtKCUkxX9CHHjo//MTGxBy2FtaJnldku49i UPcJ/qD3Dt9xm42e6vRc0OlOR7sGxsobyL6EIGnt0OGtdqyscIsQqycmXpuN5C5pbXvZ QqK6WOuSVmmjxu3t2Eh6x/kX1DO0iT3DLhC8A= 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=+Gh03scdBX+vQSoEbthZrL7lCl1gOAc/8ZUQE2+ADY8=; b=LwaiKFTWRXFp98P0TXc/zcZOeeU8PU56FYbU4EKeS6W4dhNHwJmuMA0v1nLD8tRq1Y kuMxFKmbG668GQiEVpQzspdvBNkiwY+x2yjWmhLy1O61goiBEwivJnCWdCt4C+R5xYn/ NMjkyiFclUywxaPC5JVDICY2lCUUx7D/i46vJnmrSbIFD15XkvWO6/qsRpzmPQF7egIs 7+rt7o7clRDdAtteYkTq+oi2w56xcrof8Odo/kzPEiKuLPeJB5gFCpnWhSBeeCL5CAEB +OyHzZ/3hWZbuSzZ+ONODOp04OHurU9OCL+VR8lSbp7TfpvRKohnMi7/EuuCHh+A+NQ7 5RJA== X-Gm-Message-State: AE9vXwPs3s6APbP1zJy1yLdGAE+knsh38mnENJLDvOdJrUreJ0UdhbZbre7AIbB3aWDiFojI X-Received: by 10.66.76.9 with SMTP id g9mr9073706paw.51.1472242719181; Fri, 26 Aug 2016 13:18:39 -0700 (PDT) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id m128sm30761463pfm.42.2016.08.26.13.18.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Aug 2016 13:18:37 -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, brendan.jackman@arm.com, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, Juri.Lelli@arm.com, Lina Iyer , Thomas Gleixner Subject: [PATCH v5 10/16] timer: Export next wake up of a CPU Date: Fri, 26 Aug 2016 14:17:52 -0600 Message-Id: <1472242678-33700-11-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472242678-33700-1-git-send-email-lina.iyer@linaro.org> References: <1472242678-33700-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-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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 204fdc8..7d8df93 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -990,6 +990,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