From patchwork Wed Jun 20 17:22:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139374 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050511lji; Wed, 20 Jun 2018 10:22:46 -0700 (PDT) X-Received: by 2002:a2e:9516:: with SMTP id f22-v6mr14487515ljh.9.1529515366131; Wed, 20 Jun 2018 10:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515366; cv=none; d=google.com; s=arc-20160816; b=X78VNyettB7qhBXOi+SppxktW3+j1Zu82ueeoz6uq9YUrE9s8QSGfWiVOVoQ6t0rg7 k1LrPntKBJDaudpW6rxgVgRYoA7rB8RzIkBOya5BefnyOf+0j00KUCSBlBa+Skcmf9kW O6UuR77eaeeaWgRlsJpO6h+8Eq4Wi5sREGHcyoLp9/p9GRX/5SaeuJcjnns3MEsajYkM eC5nxZvQBOornQz5ECB96MIkSKOP/e+tqLaDOdnT+uw/Kc+bXup37KW0JRhN7nAU1W7/ /LeaCzFQFt8aC96cF4Z7Di16NIf1WKcODGq4OqSCG+liVWA8sWqA7vvBYG5HfbsI0v2a Zr4Q== 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=ZU7eQCdNUvVwVHNHQGUhwppj4DPi+mJPY3V/YyeaLt0=; b=07ERcLm4/l9KBIvR0hJYkCSg/Ff9AAYnDyY4er6wGkiEu+Y6fnVcrFxpk61wgSE8GU UgvK5K5YHWLaP8EfcHuO5Q2MYlX95m9ywIs/3rJLb7AXjUS87dCoXr63lly5x0wQELDy O3Lao9CJUGY+N+oRvPzNQCBbVT5nrPHgvV2PL8YmwpgfcT13LZfgV4DFqoFDisCt97c8 rdHMGjqn6jm3czsaWt1Jd5ZsQOc0PlqQ6upu2/9N8BGspSWGZznCrOrjvlwL8BI10na1 uyyh+auRjtVaN9T9WRs7QYWkZsinhFDC2U34xcR1myexuBPh18GbD0uDTULAHJD+hYEr 9SfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dZi7K4N7; 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 x25-v6sor735650lji.41.2018.06.20.10.22.46 for (Google Transport Security); Wed, 20 Jun 2018 10:22:46 -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=dZi7K4N7; 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=ZU7eQCdNUvVwVHNHQGUhwppj4DPi+mJPY3V/YyeaLt0=; b=dZi7K4N7GvETn6Hq9kRuFwIXXLI+F66+gwDmPH4DzgMvs0Pv1Eg4DTtOCmQQc5jjOg 1btH/zuEhKyYjPoJQPkRcfLRcwiISg6bRMbUA7wu0f3W4lf8UVMtybWTjIcedaEar8IH dFxJymLVGiVAWN2gIk6wVuXw5OqgwOlKgY6o4= 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=ZU7eQCdNUvVwVHNHQGUhwppj4DPi+mJPY3V/YyeaLt0=; b=ONHL24KhncCe/vnVD2YWkg/hEBvVfIRkyk7YGLiQNmmj6W07SiSV5GQn83ql8he8+4 y3q1bRKgZIvFHmGBtdC0FQU+bZHfTKzNi8ZC4Cm7xgd1jTbdFPsWKt9f2MdeVdJ0d0qj dFWk73PlVakKX9w50wc/HUTZFS3SCxV4AKQ9/27NsiY6N81ZnJAimH0B8f7/Xr3ty8dE MoFh3RnQaPk5+JDMYyV16hDtoft2hD4bEhdwwgCkF+2/+9LFUbvWXpIMpRs2zxhLdNeb g+45/4vcm2dBOL732ki90uhOmRssBGg9J0X1dh6LyAeiO798cf6GsZpXwjEA0m28VMlt 4r8w== X-Gm-Message-State: APt69E0aS4B6EJAL7gi7BpnSpfiojc1S4H3FRS5dc4kAT+1wLxsOyN9m S0fc43UQWzMBANY2x7kItvYzYJOd X-Google-Smtp-Source: ADUXVKLI5PAJJ9M0tBJGD4D4qY5SXbv264nb5hwS+QxygTGi2rPcN2hdXUkSOnAKqhPzvLQMt3Uo1Q== X-Received: by 2002:a2e:43db:: with SMTP id z88-v6mr14397880lje.24.1529515365948; Wed, 20 Jun 2018 10:22:45 -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 b2-v6sm514441lji.85.2018.06.20.10.22.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:45 -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 v8 06/26] timer: Export next wakeup time of a CPU Date: Wed, 20 Jun 2018 19:22:06 +0200 Message-Id: <20180620172226.15012-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-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 --- include/linux/tick.h | 8 ++++++++ kernel/time/tick-sched.c | 10 ++++++++++ 2 files changed, 18 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 da9455a6b42b..f380bb4f0744 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1089,6 +1089,16 @@ 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