From patchwork Thu Apr 12 11:14:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133244 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573534ljb; Thu, 12 Apr 2018 04:14:49 -0700 (PDT) X-Received: by 10.46.144.2 with SMTP id h2mr367718ljg.37.1523531689201; Thu, 12 Apr 2018 04:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531689; cv=none; d=google.com; s=arc-20160816; b=mtDfxSl0IAA4wrUbPmLyTnRzkPkiwojS1p678nMeOP2c/gERB7E2vtO3dJvOXq5YNC vYNBtVyu/z5VNdsX91KyfiGa7VQmiiAFSHLt53sF9CyWWA9inOxJ7DeCOgb6MGPjtJcC S+DbAN46IZPSQiFoRF/IvHQFRZ+42rMjcZD3rz+fzZingiNGONXCKS7NavuxLS+a7183 XK4tDbkG2Q9IppQhAPlXZLOhL77qyIuLffJPgV/EpWO0PFWaXu4hpA4voVl9gBGQ+JLm 7SdSpcACLXJANzRX8J59kYOyGf4olVh1wvnyg5W1K1PYTDaLlb73LLKDShOHJnFbE+Pd cvcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=VN7v+B4AGDaJ9ZxTUGLB9zWuv/2axGua2g5DbB4+qJo=; b=kvhvN67MABlZoCPFfDHQr7nOilS7m2uSXhNTY3WqmpiwmtT0QKCJ/YHY3r9JRIULom LC85UxbKy4PWu8VfR/G3PQv6lOmvajJpyLkrGrwB0/IY9N2g93Ls2onVV/1cZIyHbId2 Pnls3BSwLPrpfBszL3Pjb/90kjMFrslxyQ9MzA/rNn/YaFwGHjY1CuwgB+LUV2Kjj9Ke 0vw0NL7ptrdPbKD8AmTM83KTkKLVy3bZVjbAvMFjZdwaheY9dWbgJop0l4YBPI49txqL lBe7/mfD1cvohy4m73d+9gC9iH71adWiSHQzwWuy5N/jfMHWgwAqFmuX/wITKhO7L5Px 2nFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LrECZnYd; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id x13sor892034ljj.87.2018.04.12.04.14.49 for (Google Transport Security); Thu, 12 Apr 2018 04:14:49 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LrECZnYd; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=tMB/YyNNBlIvBLCQ2ehxSZQOlVqEQckLfWr5LmJ+h9dXEgXVveRjuudaMg3mQvEH5w 3hOPLLSJNGefXkLNnWUkD55ThfSrpJ+3yoIF6RX0MDeiO29AFF4MSuSM1ojGuTAD3mOH JYxeXE+13Iw6xLhhH7/eRJAVJF0Y5lOPhFtZ5t90WETZKtxvEbHQZ9zwu5H/x9jnAoLI pqKgBmbNwCQt7h30UENCT1IV3gJbY9Cnq9cePGeVaponIO1eDB/Hav3J3aOfXFXgbLzg vgAu3dzrw/W3bnxDws5udKiSW9i//Cbyu3KWber4dKmGjUrOwK90gpql8vmRZZQ23Sxw o7lw== X-Gm-Message-State: ALQs6tDn124XT4zcYtb/Jwys+Y7ZmHKmFCw2Y1AoSxNGYiOncKkOF+y8 bWx/t1rWshYnh1TvgEKeIKuIDna2 X-Google-Smtp-Source: AIpwx4+tslMe9H1Owe/SLKdwUAGqpACQFO7hh60OKOG8TltPrcb7bNklVj/aRKOUyLZmDNM34b3KOg== X-Received: by 10.46.32.154 with SMTP id g26mr365887lji.71.1523531688934; Thu, 12 Apr 2018 04:14:48 -0700 (PDT) Return-Path: 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> 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(+) -- 2.7.4 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