Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > fc11cd6e1c513a17304da94a5390f3cd > files > 4423

kernel-2.6.18-194.11.1.el5.src.rpm

From: Rik van Riel <riel@redhat.com>
Date: Thu, 13 Dec 2007 15:13:52 -0500
Subject: [xen] disable cpu freq scaling when vcpus is small
Message-id: 20071213151352.7ebb88c1@cuia.boston.redhat.com
O-Subject: [RHEL 5.2 PATCH 4/3] cpu frequency scaling for Xen BZ#251969
Bugzilla: 251969

We should really enable cpu frequency scaling by default in Xen.
Except it's not possible if dom0 has fewer VCPUs than the system
has physical CPUs.

This patch:
1) enables CPU frequency scaling by default
2) automatically switches it off if dom0 has fewer VCPUs than the
   system has physical CPUs
3) switches off frequency scaling if the user specifies cpufreq=off
   or cpufreq=none on the Xen command line

This improves the fix to bug 251969

Upstream status: I have just written the patch, submitted it upstream and
tested it, in that order :)

Acked-by: Bill Burns <bburns@redhat.com>
Acked-by: "Stephen C. Tweedie" <sct@redhat.com>

diff --git a/arch/x86/domain_build.c b/arch/x86/domain_build.c
index 7318e2e..f3eeb76 100644
--- a/arch/x86/domain_build.c
+++ b/arch/x86/domain_build.c
@@ -780,6 +780,16 @@ int __init construct_dom0(
         opt_dom0_max_vcpus = BITS_PER_GUEST_LONG(d);
     printk("Dom0 has maximum %u VCPUs\n", opt_dom0_max_vcpus);
 
+    /*
+     * If dom0 has fewer VCPUs than there are physical CPUs on the system,
+     * we need to disable cpu frequency scaling.
+     */
+    if ( opt_dom0_max_vcpus != num_online_cpus() ) {
+        extern unsigned int opt_dom0_vcpus_pin;
+        cpufreq_controller = FREQCTL_none;
+        opt_dom0_vcpus_pin = 0;
+    }
+
     for ( i = 1; i < opt_dom0_max_vcpus; i++ )
         (void)alloc_vcpu(d, i, i);
 
diff --git a/common/schedule.c b/common/schedule.c
index 70d04ee..3d80021 100644
--- a/common/schedule.c
+++ b/common/schedule.c
@@ -38,16 +38,19 @@ static char opt_sched[10] = "credit";
 string_param("sched", opt_sched);
 
 /* opt_dom0_vcpus_pin: If true, dom0 VCPUs are pinned. */
-static unsigned int opt_dom0_vcpus_pin;
+unsigned int opt_dom0_vcpus_pin = 1;
 boolean_param("dom0_vcpus_pin", opt_dom0_vcpus_pin);
 
-enum cpufreq_controller cpufreq_controller;
+enum cpufreq_controller cpufreq_controller = FREQCTL_dom0_kernel;
 static void __init setup_cpufreq_option(char *str)
 {
     if ( !strcmp(str, "dom0-kernel") )
     {
         cpufreq_controller = FREQCTL_dom0_kernel;
         opt_dom0_vcpus_pin = 1;
+    } else if ( !strcmp(str, "off") || !strcmp(str, "none") ) {
+        cpufreq_controller = FREQCTL_none;
+        opt_dom0_vcpus_pin = 0;
     }
 }
 custom_param("cpufreq", setup_cpufreq_option);