From patchwork Fri Mar 3 20:41:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 9603505 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 23CC760414 for ; Fri, 3 Mar 2017 20:44:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1108528555 for ; Fri, 3 Mar 2017 20:44:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0548228578; Fri, 3 Mar 2017 20:44:10 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8033328555 for ; Fri, 3 Mar 2017 20:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=g/IhjlKND70yu1GAP/kLLnmCdA5cHLhe2ertVnwV/nI=; b=NJcT63RsroKhyuUFaUWfRvZ06l 98OgJQvTT1GoJ9LD3dad5ZwW/ETHX0hQOfg5RG2r7BV/Um7jmsq9zxLtP8OMcER8zeCGoPr/jDgf2 YcNGIpKX0aHBKOQvd1lWw5nCt5KFkAkjl0V6gHEGSGxw/XG0vJv6eOOuDekN5ekngPOxC1n7YK8QW 5uRsIKtAB55ass2cC1wKmGUNKmQdH93X+juMTHDbgKS5j8KiUxLajNaU/Ehiw3yTiY9VBDqfTeOSI x7VN+jfVoehW+cMzoGhEY9WI2YZnHwrGn+k1uBe5QPnKpohqyWiF1udTcYkqUc102+zkGIn9gNRRM oTmeW4RQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cju3a-00067k-3D; Fri, 03 Mar 2017 20:44:06 +0000 Received: from mail-pg0-x22a.google.com ([2607:f8b0:400e:c05::22a]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cju1k-0004rH-BP for linux-arm-kernel@lists.infradead.org; Fri, 03 Mar 2017 20:42:14 +0000 Received: by mail-pg0-x22a.google.com with SMTP id 77so3205462pgc.1 for ; Fri, 03 Mar 2017 12:41:52 -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=U+qE9zaF3BN7TiNKr3Pfn4NyoGuMva//UYp+wbkMXd8=; b=d1V19wvAvZ6mDyg86n8TvsHoTIfveOw3ib2Nu6H7p3wn7sd/Lobt//454Y4Ak2xr39 1G+5rMrtL6YO7lJyFBp4kJEF0zSqrnJnHobT118FhQMEm2l++ay5fbbhw+DJ893ovEi+ F76qxePgleM1VRDoWADfJnJMZ6JtNwz07ae7s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U+qE9zaF3BN7TiNKr3Pfn4NyoGuMva//UYp+wbkMXd8=; b=SXu29+F9dZ03Z1zcxwvEX8ACVuN1gVDq+xQ2AqpJNJuc1N781z0+9RBDMCoetDOTt3 UKT+HKoLbMnU3teTz4aS9lsjMi4stSFCEUjBByNbd846Pqdb9ZW9jllIQomaVs8VzVCJ omTKCkEna6FzhiUzKhAZv3wPaasKWRzH5xzttASvdGuVKME745cIE8U/UdLrGeWwg6SR 9uaHL+4VH/tr2N7sRUyKII61IgO1H8XTw9Ws1+8NisHdz038AbJskRWGk+D2VOavN9yh s0ZGkhsK7YJUoa2fBIelbAPglvYMurz4OFEgltag0+HSypWZiKdr+gtRIdsecELwT/rP vvfw== X-Gm-Message-State: AMke39lBr7nFxFZ4MB7zRhpAV/3q9+Q9TkslhsE1flrPRc+jIGq5Jong5VYTjizi5wMHyTe3 X-Received: by 10.98.57.23 with SMTP id g23mr5814339pfa.32.1488573712296; Fri, 03 Mar 2017 12:41:52 -0800 (PST) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id o189sm25207003pga.12.2017.03.03.12.41.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Mar 2017 12:41:51 -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: [PATCH V5 5/9] timer: Export next wake up of a CPU Date: Fri, 3 Mar 2017 12:41:31 -0800 Message-Id: <1488573695-106680-6-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488573695-106680-1-git-send-email-lina.iyer@linaro.org> References: <1488573695-106680-1-git-send-email-lina.iyer@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170303_124212_422433_7CE35D9F X-CRM114-Status: GOOD ( 13.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lorenzo.pieralisi@arm.com, Juri.Lelli@arm.com, linux-arm-msm@vger.kernel.org, sboyd@codeaurora.org, brendan.jackman@arm.com, sudeep.holla@arm.com, andy.gross@linaro.org, Thomas Gleixner , Lina Iyer 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. The value is relative to the time when the call was invoked by the CPU. This doesn't work well when there is a need to know when the actual wakeup is. 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 Cc: Stephen Boyd Signed-off-by: Lina Iyer --- include/linux/tick.h | 10 ++++++++++ kernel/time/tick-sched.c | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/tick.h b/include/linux/tick.h index a04fea1..2416021 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 */ @@ -129,6 +130,15 @@ static inline ktime_t tick_nohz_get_sleep_length(void) { return NSEC_PER_SEC / HZ; } + +static inline ktime_t tick_nohz_get_next_wakeup(int cpu) +{ + ktime_t len = 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 2c115fd..03e7c17 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -989,6 +989,17 @@ 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 + */ +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