From patchwork Wed Jun 22 19:36:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 9193665 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 477D76075F for ; Wed, 22 Jun 2016 19:40:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34E3528402 for ; Wed, 22 Jun 2016 19:40:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 296DF28416; Wed, 22 Jun 2016 19:40:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id AD89E28402 for ; Wed, 22 Jun 2016 19:40:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bFnzk-00032r-TS; Wed, 22 Jun 2016 19:39:28 +0000 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bFnyM-0001bE-Ss for linux-arm-kernel@lists.infradead.org; Wed, 22 Jun 2016 19:38:04 +0000 Received: by mail-pa0-x22e.google.com with SMTP id wo6so19575203pac.3 for ; Wed, 22 Jun 2016 12:37:42 -0700 (PDT) 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=LLehbqXrulYmpeZVUQum/Z+WQPHx0Kv8JNCQ5qekB48=; b=EDu8NOECarpWN7gJghYUflJNoRM4tHSM02ruGxboZ93NcfsCcJky1ZYoWUoqcPLR/F 5FOoRuBgP6KLYYJzmaEsIfemMqQ6czUf7pgEQezLQLVc8H8dRJv4WIsyrKDNV4TzRUIT 1JyBQESvq8OPcMltOS5KmZiEEdrofkrXyokPs= 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=LLehbqXrulYmpeZVUQum/Z+WQPHx0Kv8JNCQ5qekB48=; b=D6sFUbykdCGENbhGt1S+tdrJyJtIaeJMeAJEgDfev6zpwjJlAk4ra7sVzpzKkZD5QO CuMgKb0V5SQ91Nh5jS4eiLTgJnCansYFVJ0ZbmUiq0++bD7y/RRlJNRJjo8zREx+4Hsh cPHunXlLsdtmnE8cMJi5H6VJTOBosp76CFBzJ0BB/hYTTY59lAOhjdlQkrDz7+s3SU4Q vQ1A4hZGcm83RV8DdorlPFYftoFJu+yMfHk/2aOf7kGdCMsmLR8F9qvqlhGPnecufVRu VPWPghlMo/KXm4Ryu9qQohabp8GbnjxeUBxtwKtySC3CUDwbnLTKM4sItRV4co2bDX7v Fm9A== X-Gm-Message-State: ALyK8tL2ikd4L8QZmz8PEHx5zyXaDVOKEli85/U0cQ1FPjqdUbon1y9Te7GW2KrLgTaB/Vpc X-Received: by 10.66.79.2 with SMTP id f2mr30679448pax.14.1466624262114; Wed, 22 Jun 2016 12:37:42 -0700 (PDT) Received: from ubuntu.localdomain ([172.56.9.151]) by smtp.gmail.com with ESMTPSA id t4sm1563368paw.32.2016.06.22.12.37.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Jun 2016 12:37:40 -0700 (PDT) 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: [PATCH 08/14] timer: Export next wake up of a CPU Date: Wed, 22 Jun 2016 13:36:43 -0600 Message-Id: <1466624209-27432-9-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1466624209-27432-1-git-send-email-lina.iyer@linaro.org> References: <1466624209-27432-1-git-send-email-lina.iyer@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160622_123803_109173_94FF47F6 X-CRM114-Status: GOOD ( 12.22 ) 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, geert@linux-m68k.org, Lina Iyer , andy.gross@linaro.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-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 Reviewed-by: Kevin Hilman --- 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 62be0786..9535141 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -117,6 +117,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 */ @@ -131,6 +132,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 536ada8..addf3235 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -979,6 +979,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