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: 8297501 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 9E31C9F372 for ; Fri, 12 Feb 2016 20:54:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B527320444 for ; Fri, 12 Feb 2016 20:54:31 +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 850FB2042C for ; Fri, 12 Feb 2016 20:54:30 +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 1aUKi1-0007SV-Df; Fri, 12 Feb 2016 20:52:57 +0000 Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aUKgu-0006UO-2b for linux-arm-kernel@lists.infradead.org; Fri, 12 Feb 2016 20:51:49 +0000 Received: by mail-pf0-x229.google.com with SMTP id e127so53011942pfe.3 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=Va4odjE6Epj/Tx96xVCfyqujdVsBzr9bDE0uPSKCUT7TQKf+OqrLfyvcFOmAUiArSD bTCs1/2yue8a6XJ6VxqgqzS09zkKJW3oqU+ZfjyT+q8mVDIM5onCfhHXFtiSEVMQ5piV Q9wRFQwjE4KEa+aapNjr9cDWPvLnrNuyW4nYHbgj9tEoQDwCqg8yRa8hoFdSKUOPEHK7 ebA52cgs14ZKfoNBglNgx/A1ugNOXiiwKn8aDlc6sSVibf9zSb6jtzxNxWXKC34PNEkl 3Y8R0Vjdll0P8Hxtthi/f5SRya9TbOY41gaa1cpIAlbF7dKtf2UR3FQZyJLE3YkONHYl AreQ== X-Gm-Message-State: AG10YOR8iMVevENKWB2ajqQ9rH98NZlEhFrMgYQ2bzojFGuIgkKDL/DYvV5Zu6rGIrWWIaqA 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160212_125148_263564_A72472D6 X-CRM114-Status: GOOD ( 12.90 ) X-Spam-Score: -2.7 (--) 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.2 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 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(+) 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