From: "Jan Beulich" Subject: [PATCH] linux: panic/shutdown handling adjustments Date: Thu, 25 Oct 2007 10:42:05 +0100 Message-ID: <4720810D.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 Prevent interrupts (and hence possibly scheduler operations) from occuring on (against) a CPU after removing it from cpu_online_map during panic/shutdown. (Background: I found it quite annoying to see scheduler related badness or BUG messages after a panic, eventually even leading to important information scrolling off the screen.) As usual, written and tested against 2.6.23 and made apply against 2.6.18 without further testing. Signed-off-by: Jan Beulich Index: head-2007-10-15/arch/i386/kernel/smp-xen.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 --- head-2007-10-15.orig/arch/i386/kernel/smp-xen.c 2007-10-18 = 16:47:18.000000000 +0200 +++ head-2007-10-15/arch/i386/kernel/smp-xen.c 2007-10-18 16:56:49.0000000= 00 +0200 @@ -595,9 +595,7 @@ static void stop_this_cpu (void * dummy) */ cpu_clear(smp_processor_id(), cpu_online_map); local_irq_disable(); -#if 0 - disable_local_APIC(); -#endif + mask_evtchn_local(); if (cpu_data[smp_processor_id()].hlt_works_ok) for(;;) halt(); for (;;); @@ -617,9 +615,7 @@ void xen_smp_send_stop(void) smp_call_function(stop_this_cpu, NULL, 1, 0); =20 local_irq_disable(); -#if 0 - disable_local_APIC(); -#endif + mask_evtchn_local(); local_irq_enable(); } =20 Index: head-2007-10-15/arch/x86_64/kernel/smp-xen.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 --- head-2007-10-15.orig/arch/x86_64/kernel/smp-xen.c 2007-10-18 = 11:55:23.000000000 +0200 +++ head-2007-10-15/arch/x86_64/kernel/smp-xen.c 2007-10-18 = 16:56:49.000000000 +0200 @@ -488,9 +488,7 @@ void smp_stop_cpu(void) */ cpu_clear(smp_processor_id(), cpu_online_map); local_irq_save(flags); -#ifndef CONFIG_XEN - disable_local_APIC(); -#endif + mask_evtchn_local(); local_irq_restore(flags);=20 } =20 @@ -511,9 +509,7 @@ void smp_send_stop(void) spin_unlock(&call_lock); =20 local_irq_disable(); -#ifndef CONFIG_XEN - disable_local_APIC(); -#endif + mask_evtchn_local(); local_irq_enable(); } =20 Index: head-2007-10-15/drivers/xen/core/evtchn.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 --- head-2007-10-15.orig/drivers/xen/core/evtchn.c 2007-10-18 = 11:22:50.000000000 +0200 +++ head-2007-10-15/drivers/xen/core/evtchn.c 2007-10-18 16:56:49.0000000= 00 +0200 @@ -157,6 +157,16 @@ static inline unsigned int cpu_from_evtc return cpu_evtchn[evtchn]; } =20 +void mask_evtchn_local(void) +{ + unsigned i, cpu =3D smp_processor_id(); + shared_info_t *s =3D HYPERVISOR_shared_info; + + for (i =3D 0; i < NR_EVENT_CHANNELS; ++i) + if (cpu_evtchn[i] =3D=3D cpu) + synch_set_bit(i, &s->evtchn_mask[0]); +} + #else =20 static inline unsigned long active_evtchns(unsigned int cpu, shared_info_t= *sh, Index: head-2007-10-15/include/xen/evtchn.h =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 --- head-2007-10-15.orig/include/xen/evtchn.h 2007-10-18 11:22:48.0000000= 00 +0200 +++ head-2007-10-15/include/xen/evtchn.h 2007-10-18 16:58:01.0000000= 00 +0200 @@ -102,6 +102,7 @@ asmlinkage void evtchn_do_upcall(struct=20 void evtchn_device_upcall(int port); =20 void mask_evtchn(int port); +void mask_evtchn_local(void); void unmask_evtchn(int port); =20 #ifdef CONFIG_SMP