From: Christian Loehle <christian.loehle@arm.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Subject: Re: [PATCH v1 9/9] cpuidle: teo: Replace time_span_ns with a flag
Date: Mon, 20 Jan 2025 12:16:45 +0000 [thread overview]
Message-ID: <c55e5fa8-a747-4a77-8889-93b4f42bd5c3@arm.com> (raw)
In-Reply-To: <6010475.MhkbZ0Pkbq@rjwysocki.net>
On 1/13/25 18:51, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> After recent updates, the time_span_ns field in struct teo_cpu has
> become an indicator on whether or not the most recent wakeup has been
> "genuine" which may as well be indicated by a bool field without
> calling local_clock(), so update the code accordingly.
>
> No intentional functional impact.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/cpuidle/governors/teo.c | 27 +++++++++------------------
> 1 file changed, 9 insertions(+), 18 deletions(-)
>
> --- a/drivers/cpuidle/governors/teo.c
> +++ b/drivers/cpuidle/governors/teo.c
> @@ -124,20 +124,20 @@
>
> /**
> * struct teo_cpu - CPU data used by the TEO cpuidle governor.
> - * @time_span_ns: Time between idle state selection and post-wakeup update.
> * @sleep_length_ns: Time till the closest timer event (at the selection time).
> * @state_bins: Idle state data bins for this CPU.
> * @total: Grand total of the "intercepts" and "hits" metrics for all bins.
> * @tick_intercepts: "Intercepts" before TICK_NSEC.
> * @short_idle: Wakeups after short idle periods.
> + * @artificial_wakeup: Set if the wakeup has been triggered by a safety net.
> */
> struct teo_cpu {
> - s64 time_span_ns;
> s64 sleep_length_ns;
> struct teo_bin state_bins[CPUIDLE_STATE_MAX];
> unsigned int total;
> unsigned int tick_intercepts;
> unsigned int short_idle;
> + bool artificial_wakeup;
> };
>
> static DEFINE_PER_CPU(struct teo_cpu, teo_cpus);
> @@ -156,7 +156,7 @@
>
> cpu_data->short_idle -= cpu_data->short_idle >> DECAY_SHIFT;
>
> - if (cpu_data->time_span_ns < 0) {
> + if (cpu_data->artificial_wakeup) {
> /*
> * If one of the safety nets has triggered, assume that this
> * might have been a long sleep.
> @@ -165,13 +165,6 @@
> } else {
> u64 lat_ns = drv->states[dev->last_state_idx].exit_latency_ns;
>
> - /*
> - * The computations below are to determine whether or not the
> - * (saved) time till the next timer event and the measured idle
> - * duration fall into the same "bin", so use last_residency_ns
> - * for that instead of time_span_ns which includes the cpuidle
> - * overhead.
> - */
> measured_ns = dev->last_residency_ns;
> /*
> * The delay between the wakeup and the first instruction
> @@ -286,7 +279,6 @@
> dev->last_state_idx = -1;
> }
>
> - cpu_data->time_span_ns = local_clock();
> /*
> * Set the sleep length to infitity in case the invocation of
You're not touching this here, but might as well fix the infitity
typo with the series.
> * tick_nohz_get_sleep_length() below is skipped, in which case it won't
> @@ -504,17 +496,16 @@
> struct teo_cpu *cpu_data = per_cpu_ptr(&teo_cpus, dev->cpu);
>
> dev->last_state_idx = state;
> - /*
> - * If the wakeup was not "natural", but triggered by one of the safety
> - * nets, assume that the CPU might have been idle for the entire sleep
> - * length time.
> - */
> if (dev->poll_time_limit ||
> (tick_nohz_idle_got_tick() && cpu_data->sleep_length_ns > TICK_NSEC)) {
> + /*
> + * The wakeup was not "geniune", but triggered by one of the
s/geniune/genuine
> + * safety nets.
> + */
> dev->poll_time_limit = false;
> - cpu_data->time_span_ns = KTIME_MIN;
> + cpu_data->artificial_wakeup = true;
> } else {
> - cpu_data->time_span_ns = local_clock() - cpu_data->time_span_ns;
> + cpu_data->artificial_wakeup = false;
> }
You could rewrite this without the else by just setting it to false before the if.
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
next prev parent reply other threads:[~2025-01-20 12:16 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 18:32 [PATCH v1 0/9] cpuidle: teo: Cleanups and very frequent wakeups handling update Rafael J. Wysocki
2025-01-13 18:34 ` [PATCH v1 1/9] cpuidle: teo: Rearrange idle state lookup code Rafael J. Wysocki
2025-01-15 14:21 ` Christian Loehle
2025-01-13 18:36 ` [PATCH v1 2/9] cpuidle: teo: Reorder candidate state index checks Rafael J. Wysocki
2025-01-15 14:46 ` Christian Loehle
2025-01-15 15:54 ` Rafael J. Wysocki
2025-01-15 19:20 ` Christian Loehle
2025-01-15 20:48 ` Rafael J. Wysocki
2025-01-15 21:10 ` Rafael J. Wysocki
2025-01-16 12:22 ` Rafael J. Wysocki
2025-01-16 13:26 ` Christian Loehle
2025-01-16 13:27 ` Christian Loehle
2025-01-13 18:39 ` [PATCH v1 3/9] cpuidle: teo: Combine candidate state index checks against 0 Rafael J. Wysocki
2025-01-15 19:44 ` Christian Loehle
2025-01-13 18:40 ` [PATCH v1 4/9] cpuidle: teo: Drop local variable prev_intercept_idx Rafael J. Wysocki
2025-01-15 19:46 ` Christian Loehle
2025-01-13 18:41 ` [PATCH v1 5/9] cpuidle: teo: Clarify two code comments Rafael J. Wysocki
2025-01-15 19:43 ` Christian Loehle
2025-01-13 18:45 ` [PATCH v1 6/9] cpuidle: teo: Simplify counting events used for tick management Rafael J. Wysocki
2025-01-20 11:27 ` Christian Loehle
2025-01-13 18:48 ` [PATCH v1 7/9] cpuidle: teo: Skip getting the sleep length is wakeups are very frequent Rafael J. Wysocki
2025-01-20 12:08 ` Christian Loehle
2025-01-20 16:24 ` Rafael J. Wysocki
2025-01-13 18:50 ` [PATCH v1 8/9] cpuidle: teo: Simplify handling of total events count Rafael J. Wysocki
2025-01-20 12:10 ` Christian Loehle
2025-01-13 18:51 ` [PATCH v1 9/9] cpuidle: teo: Replace time_span_ns with a flag Rafael J. Wysocki
2025-01-20 12:16 ` Christian Loehle [this message]
2025-01-20 12:42 ` Rafael J. Wysocki
2025-01-15 14:52 ` [PATCH v1 0/9] cpuidle: teo: Cleanups and very frequent wakeups handling update Christian Loehle
2025-01-20 8:17 ` Aboorva Devarajan
2025-01-20 16:26 ` Rafael J. Wysocki
2025-01-20 16:24 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c55e5fa8-a747-4a77-8889-93b4f42bd5c3@arm.com \
--to=christian.loehle@arm.com \
--cc=artem.bityutskiy@linux.intel.com \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®