From patchwork Thu Nov 29 17:46:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 152428 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2671988ljp; Thu, 29 Nov 2018 09:47:14 -0800 (PST) X-Received: by 2002:a19:c70a:: with SMTP id x10mr1627490lff.88.1543513634108; Thu, 29 Nov 2018 09:47:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543513634; cv=none; d=google.com; s=arc-20160816; b=tGro9WjHfg+S3ueLVhqXhxRMrxRxE1n+RggT2vyuA/ag14hU0YcmIJGeWxKtR+PLcv 7ncJ+qLdt4ryqrrUMbBYl6AaHTYMXt/+xqV7uu6VzqH6KFofTQ9EuprEyJ/jHhxNyQ2i lOwMB806jfv0feeK/R5eGosiUQfmablNx4VnoM0ji53RvLDL1ab6a+UanekWxPmQ5TbB EGMo9GWnjt6GqzMXBpubFSD+sLcpJ3xHPXoSDpjDt919zkndKiCUu9fI9X7twiKAOfos E8L6IOk4GAidrrcP6EI5gSKqswKgasnutWojA2K5lJiQzHG4GXrJxb76jhESe7pNshsJ ewaQ== 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; bh=We8CaGvJmbhYNYzrL7xua655X98bhiXXYfxMtnIUbcg=; b=Z6zifB8O3eKB3AoOz1gezDfJGF5Lo+C5I3BAEIvFHoWWoV6cD6AvVJynUdVdjA529/ 08NiS1o5jUhLcAQAoJYy3QAbTJ5rQjJQGKtfBscwRdPB18XttlQEnV1QWhBRfs/FRPKU xgyeR/U5KOenVuXnE371YtBSCOOHgpOJm1ubY7MP1QXpS3j7NQSeRH8DgFjPVKeOe4CL yCrVaxNh4LrL1lnFMWJoyKaLeOHszyvmGG9SsX9uW33q3sCHjcR9UTkDJO362LDGdNf0 xrPTFpVLnefQLodj+KBjPe8d7FEF/HyoIZc9XVMSsOweSS/SEphKlYcLxYgTTL72NaFn 6aXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="CxUDChM/"; 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 z23sor789334lff.41.2018.11.29.09.47.14 for (Google Transport Security); Thu, 29 Nov 2018 09:47:14 -0800 (PST) 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="CxUDChM/"; 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=We8CaGvJmbhYNYzrL7xua655X98bhiXXYfxMtnIUbcg=; b=CxUDChM/RBvhrA31XzUsCNP+4FezP+eXEflQmQnd54XH4DLPYar6y05JtbZh1VkOR9 SkqR/CZFgNzntsxd4Oe81r1RyldMKKKEpGM2IwKlpysWwwEyVbXW691jkPCx5rLzQP/r x2cpT4wVVole1llA1ynH/xIBV8qW3U8BBRoCI= 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=We8CaGvJmbhYNYzrL7xua655X98bhiXXYfxMtnIUbcg=; b=ofG72NCgqVGehuF9h6OILdkInSFmbTxV/aSRCmSNX2g8bBVt7rAW4vn4hW4ZYYZRCp 5Fh5Bo2zLDD8LEPQEjLsDBBGORFD8HqWCkEYQKB/ZydUj85is7krHFRE1kWNVNuyHUjU qytGoPOHhZUqUL4tK/f3cv+EVbagOkIS97OJWyr+s+sjtUC77KGPAXg361NiNKeOQlwy nXafaqoT+OEYcoXYTh+nrSg0ai/kAxdvcDPOGq3vXy21CzsIbxuhul+XXdvxG0Kg8W9p kYFWaZ3VovVi4YOhxtAX6YuAG6jCVOEAjMiZC+zt5olb0q/up5t95jjt214bvMpD/joY 1LfA== X-Gm-Message-State: AA+aEWaWvDJliuyk5JtsXhwjb1mkS1IcNwCEghPV9ZLEUn96Z18IX9rY iUHoHW3qAxT6hYUlsJvhmzFAlOHy X-Google-Smtp-Source: AFSGD/X5ijktJZyrJe4NVc5D4Xj3iZjspHtp3e2YPqQ10kRYH3SesOqeSLOZT9YaqgkfpSVEiZRWsQ== X-Received: by 2002:a19:6806:: with SMTP id d6mr1607974lfc.48.1543513633779; Thu, 29 Nov 2018 09:47:13 -0800 (PST) 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 j76-v6sm393983ljb.12.2018.11.29.09.47.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:13 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Lina Iyer , Thomas Gleixner , Frederic Weisbecker , Ingo Molnar Subject: [PATCH v10 03/27] timer: Export next wakeup time of a CPU Date: Thu, 29 Nov 2018 18:46:36 +0100 Message-Id: <20181129174700.16585-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-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 --- Changes in v10: - Updated function header of tick_nohz_get_next_wakeup(). --- include/linux/tick.h | 8 ++++++++ kernel/time/tick-sched.c | 13 +++++++++++++ 2 files changed, 21 insertions(+) -- 2.17.1 diff --git a/include/linux/tick.h b/include/linux/tick.h index 55388ab45fd4..e48f6b26b425 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,13 @@ 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) +{ + /* Next wake up is the tick period, assume it starts now */ + return ktime_add(ktime_get(), TICK_NSEC); +} + 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 69e673b88474..7a9166506503 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1089,6 +1089,19 @@ 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 + * @cpu: the particular CPU to get next wake up for + * + * Called for idle CPUs only. + */ +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