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: 7642871 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 33210C05CA for ; Tue, 17 Nov 2015 22:38:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 41EAE20523 for ; Tue, 17 Nov 2015 22:38:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 382332051F for ; Tue, 17 Nov 2015 22:38:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932573AbbKQWis (ORCPT ); Tue, 17 Nov 2015 17:38:48 -0500 Received: from mail-pa0-f42.google.com ([209.85.220.42]:35047 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932543AbbKQWir (ORCPT ); Tue, 17 Nov 2015 17:38:47 -0500 Received: by pacej9 with SMTP id ej9so22075227pac.2 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=EISgFppcDll5BUhQRt/yuUnb0yMeb6u05hkkk4TRzkyxQJnTlBnNJdMjaEpoDjoUuO tad0j456npqfGr/YJ7Xrw7NPLWeH0Q8FgEQeEpDlKX3SIZ2X5NduNXEcNeOXSy8qNs/l QyNnUxYxcr2zKFOCp02HSIRk8kqeHt5fApetDVRB1oWqLxz3wYaK/LnKU380V+GZvVna imbuU/4mtdSWbdAhNWj3JqZeTj1EpRkreMTeshWFMIEuCgN5P3tbRJC+ZATpwgHBAOHd z4AzLzBgfbPnq6CSU3y8LiZr8pYQt7DiZt+ipifo9LJyULJ7W9fPbuPHAd4RO1ZESly+ MGoQ== X-Gm-Message-State: ALoCoQlVjQRqE7KEP8bXWn5S2Cp/KvM6qe3o9X3M8v+W8sp70705315H2Z3JXcvZtB/Xw0hDYLbW 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 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: [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> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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