[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] xen/cpufreq: fix adjusting of sampling window on early exit


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Fri, 27 Feb 2026 08:32:58 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • 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=DPPIUPm12nWgbE3ZxGYrVCdi/GpigvkTLG3rTr9R7oI=; b=Sf9Wtv5K1wcAiSvp+7jNqY3jGMsz7gxUWYjmmH+4tde550kdrpCPDSfPgE8af0p1nJCUXQEkBFKmnrq5e+x8TMpLVuMAd6VYDNYKBWjLuWKu5BQC5lDOJZO37KLBIaHvIlC9oGqTTB7vk710SQTy6KUZJcVz0XOVMEWFnABsqOAAkal3Eh8L1eN5X2yYdhXNg3CzfxhDUM8Um3F4w8fo/MBhUKCBWiJ+MqmmVmOppCUBJUCKfoo5xqF3JJxps9RTizzblzewIKR4vS8rHXusiFoTMg7tjeM0d49kH+PPB45JWqSOBHfX3lx3KRDPe4dKgjYdq9wJRwPCtMkG/mtS/Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=skAbc5lk+b9UuPGVUcqLQiDjlrdS4wBvh97l4CXrDls2YU2ZVM1SFTyXfPAAdLcQPQyv9/knpIszaQeRbK3otz7xbCf3qVmA2bJJ8vX3CiyBPQw4CTT2pFculaIQTTniek968hR03GZmJWW4XFBedwfzIaOpqk2o6Y/zCehaGjaDpaIwKGGiMVPFWyCceloFdZTxrHCUsQ/IaL0YJslUEfVWgDF1yaILrSHAbbX6VHmU3cRhlkQH2m6ekShnCWtcgOFosuRjOVq83x0vD1YeeThU7NckFtdp4Ewg9IMPcZhtpr9W1LWUGMHwtpfs7s8yeB7PSVGGATbLcbrX0KGpFg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Fri, 27 Feb 2026 07:33:21 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxxxx>
---
 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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.