WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] x86: fix cpufreq_dom_mask

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] x86: fix cpufreq_dom_mask
From: "Jan Beulich" <jbeulich@xxxxxxxxxx>
Date: Mon, 08 Sep 2008 13:54:34 +0100
Delivery-date: Mon, 08 Sep 2008 05:54:33 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
cpufreq_dom_mask must not be confined to the number of CPUs in the
system - there's nothing disallowing e.g. 1-based domain identifiers
to be used in _PSD. It still remains risky to assume that these numbers
are 'small' and/or not allocated sparsely.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

Index: 2008-09-01/xen/arch/x86/acpi/cpufreq/cpufreq.c
===================================================================
--- 2008-09-01.orig/xen/arch/x86/acpi/cpufreq/cpufreq.c 2008-07-21 
08:19:40.000000000 +0200
+++ 2008-09-01/xen/arch/x86/acpi/cpufreq/cpufreq.c      2008-09-08 
11:54:12.000000000 +0200
@@ -48,7 +48,7 @@ struct processor_pminfo processor_pminfo
 struct cpufreq_policy xen_px_policy[NR_CPUS];
 
 static cpumask_t *cpufreq_dom_pt;
-static cpumask_t cpufreq_dom_mask;
+static unsigned long *cpufreq_dom_mask;
 static unsigned int cpufreq_dom_max;
 
 enum {
@@ -562,7 +562,8 @@ static struct cpufreq_driver acpi_cpufre
 void cpufreq_dom_exit(void)
 {
     cpufreq_dom_max = 0;
-    cpus_clear(cpufreq_dom_mask);
+    if (cpufreq_dom_mask)
+        xfree(cpufreq_dom_mask);
     if (cpufreq_dom_pt)
         xfree(cpufreq_dom_pt);
 }
@@ -572,22 +573,28 @@ int cpufreq_dom_init(void)
     unsigned int i;
 
     cpufreq_dom_max = 0;
-    cpus_clear(cpufreq_dom_mask);
 
     for_each_online_cpu(i) {
-        cpu_set(processor_pminfo[i].perf.domain_info.domain, cpufreq_dom_mask);
         if (cpufreq_dom_max < processor_pminfo[i].perf.domain_info.domain)
             cpufreq_dom_max = processor_pminfo[i].perf.domain_info.domain;
     }
     cpufreq_dom_max++;
 
+    cpufreq_dom_mask = xmalloc_array(unsigned long,
+                                     BITS_TO_LONGS(cpufreq_dom_max));
+    if (!cpufreq_dom_mask)
+        return -ENOMEM;
+    bitmap_zero(cpufreq_dom_mask, cpufreq_dom_max);
+
     cpufreq_dom_pt = xmalloc_array(cpumask_t, cpufreq_dom_max);
     if (!cpufreq_dom_pt)
         return -ENOMEM;
     memset(cpufreq_dom_pt, 0, cpufreq_dom_max * sizeof(cpumask_t));
 
-    for_each_online_cpu(i)
+    for_each_online_cpu(i) {
+        __set_bit(processor_pminfo[i].perf.domain_info.domain, 
cpufreq_dom_mask);
         cpu_set(i, 
cpufreq_dom_pt[processor_pminfo[i].perf.domain_info.domain]);
+    }
 
     for_each_online_cpu(i)
         processor_pminfo[i].perf.shared_cpu_map =
@@ -616,10 +623,11 @@ static int cpufreq_cpu_init(void)
 
 int cpufreq_dom_dbs(unsigned int event)
 {
-    int cpu, dom, ret = 0;
+    unsigned int cpu, dom;
+    int ret = 0;
 
-    for (dom=0; dom<cpufreq_dom_max; dom++) {
-        if (!cpu_isset(dom, cpufreq_dom_mask))
+    for (dom = 0; dom < cpufreq_dom_max; dom++) {
+        if (!test_bit(dom, cpufreq_dom_mask))
             continue;
         cpu = first_cpu(cpufreq_dom_pt[dom]);
         ret = cpufreq_governor_dbs(&xen_px_policy[cpu], event);




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] x86: fix cpufreq_dom_mask, Jan Beulich <=