From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH] x86/mce: eliminate unnecessary NR_CPUS-sized arrays Date: Thu, 08 Jul 2010 16:29:41 +0100 Message-ID: <4C360B05020000780000A480@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part0A277EF5.0__=" Return-path: 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 This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part0A277EF5.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Replace them with per-CPU data. Signed-off-by: Jan Beulich --- 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 =3D smp_processor_id(); - static s_time_t next[NR_CPUS]; + static DEFINE_PER_CPU(s_time_t, next); =20 ack_APIC_irq(); - if (NOW() < next[cpu]) + if (NOW() < per_cpu(next, cpu)) return; =20 - next[cpu] =3D NOW() + MILLISECS(5000); + per_cpu(next, cpu) =3D 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); =20 /* 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 =3D COOKIE2MCTE(cookie); =20 - mctelem_xchg_head(&mctctl.mctc_cpu[smp_processor_id()], - &tep->mcte_next, tep); + mctelem_xchg_head(&this_cpu(mctctl.pending), &tep->mcte_next, = tep); } =20 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=09 * 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); =20 - head =3D mctctl.mctc_cpu_processing[smp_processor_id()]; + head =3D this_cpu(mctctl.processing); =20 /* * Then, fix up the list to include prev pointers, to make @@ -193,7 +196,7 @@ void mctelem_process_deferred(unsigned i =20 int mctelem_has_deferred(unsigned int cpu) { - if (mctctl.mctc_cpu[cpu] !=3D NULL) + if (per_cpu(mctctl.pending, cpu) !=3D NULL) return 1; return 0; } --=__Part0A277EF5.0__= Content-Type: text/plain; name="x86-mce-no-NR_CPUS.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-mce-no-NR_CPUS.patch" Replace them with per-CPU data.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- 2010-06-15.orig/xen/arch/x86/cpu/mcheck/mce_intel.c = 2010-06-15 12:08:53.000000000 +0200=0A+++ 2010-06-15/xen/arch/x86/cpu/mchec= k/mce_intel.c 2010-07-06 14:55:29.000000000 +0200=0A@@ -40,13 +40,13 @@ = static void intel_thermal_interrupt(stru=0A {=0A uint64_t msr_content;= =0A unsigned int cpu =3D smp_processor_id();=0A- static s_time_t = next[NR_CPUS];=0A+ static DEFINE_PER_CPU(s_time_t, next);=0A =0A = ack_APIC_irq();=0A- if (NOW() < next[cpu])=0A+ if (NOW() < per_cpu(ne= xt, cpu))=0A return;=0A =0A- next[cpu] =3D NOW() + MILLISECS(500= 0);=0A+ per_cpu(next, cpu) =3D NOW() + MILLISECS(5000);=0A = rdmsrl(MSR_IA32_THERM_STATUS, msr_content);=0A if (msr_content & 0x1) = {=0A printk(KERN_EMERG "CPU%d: Temperature above threshold\n", = cpu);=0A--- 2010-06-15.orig/xen/arch/x86/cpu/mcheck/mctelem.c 2009-12-02 = 10:02:49.000000000 +0100=0A+++ 2010-06-15/xen/arch/x86/cpu/mcheck/mctelem.c= 2010-07-06 15:03:34.000000000 +0200=0A@@ -109,15 +109,19 @@ static = struct mc_telem_ctl {=0A * Telemetry array=0A */=0A struct = mctelem_ent *mctc_elems;=0A+} mctctl;=0A+=0A+struct mc_telem_cpu_ctl {=0A = /*=0A * Per-CPU processing lists, used for deferred (softirq)=0A- * = processing of telemetry. mctc_cpu is indexed by the=0A- * CPU that the = telemetry belongs to. mctc_cpu_processing=0A- * is indexed by the CPU = that is processing the telemetry.=0A+ * processing of telemetry. = @pending is indexed by the=0A+ * CPU that the telemetry belongs to. = @processing is indexed=0A+ * by the CPU that is processing the = telemetry.=0A */=0A- struct mctelem_ent *mctc_cpu[NR_CPUS];=0A- = struct mctelem_ent *mctc_cpu_processing[NR_CPUS];=0A-} mctctl;=0A+ = struct mctelem_ent *pending;=0A+ struct mctelem_ent *processing;=0A+= };=0A+static DEFINE_PER_CPU(struct mc_telem_cpu_ctl, mctctl);=0A =0A /* = Lock protecting all processing lists */=0A static DEFINE_SPINLOCK(processin= g_lock);=0A@@ -139,8 +143,7 @@ void mctelem_defer(mctelem_cookie_t cook=0A = {=0A struct mctelem_ent *tep =3D COOKIE2MCTE(cookie);=0A =0A- = mctelem_xchg_head(&mctctl.mctc_cpu[smp_processor_id()],=0A- = &tep->mcte_next, tep);=0A+ mctelem_xchg_head(&this_cpu(mctctl.pending)= , &tep->mcte_next, tep);=0A }=0A =0A void mctelem_process_deferred(unsigned= int cpu,=0A@@ -154,10 +157,10 @@ void mctelem_process_deferred(unsigned = i=0A * First, unhook the list of telemetry structures, and =0A * = hook it up to the processing list head for this CPU.=0A */=0A- = mctelem_xchg_head(&mctctl.mctc_cpu[cpu],=0A- &mctctl.mctc_cpu_proces= sing[smp_processor_id()], NULL);=0A+ mctelem_xchg_head(&per_cpu(mctctl.p= ending, cpu),=0A+ &this_cpu(mctctl.processing), = NULL);=0A =0A- head =3D mctctl.mctc_cpu_processing[smp_processor_id()];=0A= + head =3D this_cpu(mctctl.processing);=0A =0A /*=0A * Then, = fix up the list to include prev pointers, to make=0A@@ -193,7 +196,7 @@ = void mctelem_process_deferred(unsigned i=0A =0A int mctelem_has_deferred(un= signed int cpu)=0A {=0A- if (mctctl.mctc_cpu[cpu] !=3D NULL)=0A+ if = (per_cpu(mctctl.pending, cpu) !=3D NULL)=0A return 1;=0A = return 0;=0A }=0A --=__Part0A277EF5.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__Part0A277EF5.0__=--