xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/mce: eliminate unnecessary NR_CPUS-sized arrays
@ 2010-07-08 15:29 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2010-07-08 15:29 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com

[-- Attachment #1: Type: text/plain, Size: 3075 bytes --]

Replace them with per-CPU data.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

--- 2010-06-15.orig/xen/arch/x86/cpu/mcheck/mce_intel.c	2010-06-15 12:08:53.000000000 +0200
+++ 2010-06-15/xen/arch/x86/cpu/mcheck/mce_intel.c	2010-07-06 14:55:29.000000000 +0200
@@ -40,13 +40,13 @@ static void intel_thermal_interrupt(stru
 {
     uint64_t msr_content;
     unsigned int cpu = smp_processor_id();
-    static s_time_t next[NR_CPUS];
+    static DEFINE_PER_CPU(s_time_t, next);
 
     ack_APIC_irq();
-    if (NOW() < next[cpu])
+    if (NOW() < per_cpu(next, cpu))
         return;
 
-    next[cpu] = NOW() + MILLISECS(5000);
+    per_cpu(next, cpu) = NOW() + MILLISECS(5000);
     rdmsrl(MSR_IA32_THERM_STATUS, msr_content);
     if (msr_content & 0x1) {
         printk(KERN_EMERG "CPU%d: Temperature above threshold\n", cpu);
--- 2010-06-15.orig/xen/arch/x86/cpu/mcheck/mctelem.c	2009-12-02 10:02:49.000000000 +0100
+++ 2010-06-15/xen/arch/x86/cpu/mcheck/mctelem.c	2010-07-06 15:03:34.000000000 +0200
@@ -109,15 +109,19 @@ static struct mc_telem_ctl {
 	 * Telemetry array
 	 */
 	struct mctelem_ent *mctc_elems;
+} mctctl;
+
+struct mc_telem_cpu_ctl {
 	/*
 	 * Per-CPU processing lists, used for deferred (softirq)
-	 * processing of telemetry. mctc_cpu is indexed by the
-	 * CPU that the telemetry belongs to. mctc_cpu_processing
-	 * is indexed by the CPU that is processing the telemetry.
+	 * processing of telemetry. @pending is indexed by the
+	 * CPU that the telemetry belongs to. @processing is indexed
+	 * by the CPU that is processing the telemetry.
 	 */
-	struct mctelem_ent *mctc_cpu[NR_CPUS];
-	struct mctelem_ent *mctc_cpu_processing[NR_CPUS];
-} mctctl;
+	struct mctelem_ent *pending;
+	struct mctelem_ent *processing;
+};
+static DEFINE_PER_CPU(struct mc_telem_cpu_ctl, mctctl);
 
 /* Lock protecting all processing lists */
 static DEFINE_SPINLOCK(processing_lock);
@@ -139,8 +143,7 @@ void mctelem_defer(mctelem_cookie_t cook
 {
 	struct mctelem_ent *tep = COOKIE2MCTE(cookie);
 
-	mctelem_xchg_head(&mctctl.mctc_cpu[smp_processor_id()],
-	    &tep->mcte_next, tep);
+	mctelem_xchg_head(&this_cpu(mctctl.pending), &tep->mcte_next, tep);
 }
 
 void mctelem_process_deferred(unsigned int cpu,
@@ -154,10 +157,10 @@ void mctelem_process_deferred(unsigned i
 	 * First, unhook the list of telemetry structures, and	
 	 * hook it up to the processing list head for this CPU.
 	 */
-	mctelem_xchg_head(&mctctl.mctc_cpu[cpu],
-	    &mctctl.mctc_cpu_processing[smp_processor_id()], NULL);
+	mctelem_xchg_head(&per_cpu(mctctl.pending, cpu),
+			  &this_cpu(mctctl.processing), NULL);
 
-	head = mctctl.mctc_cpu_processing[smp_processor_id()];
+	head = this_cpu(mctctl.processing);
 
 	/*
 	 * Then, fix up the list to include prev pointers, to make
@@ -193,7 +196,7 @@ void mctelem_process_deferred(unsigned i
 
 int mctelem_has_deferred(unsigned int cpu)
 {
-	if (mctctl.mctc_cpu[cpu] != NULL)
+	if (per_cpu(mctctl.pending, cpu) != NULL)
 		return 1;
 	return 0;
 }




[-- Attachment #2: x86-mce-no-NR_CPUS.patch --]
[-- Type: text/plain, Size: 3069 bytes --]

Replace them with per-CPU data.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

--- 2010-06-15.orig/xen/arch/x86/cpu/mcheck/mce_intel.c	2010-06-15 12:08:53.000000000 +0200
+++ 2010-06-15/xen/arch/x86/cpu/mcheck/mce_intel.c	2010-07-06 14:55:29.000000000 +0200
@@ -40,13 +40,13 @@ static void intel_thermal_interrupt(stru
 {
     uint64_t msr_content;
     unsigned int cpu = smp_processor_id();
-    static s_time_t next[NR_CPUS];
+    static DEFINE_PER_CPU(s_time_t, next);
 
     ack_APIC_irq();
-    if (NOW() < next[cpu])
+    if (NOW() < per_cpu(next, cpu))
         return;
 
-    next[cpu] = NOW() + MILLISECS(5000);
+    per_cpu(next, cpu) = NOW() + MILLISECS(5000);
     rdmsrl(MSR_IA32_THERM_STATUS, msr_content);
     if (msr_content & 0x1) {
         printk(KERN_EMERG "CPU%d: Temperature above threshold\n", cpu);
--- 2010-06-15.orig/xen/arch/x86/cpu/mcheck/mctelem.c	2009-12-02 10:02:49.000000000 +0100
+++ 2010-06-15/xen/arch/x86/cpu/mcheck/mctelem.c	2010-07-06 15:03:34.000000000 +0200
@@ -109,15 +109,19 @@ static struct mc_telem_ctl {
 	 * Telemetry array
 	 */
 	struct mctelem_ent *mctc_elems;
+} mctctl;
+
+struct mc_telem_cpu_ctl {
 	/*
 	 * Per-CPU processing lists, used for deferred (softirq)
-	 * processing of telemetry. mctc_cpu is indexed by the
-	 * CPU that the telemetry belongs to. mctc_cpu_processing
-	 * is indexed by the CPU that is processing the telemetry.
+	 * processing of telemetry. @pending is indexed by the
+	 * CPU that the telemetry belongs to. @processing is indexed
+	 * by the CPU that is processing the telemetry.
 	 */
-	struct mctelem_ent *mctc_cpu[NR_CPUS];
-	struct mctelem_ent *mctc_cpu_processing[NR_CPUS];
-} mctctl;
+	struct mctelem_ent *pending;
+	struct mctelem_ent *processing;
+};
+static DEFINE_PER_CPU(struct mc_telem_cpu_ctl, mctctl);
 
 /* Lock protecting all processing lists */
 static DEFINE_SPINLOCK(processing_lock);
@@ -139,8 +143,7 @@ void mctelem_defer(mctelem_cookie_t cook
 {
 	struct mctelem_ent *tep = COOKIE2MCTE(cookie);
 
-	mctelem_xchg_head(&mctctl.mctc_cpu[smp_processor_id()],
-	    &tep->mcte_next, tep);
+	mctelem_xchg_head(&this_cpu(mctctl.pending), &tep->mcte_next, tep);
 }
 
 void mctelem_process_deferred(unsigned int cpu,
@@ -154,10 +157,10 @@ void mctelem_process_deferred(unsigned i
 	 * First, unhook the list of telemetry structures, and	
 	 * hook it up to the processing list head for this CPU.
 	 */
-	mctelem_xchg_head(&mctctl.mctc_cpu[cpu],
-	    &mctctl.mctc_cpu_processing[smp_processor_id()], NULL);
+	mctelem_xchg_head(&per_cpu(mctctl.pending, cpu),
+			  &this_cpu(mctctl.processing), NULL);
 
-	head = mctctl.mctc_cpu_processing[smp_processor_id()];
+	head = this_cpu(mctctl.processing);
 
 	/*
 	 * Then, fix up the list to include prev pointers, to make
@@ -193,7 +196,7 @@ void mctelem_process_deferred(unsigned i
 
 int mctelem_has_deferred(unsigned int cpu)
 {
-	if (mctctl.mctc_cpu[cpu] != NULL)
+	if (per_cpu(mctctl.pending, cpu) != NULL)
 		return 1;
 	return 0;
 }

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-07-08 15:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-08 15:29 [PATCH] x86/mce: eliminate unnecessary NR_CPUS-sized arrays Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).