[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] xen/cpufreq: fix usages of align_timer() in the on-demand governor
- To: Roger Pau Monne <roger.pau@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Jason Andryuk <jason.andryuk@xxxxxxx>
- Date: Mon, 15 Jun 2026 13:44:54 -0400
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=citrix.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QDoPIxv9i7O13kXGh5GBrpXz05kp6T5/s6TDbkxue/8=; b=b5CeMDNIHGDZzakeoH2GRbHNAmdLZ1nPDzAoCLW1y50gYt5/O40TH5hapOi6LdWFIkbEGuJkEk1M07wrknps1Mr3N4ffXgYwigFZuxeeJ0Qk46V6ii2O6RolotVKcNZjuNNi3bEwKtMQSoMHVd6ddHFmD9jzzVeymPP0tcbcvcnBQxbvuM0T9iuGg6IsTvVJZr35g90ZVNwgGSIiyJ9b4jAIFyYgPvjXnJ+kiRwUqmy/a4IHGL5q4A9G8ABXeTA0OBWDAUmlVVnNuoROaTRKLaU+WigMcwwzviBE720tOtHEwqp4hM3ZzW+cRBiQA+DKfUl5lytcs1z0PpJ0ZM5kAQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SztQJkYgErYujOXzf8AglqY/F2/BffSmZk7L9PUl20pfcUEKIQuNu4rc53DwPH/icMMNB+DacEKdbEC+ns8RM1dv656VC/R29Ldhkq54U2I7ES2wBu+9pVvLPUKJHPA7q8DnqPfHBybCvcnfHu8V9Fzn1/co1RpQ2l8eg/4ayYqkl8uPmPp9royY06Dd8BOskpmj+Meojf0TmGExQHDY8NihLVwwgFoh/CtTJvPK2pCevNAl/1DKdCU/MB0kAy4hKXWFryn3r4+sYJ9/qZOdcxIrh6j1zQkWTfh3qqvoHK44EpFlT4np+uWu7XNKnScUN1b5grxyu9nlvzqrxeMAUw==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
- Cc: Jan Beulich <jbeulich@xxxxxxxx>
- Delivery-date: Mon, 15 Jun 2026 17:45:19 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 2026-02-27 02:32, Roger Pau Monne wrote:
The first parameter passed to align_timer() is the timer expiration, not
the current time. Adjust the calls to align_timer() in the on-demand
governor to pass the expected timer expiration as the first parameter.
Internally, we have a report of a benchmark regressing ~6% with this
change on 4.20.
s_time_t align_timer(s_time_t firsttick, uint64_t period)
{
if ( !period )
return firsttick;
return firsttick + (period - 1) - ((firsttick - 1) % period);
}
The code rounds firsttick up to the next period:
align_timer(0, period) -> 0
align_timer(1, period) -> period
align_timer(period - 1, period) -> period
align_timer(period, period) -> period
align_timer(period + 1, period) -> 2 * period
With the change of this patch adding the period before calling
align_timer(), the timer is set for two periods in the future. The only
exception is when firsttick % period == 0. I think that is unlikely to
happen since NOW() will always be a little after the period. Even if it
did happen, the timer would fire immediately, but the next timer would
be set for 1 period later.
So I think we want to revert?
Regards,
Jason
Fixes: af74e3a15a83 ("cpufreq: align dbs timer for better package C state
residency")
Fixes: 382b95f627a9 ("Fix cpufreq HW-ALL coordination handle")
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
xen/drivers/cpufreq/cpufreq_ondemand.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/xen/drivers/cpufreq/cpufreq_ondemand.c
b/xen/drivers/cpufreq/cpufreq_ondemand.c
index 537695eaab19..0d94c0e464a6 100644
--- a/xen/drivers/cpufreq/cpufreq_ondemand.c
+++ b/xen/drivers/cpufreq/cpufreq_ondemand.c
@@ -185,7 +185,8 @@ 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));
+ align_timer(NOW() + dbs_tuners_ins.sampling_rate,
+ dbs_tuners_ins.sampling_rate));
}
static void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
@@ -400,6 +401,6 @@ void cpufreq_dbs_timer_resume(void)
(void)cmpxchg(stoppable, -1, 1);
}
else
- set_timer(t, align_timer(now, dbs_tuners_ins.sampling_rate));
+ set_timer(t, align_timer(t->expires,
dbs_tuners_ins.sampling_rate));
}
}
|