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: 56892 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp2218360lbb; Tue, 17 Nov 2015 14:39:16 -0800 (PST) X-Received: by 10.67.4.69 with SMTP id cc5mr66478249pad.142.1447799929068; Tue, 17 Nov 2015 14:38:49 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ax2si60766904pbd.123.2015.11.17.14.38.48; Tue, 17 Nov 2015 14:38:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932573AbbKQWis (ORCPT + 6 others); 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 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(+) -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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