* [PATCH] Revert "xen/cpufreq: fix usages of align_timer() in the on-demand governor"
@ 2026-06-15 19:39 Jason Andryuk
2026-06-16 6:30 ` Jan Beulich
2026-06-16 6:31 ` [PATCH] " Jan Beulich
0 siblings, 2 replies; 5+ messages in thread
From: Jason Andryuk @ 2026-06-15 19:39 UTC (permalink / raw)
To: xen-devel; +Cc: Roger Pau Monne, Jason Andryuk, Jan Beulich
The original commit showed a ~6% regression in a benchmark. The call to
align_timer(firsttick, period) rounds firsttick up to the next mutiple
of the period, if firsttick % period != 0:
align_timer(0, period) -> 0
align_timer(1, period) -> period
align_timer(period, period) -> period
align_timer(period + 1, period) -> 2 * period
So adding the period (sampling_rate) before calling align_timer() will
in most cases incease the expiration to 2 * period (sampling_rate) (the
exception being firsttick % period == 0). This longer timer slows the
reaction time of the algorithm.
This reverts commit a0ed5bcfbeee81c91c574ad484faa057054eaf09.
Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
---
This is backported in stable trees and should be reverted there as well
(found in 4.20.3).
A Fixes seems superfluous and not normally used with a revert, but if
needed:
Fixes: a0ed5bcfbeee ("xen/cpufreq: fix usages of align_timer() in the on-demand governor")
---
xen/drivers/cpufreq/cpufreq_ondemand.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/xen/drivers/cpufreq/cpufreq_ondemand.c b/xen/drivers/cpufreq/cpufreq_ondemand.c
index 0d94c0e464..537695eaab 100644
--- a/xen/drivers/cpufreq/cpufreq_ondemand.c
+++ b/xen/drivers/cpufreq/cpufreq_ondemand.c
@@ -185,8 +185,7 @@ static void cf_check do_dbs_timer(void *dbs)
dbs_check_cpu(dbs_info);
set_timer(&per_cpu(dbs_timer, dbs_info->cpu),
- align_timer(NOW() + dbs_tuners_ins.sampling_rate,
- dbs_tuners_ins.sampling_rate));
+ align_timer(NOW() , dbs_tuners_ins.sampling_rate));
}
static void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
@@ -401,6 +400,6 @@ void cpufreq_dbs_timer_resume(void)
(void)cmpxchg(stoppable, -1, 1);
}
else
- set_timer(t, align_timer(t->expires, dbs_tuners_ins.sampling_rate));
+ set_timer(t, align_timer(now, dbs_tuners_ins.sampling_rate));
}
}
--
2.54.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] Revert "xen/cpufreq: fix usages of align_timer() in the on-demand governor"
2026-06-15 19:39 [PATCH] Revert "xen/cpufreq: fix usages of align_timer() in the on-demand governor" Jason Andryuk
@ 2026-06-16 6:30 ` Jan Beulich
2026-06-16 6:47 ` [PATCH for-4.22] " Roger Pau Monné
2026-06-16 6:31 ` [PATCH] " Jan Beulich
1 sibling, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2026-06-16 6:30 UTC (permalink / raw)
To: Jason Andryuk, Roger Pau Monne; +Cc: xen-devel
On 15.06.2026 21:39, Jason Andryuk wrote:
> The original commit showed a ~6% regression in a benchmark. The call to
> align_timer(firsttick, period) rounds firsttick up to the next mutiple
> of the period, if firsttick % period != 0:
>
> align_timer(0, period) -> 0
> align_timer(1, period) -> period
> align_timer(period, period) -> period
> align_timer(period + 1, period) -> 2 * period
>
> So adding the period (sampling_rate) before calling align_timer() will
> in most cases incease the expiration to 2 * period (sampling_rate) (the
> exception being firsttick % period == 0). This longer timer slows the
> reaction time of the algorithm.
>
> This reverts commit a0ed5bcfbeee81c91c574ad484faa057054eaf09.
>
> Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
> ---
> This is backported in stable trees and should be reverted there as well
> (found in 4.20.3).
>
> A Fixes seems superfluous and not normally used with a revert, but if
> needed:
> Fixes: a0ed5bcfbeee ("xen/cpufreq: fix usages of align_timer() in the on-demand governor")
If "git grep" is intended to (also) find such straight reverts by merely
matching "Fixes: ", I think the tag should still be put there.
Talking of Fixes: tags - the original change had two of them, so there
must have been a problem? Or, Roger, was this purely an observation from
looking the the code?
> --- a/xen/drivers/cpufreq/cpufreq_ondemand.c
> +++ b/xen/drivers/cpufreq/cpufreq_ondemand.c
> @@ -185,8 +185,7 @@ static void cf_check do_dbs_timer(void *dbs)
> dbs_check_cpu(dbs_info);
>
> set_timer(&per_cpu(dbs_timer, dbs_info->cpu),
> - align_timer(NOW() + dbs_tuners_ins.sampling_rate,
> - dbs_tuners_ins.sampling_rate));
> + align_timer(NOW() , dbs_tuners_ins.sampling_rate));
> }
As much as I understand you wanting to have things simple by doing a
straight revert, imo the formatting flaws better wouldn't be introduced
again. If I ended up committing this, I'd very likely take the liberty
of doing so. Yet before ack-ing the question above needs answering.
Jan
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH for-4.22] Revert "xen/cpufreq: fix usages of align_timer() in the on-demand governor"
2026-06-16 6:30 ` Jan Beulich
@ 2026-06-16 6:47 ` Roger Pau Monné
2026-06-16 7:31 ` Oleksii Kurochko
0 siblings, 1 reply; 5+ messages in thread
From: Roger Pau Monné @ 2026-06-16 6:47 UTC (permalink / raw)
To: Jan Beulich, oleksii.kurochko; +Cc: Jason Andryuk, xen-devel
On Tue, Jun 16, 2026 at 08:30:25AM +0200, Jan Beulich wrote:
> On 15.06.2026 21:39, Jason Andryuk wrote:
> > The original commit showed a ~6% regression in a benchmark. The call to
> > align_timer(firsttick, period) rounds firsttick up to the next mutiple
> > of the period, if firsttick % period != 0:
> >
> > align_timer(0, period) -> 0
> > align_timer(1, period) -> period
> > align_timer(period, period) -> period
> > align_timer(period + 1, period) -> 2 * period
> >
> > So adding the period (sampling_rate) before calling align_timer() will
> > in most cases incease the expiration to 2 * period (sampling_rate) (the
> > exception being firsttick % period == 0). This longer timer slows the
> > reaction time of the algorithm.
> >
> > This reverts commit a0ed5bcfbeee81c91c574ad484faa057054eaf09.
> >
> > Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Adding Oleksii for a release-ack.
> > ---
> > This is backported in stable trees and should be reverted there as well
> > (found in 4.20.3).
> >
> > A Fixes seems superfluous and not normally used with a revert, but if
> > needed:
> > Fixes: a0ed5bcfbeee ("xen/cpufreq: fix usages of align_timer() in the on-demand governor")
>
> If "git grep" is intended to (also) find such straight reverts by merely
> matching "Fixes: ", I think the tag should still be put there.
>
> Talking of Fixes: tags - the original change had two of them, so there
> must have been a problem? Or, Roger, was this purely an observation from
> looking the the code?
It was purely by observation that the current timer setup will very
likely fire before the set period, making the sampling intervals
possibly shorter. However shorter periods are fine, we simply
over-sample. Longer periods as shown by Jason have an adverse
impact in the response time of the governor.
> > --- a/xen/drivers/cpufreq/cpufreq_ondemand.c
> > +++ b/xen/drivers/cpufreq/cpufreq_ondemand.c
> > @@ -185,8 +185,7 @@ static void cf_check do_dbs_timer(void *dbs)
> > dbs_check_cpu(dbs_info);
> >
> > set_timer(&per_cpu(dbs_timer, dbs_info->cpu),
> > - align_timer(NOW() + dbs_tuners_ins.sampling_rate,
> > - dbs_tuners_ins.sampling_rate));
> > + align_timer(NOW() , dbs_tuners_ins.sampling_rate));
> > }
>
> As much as I understand you wanting to have things simple by doing a
> straight revert, imo the formatting flaws better wouldn't be introduced
> again. If I ended up committing this, I'd very likely take the liberty
> of doing so. Yet before ack-ing the question above needs answering.
I wouldn't mind adjusting this at commit.
Thanks, Roger.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH for-4.22] Revert "xen/cpufreq: fix usages of align_timer() in the on-demand governor"
2026-06-16 6:47 ` [PATCH for-4.22] " Roger Pau Monné
@ 2026-06-16 7:31 ` Oleksii Kurochko
0 siblings, 0 replies; 5+ messages in thread
From: Oleksii Kurochko @ 2026-06-16 7:31 UTC (permalink / raw)
To: Roger Pau Monné, Jan Beulich; +Cc: Jason Andryuk, xen-devel
On 6/16/26 8:47 AM, Roger Pau Monné wrote:
> On Tue, Jun 16, 2026 at 08:30:25AM +0200, Jan Beulich wrote:
>> On 15.06.2026 21:39, Jason Andryuk wrote:
>>> The original commit showed a ~6% regression in a benchmark. The call to
>>> align_timer(firsttick, period) rounds firsttick up to the next mutiple
>>> of the period, if firsttick % period != 0:
>>>
>>> align_timer(0, period) -> 0
>>> align_timer(1, period) -> period
>>> align_timer(period, period) -> period
>>> align_timer(period + 1, period) -> 2 * period
>>>
>>> So adding the period (sampling_rate) before calling align_timer() will
>>> in most cases incease the expiration to 2 * period (sampling_rate) (the
>>> exception being firsttick % period == 0). This longer timer slows the
>>> reaction time of the algorithm.
>>>
>>> This reverts commit a0ed5bcfbeee81c91c574ad484faa057054eaf09.
>>>
>>> Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
>
> Acked-by: Roger Pau Monné <roger.pau@citrix.com>
>
> Adding Oleksii for a release-ack.
>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Thanks.
~ Oleksii
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Revert "xen/cpufreq: fix usages of align_timer() in the on-demand governor"
2026-06-15 19:39 [PATCH] Revert "xen/cpufreq: fix usages of align_timer() in the on-demand governor" Jason Andryuk
2026-06-16 6:30 ` Jan Beulich
@ 2026-06-16 6:31 ` Jan Beulich
1 sibling, 0 replies; 5+ messages in thread
From: Jan Beulich @ 2026-06-16 6:31 UTC (permalink / raw)
To: Jason Andryuk; +Cc: Roger Pau Monne, xen-devel, Oleksii Kurochko
On 15.06.2026 21:39, Jason Andryuk wrote:
> The original commit showed a ~6% regression in a benchmark. The call to
> align_timer(firsttick, period) rounds firsttick up to the next mutiple
> of the period, if firsttick % period != 0:
>
> align_timer(0, period) -> 0
> align_timer(1, period) -> period
> align_timer(period, period) -> period
> align_timer(period + 1, period) -> 2 * period
>
> So adding the period (sampling_rate) before calling align_timer() will
> in most cases incease the expiration to 2 * period (sampling_rate) (the
> exception being firsttick % period == 0). This longer timer slows the
> reaction time of the algorithm.
>
> This reverts commit a0ed5bcfbeee81c91c574ad484faa057054eaf09.
>
> Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Oh, also Cc: Oleksii for a release-ack.
Jan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-06-16 7:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15 19:39 [PATCH] Revert "xen/cpufreq: fix usages of align_timer() in the on-demand governor" Jason Andryuk
2026-06-16 6:30 ` Jan Beulich
2026-06-16 6:47 ` [PATCH for-4.22] " Roger Pau Monné
2026-06-16 7:31 ` Oleksii Kurochko
2026-06-16 6:31 ` [PATCH] " Jan Beulich
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.