From patchwork Tue Nov 17 22:37:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 7643401 Return-Path: X-Original-To: patchwork-linux-arm@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 C88BA9F2EC for ; Tue, 17 Nov 2015 22:53:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DF293205B1 for ; Tue, 17 Nov 2015 22:53:46 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 0059F2058A for ; Tue, 17 Nov 2015 22:53:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zyp6J-0003zu-P5; Tue, 17 Nov 2015 22:51:47 +0000 Received: from mail-pa0-x22b.google.com ([2607:f8b0:400e:c03::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zyoty-0005a3-Qi for linux-arm-kernel@lists.infradead.org; Tue, 17 Nov 2015 22:39:06 +0000 Received: by padhx2 with SMTP id hx2so22138330pad.1 for ; Tue, 17 Nov 2015 14:38:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jKpDUv01QJVbMTwxRj074fa1+bBNrUcQXzx2oobJVBM=; b=flpUyjj5F98KJJObo7b+MRvgRolrBCmA6YfyTblboJlZ1qR5w2x6Jjkqg56O00wEWJ jdE16Lo26QLtEp8o3wVZHhMVAA4wfgyy5nERwVTqRqZSH94zhGEwtxhAeBrcLUgB8kZ2 mkAYMyV0b+wkEJhPnya5mPj3Odz1F6E/ryVroMy9DmVKfkF8fnsf4ZTQYB4EX7Aox3vq nGNvwyog152oAcFNQbq5U5TQaeA/IAx7TZeHQUr/TUU0HGvIdekMMBx/RmlJh6ILkJGi 9JxI1HBX7lUnWj0TlVveGCvDVqZkqMmdbnPuVcuhN3opk4t7P0F6UmgNUiJqZHkCc6hy HR3g== 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=jKpDUv01QJVbMTwxRj074fa1+bBNrUcQXzx2oobJVBM=; b=ZWV+t3AbJD7hFVxtWDgUoLWnxIY86jizCe0I5THrtlrAOzDgcIFQZdroJpZXANeQzz m6IEyhD/CMvkzrzP0c+8T9+hndoUvDmq8FsfKBHwmaaz5YoIfXNJunJduZ0s8+246pkw 83E7WCD+4jLTrEL3dQnwBns5iajpv99VAFOc+bG9AhW4tZyZNF3VlY8oOMkIA3sJhNbh Goi3/fxgr+9b4ljY45CHfDmSrrI+Lf6n7j5Yz+ipdFe7FQztnUl0Ae1QWIpJTbstpbUd mo7aCgE4TmFmXgXypQChtzJwnqIXzjm+M5a1i/ztE5CmM/6BZ7Jv79YDeWOqahgGGaOv Ks2w== X-Gm-Message-State: ALoCoQmEA4joEvrcVFNiES1uret94yV/wOPaTGA6SX09mFouEC8/wmt5idYRlm1pfUcUe9VGs1dW X-Received: by 10.68.91.228 with SMTP id ch4mr66204996pbb.41.1447799926970; Tue, 17 Nov 2015 14:38:46 -0800 (PST) Received: from ubuntu.localdomain ([8.42.77.226]) by smtp.gmail.com with ESMTPSA id hy1sm14875199pbb.63.2015.11.17.14.38.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Nov 2015 14:38:43 -0800 (PST) From: Lina Iyer To: ulf.hansson@linaro.org, khilman@linaro.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC 14/27] tick: get next wakeup event for the CPU Date: Tue, 17 Nov 2015 15:37:38 -0700 Message-Id: <1447799871-56374-15-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447799871-56374-1-git-send-email-lina.iyer@linaro.org> References: <1447799871-56374-1-git-send-email-lina.iyer@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151117_143903_173951_1EB68605 X-CRM114-Status: GOOD ( 13.82 ) X-Spam-Score: -2.6 (--) 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: k.kozlowski@samsung.com, lorenzo.pieralisi@arm.com, ahaslam@baylibre.com, linux-arm-msm@vger.kernel.org, sboyd@codeaurora.org, msivasub@codeaurora.org, geert@linux-m68k.org, Lina Iyer , agross@codeaurora.org, Thomas Gleixner , mtitinger@baylibre.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,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 CPUidle governors use the sleep time of the CPU to determine the idle state of the CPU. However, to determine a common sleep time between CPUs that enter idle at different times, the tick_nohz_get_sleep_length() API is not very helpful. Add API to read the next event for the CPU. The value can be evaluated at any time to determine the remaining sleep time of the CPU. Cc: Thomas Gleixner Signed-off-by: Lina Iyer --- include/linux/tick.h | 10 ++++++++++ kernel/time/tick-sched.c | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/include/linux/tick.h b/include/linux/tick.h index e312219..6db3e52 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -103,6 +103,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(void); 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 */ @@ -116,6 +117,15 @@ static inline ktime_t tick_nohz_get_sleep_length(void) return len; } + +static inline ktime_t tick_nohz_get_next_wakeup(void) +{ + 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 7c7ec45..e130edd 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -870,6 +870,14 @@ ktime_t tick_nohz_get_sleep_length(void) return ts->sleep_length; } +ktime_t tick_nohz_get_next_wakeup(void) +{ + struct clock_event_device *dev = + __this_cpu_read(tick_cpu_device.evtdev); + + return dev->next_event; +} + static void tick_nohz_account_idle_ticks(struct tick_sched *ts) { #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE