From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Roger Pau Monne <roger.pau@citrix.com>, Jan Beulich <jbeulich@suse.com>
Subject: [PATCH 1/2] xen/cpufreq: fix adjusting of sampling window on early exit
Date: Fri, 27 Feb 2026 08:32:58 +0100 [thread overview]
Message-ID: <20260227073259.1200-2-roger.pau@citrix.com> (raw)
In-Reply-To: <20260227073259.1200-1-roger.pau@citrix.com>
The logic in dbs_check_cpu() resets the sampling window even when the
sampling period is considered too small. This leads to further calls
finding an imbalance between the total window time and the idle time, as
the total window time is possibly shorter than the idle time.
Fix by resetting the sampling window start time in the same block where the
current idle time is stored. While there also prevent a duplicated call to
NOW() and instead re-use the previously fetched value.
Fixes: d6f001cb91ac ("x86: Implement cpufreq ondemand policy")
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
xen/drivers/cpufreq/cpufreq_ondemand.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/xen/drivers/cpufreq/cpufreq_ondemand.c b/xen/drivers/cpufreq/cpufreq_ondemand.c
index 0126a3f5d9b4..537695eaab19 100644
--- a/xen/drivers/cpufreq/cpufreq_ondemand.c
+++ b/xen/drivers/cpufreq/cpufreq_ondemand.c
@@ -117,11 +117,12 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
cur_ns = NOW();
total_ns = cur_ns - this_dbs_info->prev_cpu_wall;
- this_dbs_info->prev_cpu_wall = NOW();
if (total_ns < MIN_DBS_INTERVAL)
return;
+ this_dbs_info->prev_cpu_wall = cur_ns;
+
/* Get Idle Time */
for_each_cpu(j, policy->cpus) {
uint64_t idle_ns, total_idle_ns;
--
2.51.0
next prev parent reply other threads:[~2026-02-27 7:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 7:32 [PATCH 0/2] xen/cpufreq: a couple of fixes for the sampling window Roger Pau Monne
2026-02-27 7:32 ` Roger Pau Monne [this message]
2026-03-02 9:46 ` [PATCH 1/2] xen/cpufreq: fix adjusting of sampling window on early exit Jan Beulich
2026-02-27 7:32 ` [PATCH 2/2] xen/cpufreq: fix usages of align_timer() in the on-demand governor Roger Pau Monne
2026-03-02 9:57 ` Jan Beulich
2026-06-15 17:44 ` Jason Andryuk
2026-06-15 18:33 ` Roger Pau Monné
2026-06-15 19:31 ` Jason Andryuk
2026-06-15 19:22 ` Roger Pau Monné
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=20260227073259.1200-2-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=jbeulich@suse.com \
--cc=xen-devel@lists.xenproject.org \
/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 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.