From patchwork Thu Aug 25 20:03:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 9299869 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 63F25607D8 for ; Thu, 25 Aug 2016 20:10:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5279D292E8 for ; Thu, 25 Aug 2016 20:10:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 431E1292EB; Thu, 25 Aug 2016 20:10:03 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BFE5E292E8 for ; Thu, 25 Aug 2016 20:10:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bd0wz-0000rK-LJ; Thu, 25 Aug 2016 20:08:33 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bd0t5-0005U5-4s for linux-arm-kernel@bombadil.infradead.org; Thu, 25 Aug 2016 20:04:31 +0000 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]) by merlin.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bd0t3-0000O1-Gm for linux-arm-kernel@lists.infradead.org; Thu, 25 Aug 2016 20:04:30 +0000 Received: by mail-pa0-x22e.google.com with SMTP id fi15so19725698pac.1 for ; Thu, 25 Aug 2016 13:04:08 -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=UY3yPwmc+aWh/kHHpsiaK6IQItZLfd4zQ5Wpxg/+gnIn6pPVqMdQ3UU5qncQgnuhpI ydZ2zVgHzaYmfNgFBUmBHABkHJHmkrB6f1D6nki08b0paDgd+nTcNr5MhnR4daCZbN0H ezG6nCBIm2C++9LYQ/KZUuTMH6Jiz5po0kLNI= 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=YxK/LgmVJpmJOMbt/kSrwvUfwKSHsAMhLFn+XJDs2bvOrE12elmNKKZC9k08N7gOKO 6b4xIPlkadilYZ+PmmP7oQ2PsVTQPj3SS3I6w4Ikas3D6xGQCtP6m1QGPfHxA0ZIVhfz QkAVypSIqvozzj6t7umvdZ8hs8UVDrJRXCGGzLv2NHJw9MMeNaujFz1eksdTw5N2lT33 SjkvQQDYL48fJP+EJFE2BTl6B1e2HsSeRBoJkZPGGnSNkSMnvPz89UZ5s4jA1Pe63TiO T//4eWgXRCdML5aj2gYUOsS9nf4V3KXJb1Yab9EDaEZww4/Pjy7CLURooi/8T4ideZXU QNNg== X-Gm-Message-State: AE9vXwMnn+HAcVDRHzF3E1GfXtniMX55OsRn8cwhwQBbM76sgfVjjsOw+ItPr3kMKLF2Opf4 X-Received: by 10.67.15.8 with SMTP id fk8mr19550834pad.19.1472155444056; Thu, 25 Aug 2016 13:04:04 -0700 (PDT) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id u1sm22841644pfu.12.2016.08.25.13.04.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Aug 2016 13:04:02 -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 Subject: [PATCH v4 09/16] timer: Export next wake up of a CPU Date: Thu, 25 Aug 2016 14:03:18 -0600 Message-Id: <1472155405-41841-10-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472155405-41841-1-git-send-email-lina.iyer@linaro.org> References: <1472155405-41841-1-git-send-email-lina.iyer@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160825_160429_648146_9AA982D4 X-CRM114-Status: GOOD ( 13.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lorenzo.pieralisi@arm.com, Juri.Lelli@arm.com, linux-arm-msm@vger.kernel.org, sboyd@codeaurora.org, brendan.jackman@arm.com, sudeep.holla@arm.com, andy.gross@linaro.org, Thomas Gleixner , Lina Iyer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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 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