From patchwork Fri Feb 12 20:50:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 61889 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1056109lbl; Fri, 12 Feb 2016 12:51:40 -0800 (PST) X-Received: by 10.98.10.86 with SMTP id s83mr5072392pfi.85.1455310289406; Fri, 12 Feb 2016 12:51:29 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b27si22128384pfd.82.2016.02.12.12.51.29; Fri, 12 Feb 2016 12:51:29 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751082AbcBLUv2 (ORCPT + 7 others); Fri, 12 Feb 2016 15:51:28 -0500 Received: from mail-pf0-f169.google.com ([209.85.192.169]:34178 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751016AbcBLUv1 (ORCPT ); Fri, 12 Feb 2016 15:51:27 -0500 Received: by mail-pf0-f169.google.com with SMTP id x65so52983898pfb.1 for ; Fri, 12 Feb 2016 12:51:27 -0800 (PST) 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=JdwV59Mr9zc6V6lqdT4XAPyzCzJVVJRH3T1LlDKeRG4=; b=CULj1mQGg+0WaRt2j5FZYH+jc1I0VJYpb/i4FDRFpd8TAV8krpG3/USy9UHesPizw0 QNJYHLLdFktGvqWFB2VMYI9Eyq5D4/aYeE1GV28No4bexaTfgiq3Xno4c1Tlq/HtcOw4 ne3GdGtvHXNvef+LTdk82oYkDnFvrNh9V9WDA= 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=JdwV59Mr9zc6V6lqdT4XAPyzCzJVVJRH3T1LlDKeRG4=; b=FbamA5C5PR00RHcr4j3L68rx9hJFVAo+2IoVd5yL7CXf/3D/+9Bg6CgooMAEY0DAov auKntlJrwrBEnn5DBvpeU6AnsR43pSDCdtuhXXwJzDisWiU50BVGeNcqJrJcM8Bd5Pmw bUF8q9Ni1P/cqViDtJa2AZL4FZjxWvoeoP32Apkq8Uh1YXX14Bfh8Nqlnm61nXkw1hCs 6oldwRmicp9NXKLuRgSTwogVLzuyTkSQRcqwWzPRuD8XS/vuZuFEKy44K1InZ90XjM08 LF2V1tGfelfdO4EEsptNJmJEOi17sVSfTi+K4Uy1FQiMtTXCJPXMj3xxAmDjoF3lWxSY dQ0Q== X-Gm-Message-State: AG10YOQhfo1fOqH/Tcfpc9b8BRhxcve6HXTQb3HO8BQOrxFR46epRmiww5u06eBGJEIVOBx6 X-Received: by 10.98.74.144 with SMTP id c16mr5056330pfj.129.1455310287293; Fri, 12 Feb 2016 12:51:27 -0800 (PST) Received: from ubuntu.localdomain ([172.56.8.98]) by smtp.gmail.com with ESMTPSA id x12sm21401070pfi.88.2016.02.12.12.51.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Feb 2016 12:51:26 -0800 (PST) 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: 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: [RFC v2 05/12] timer: Export next wake up of a CPU Date: Fri, 12 Feb 2016 13:50:31 -0700 Message-Id: <1455310238-8963-6-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455310238-8963-1-git-send-email-lina.iyer@linaro.org> References: <1455310238-8963-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 Knowing the sleep length of the CPU is useful for the power state determination on idle. However, when the common sleep time between multiple CPUs is needed, the sleep length of a CPU is not useful. 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 --- Changes since RFC v1 - - any CPU can access this variable if that CPU has IRQs disabled include/linux/tick.h | 10 ++++++++++ kernel/time/tick-sched.c | 13 +++++++++++++ 2 files changed, 23 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 97fd4e5..b8a2e06 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -104,6 +104,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 */ @@ -118,6 +119,15 @@ static inline ktime_t tick_nohz_get_sleep_length(void) return len; } + +static inline ktime_t tick_nohz_get_next_wakeup(int cpu) +{ + 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 0b17424..f0ddaec 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -888,6 +888,19 @@ 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 + * + * Called with interrupts disabled on 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