Received: by 10.192.165.156 with SMTP id m28csp1832461imm; Thu, 12 Apr 2018 04:25:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+9x/JZKOd+p667KQxNSGuAhFuFpgqie0Bby3m33M+VzpVDGkGatn7Nh4XKwYhRL08Nqd0F X-Received: by 10.99.126.92 with SMTP id o28mr415220pgn.50.1523532301185; Thu, 12 Apr 2018 04:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523532301; cv=none; d=google.com; s=arc-20160816; b=RWc6n5tZUsdyxcO5KodUSsla3k1lGyxr1HfuTREnJ68aa4790D6/oR++RXhia36IGl 6Dism4oC/UbJml5m+JLZL6zmGwfPuKH7oZYcvMRXlL4Tnyv3GpOtkOz3MBQ9fqPuIHHC O5l9u9xKBuvkdeaHpvwPFQQQw1V6+xj362d/s+RyHlUnPJ+30MmPK75mvL+o9hYMDlYH j4G3Rwm+li0G1mBP3TguxY7DHgKryRG0AakIc4wqu5av31VXRhV0sW9Af7JkJWmj9bS0 2mbkhmobf8X7sNCBKBBnd0X46f2Wjr9KD/lJxL1Ewb77Cc1uy/xsUEUaiD8RMGp1Bbw1 OfEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=VN7v+B4AGDaJ9ZxTUGLB9zWuv/2axGua2g5DbB4+qJo=; b=XiPRvh7Uype71bN3jV+rc+7kB2Y/0SEJ7AiFtYNiMHmcl7vkbzEp3swU4YtxgFDZYW Ioe4KNpqZ/f4GtR8RWe90+nAqBAn6Lr9ps3/FlqvXhP4L5utvgBCqPShqD22UJePQIPy gMkMN8MNOd2FxdPbXk+Ha8bwe53l/DMyRGUeCKNmOLh8QUEEHlMcsFuQRCqo+thXQF0a qd7SS1yTUu0N109jcsDmN+NDdpTrlG3UhppGRhEou+qlTQRsWP87H/CqhGD1IvyU4D4j mIvu1UofjjxebooH9tt5VZ8hQCG4rpTQduUFH90Qoy26j0REByRS7qX8IimrrruiL9Xh adhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LrECZnYd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l75si2443259pfj.375.2018.04.12.04.24.24; Thu, 12 Apr 2018 04:25:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LrECZnYd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753413AbeDLLUJ (ORCPT + 99 others); Thu, 12 Apr 2018 07:20:09 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:45674 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753061AbeDLLOu (ORCPT ); Thu, 12 Apr 2018 07:14:50 -0400 Received: by mail-lf0-f67.google.com with SMTP id q5-v6so7096640lff.12 for ; Thu, 12 Apr 2018 04:14:49 -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=VN7v+B4AGDaJ9ZxTUGLB9zWuv/2axGua2g5DbB4+qJo=; b=LrECZnYdgZ/2TmHf7jVrqc/fy5ZNRPebc9lVJniSXt3y4ekCcN3sD8U5b9q0xVxGyn KXALMYR1RfD0xwQFJXvIZzvcvs2W+0BV0cbGOawdtrONqYT0OcQVKXotAlOci/XmzH+A SZTOB/R51ax7CMsrvSjQulMt6fABENzAjDry4= 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=VN7v+B4AGDaJ9ZxTUGLB9zWuv/2axGua2g5DbB4+qJo=; b=qBxHPZlx//QsfUlFo9VBb47OE7wUamL6Ox2tU+Wl7KtyK4fjnp2WNIAL6NV3f7VICg 6Cso/a5wXO3s6Ag476JGJM/4x3ay8V2Mey85UKC/P6tMdv0nffVQ4NrsaTqF6HooebOs SgHEIlW2pTUBMaLNuM7kmGYab9niqgssC9d3RZh6SfJPbUw1e6B9ddV3QetsmrqRgMYN hnj6t7my81HoXaoDgD47AoOKjtN4J87WIwSuOCDYXMeTre2FgSjr5Ujck/TPeMN1sL3P HlcV5QnXb6PMDtHKXNCnu/PcrIVN+khfw36eTRquZdrYGc5uM8W+v+gnuVnvVDkroAzj tGAg== X-Gm-Message-State: ALQs6tDR6uXI2CGyukZ5ZBjEYPl7Ig3jUxJ3o9Pgda1oR0cf6WCno/3v GuzVNubTEj5ZX7iFb26CM/Hefg== X-Received: by 10.46.32.154 with SMTP id g26mr365887lji.71.1523531688934; Thu, 12 Apr 2018 04:14:48 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.14.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:14:48 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Frederic Weisbecker , Ingo Molnar Subject: [PATCH v7 06/26] timer: Export next wakeup time of a CPU Date: Thu, 12 Apr 2018 13:14:11 +0200 Message-Id: <1523531671-27491-7-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lina Iyer Knowing the sleep duration of CPUs, is known to be needed while selecting the most energy efficient idle state for a CPU or a group of CPUs. However, to be able to compute the sleep duration, we need to know at what time the next expected wakeup is for the CPU. Therefore, let's export this information via a new function, tick_nohz_get_next_wakeup(). Following changes make use of it. Cc: Thomas Gleixner Cc: Daniel Lezcano Cc: Lina Iyer Cc: Frederic Weisbecker Cc: Ingo Molnar Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- 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 389aa25..d341811 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -125,6 +125,7 @@ extern bool tick_nohz_idle_got_tick(void); extern ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next); extern unsigned long tick_nohz_get_idle_calls(void); extern unsigned long tick_nohz_get_idle_calls_cpu(int cpu); +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); @@ -151,6 +152,15 @@ static inline ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next) *delta_next = TICK_NSEC; return *delta_next; } + +static inline ktime_t tick_nohz_get_next_wakeup(int cpu) +{ + ktime_t t; + + /* Next wake up is the tick period, assume it starts now */ + return ktime_add(tick_nohz_get_sleep_length(&t), 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; } diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 646645e..08db7f3 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1098,6 +1098,17 @@ unsigned long tick_nohz_get_idle_calls(void) return ts->idle_calls; } +/** + * 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 -- 2.7.4