From: "Jan Beulich" Subject: [PATCH] x86: fix cpufreq_dom_mask Date: Mon, 08 Sep 2008 13:54:34 +0100 Message-ID: <48C53CAA.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org 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 Index: 2008-09-01/xen/arch/x86/acpi/cpufreq/cpufreq.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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]; =20 static cpumask_t *cpufreq_dom_pt; -static cpumask_t cpufreq_dom_mask; +static unsigned long *cpufreq_dom_mask; static unsigned int cpufreq_dom_max; =20 enum { @@ -562,7 +562,8 @@ static struct cpufreq_driver acpi_cpufre void cpufreq_dom_exit(void) { cpufreq_dom_max =3D 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; =20 cpufreq_dom_max =3D 0; - cpus_clear(cpufreq_dom_mask); =20 for_each_online_cpu(i) { - cpu_set(processor_pminfo[i].perf.domain_info.domain, cpufreq_dom_m= ask); if (cpufreq_dom_max < processor_pminfo[i].perf.domain_info.domain)= cpufreq_dom_max =3D processor_pminfo[i].perf.domain_info.domai= n; } cpufreq_dom_max++; =20 + cpufreq_dom_mask =3D 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 =3D xmalloc_array(cpumask_t, cpufreq_dom_max); if (!cpufreq_dom_pt) return -ENOMEM; memset(cpufreq_dom_pt, 0, cpufreq_dom_max * sizeof(cpumask_t)); =20 - 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.dom= ain]); + } =20 for_each_online_cpu(i) processor_pminfo[i].perf.shared_cpu_map =3D @@ -616,10 +623,11 @@ static int cpufreq_cpu_init(void) =20 int cpufreq_dom_dbs(unsigned int event) { - int cpu, dom, ret =3D 0; + unsigned int cpu, dom; + int ret =3D 0; =20 - for (dom=3D0; dom