ia64/xen-unstable

changeset 10214:e58e04589d11

Define halt() and safe_halt() properly for Linux-on-Xen. Remove duplicated
code for initial bringup of secondary VCPUs.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue May 30 13:29:29 2006 +0100 (2006-05-30)
parents 6a3462993320
children c43080e63545
files linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c linux-2.6-xen-sparse/drivers/xen/core/smpboot.c linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/system.h linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/system.h linux-2.6-xen-sparse/include/xen/cpu_hotplug.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c	Tue May 30 12:37:49 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c	Tue May 30 13:29:29 2006 +0100
     1.3 @@ -55,6 +55,7 @@
     1.4  
     1.5  #include <xen/interface/physdev.h>
     1.6  #include <xen/interface/vcpu.h>
     1.7 +#include <xen/cpu_hotplug.h>
     1.8  
     1.9  #include <linux/err.h>
    1.10  
    1.11 @@ -101,8 +102,6 @@ void enable_hlt(void)
    1.12  EXPORT_SYMBOL(enable_hlt);
    1.13  
    1.14  /* XXX XEN doesn't use default_idle(), poll_idle(). Use xen_idle() instead. */
    1.15 -extern void stop_hz_timer(void);
    1.16 -extern void start_hz_timer(void);
    1.17  void xen_idle(void)
    1.18  {
    1.19  	local_irq_disable();
    1.20 @@ -112,10 +111,7 @@ void xen_idle(void)
    1.21  	else {
    1.22  		clear_thread_flag(TIF_POLLING_NRFLAG);
    1.23  		smp_mb__after_clear_bit();
    1.24 -		stop_hz_timer();
    1.25 -		/* Blocking includes an implicit local_irq_enable(). */
    1.26 -		HYPERVISOR_block();
    1.27 -		start_hz_timer();
    1.28 +		safe_halt();
    1.29  		set_thread_flag(TIF_POLLING_NRFLAG);
    1.30  	}
    1.31  }
    1.32 @@ -132,11 +128,7 @@ static inline void play_dead(void)
    1.33  	cpu_clear(smp_processor_id(), cpu_initialized);
    1.34  	preempt_enable_no_resched();
    1.35  	HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL);
    1.36 -	/* Same as drivers/xen/core/smpboot.c:cpu_bringup(). */
    1.37 -	cpu_init();
    1.38 -	touch_softlockup_watchdog();
    1.39 -	preempt_disable();
    1.40 -	local_irq_enable();
    1.41 +	cpu_bringup();
    1.42  }
    1.43  #else
    1.44  static inline void play_dead(void)
     2.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Tue May 30 12:37:49 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Tue May 30 13:29:29 2006 +0100
     2.3 @@ -973,7 +973,7 @@ EXPORT_SYMBOL(jiffies_to_st);
     2.4   * stop_hz_timer / start_hz_timer - enter/exit 'tickless mode' on an idle cpu
     2.5   * These functions are based on implementations from arch/s390/kernel/time.c
     2.6   */
     2.7 -void stop_hz_timer(void)
     2.8 +static void stop_hz_timer(void)
     2.9  {
    2.10  	unsigned int cpu = smp_processor_id();
    2.11  	unsigned long j;
    2.12 @@ -993,11 +993,27 @@ void stop_hz_timer(void)
    2.13  	BUG_ON(HYPERVISOR_set_timer_op(jiffies_to_st(j)) != 0);
    2.14  }
    2.15  
    2.16 -void start_hz_timer(void)
    2.17 +static void start_hz_timer(void)
    2.18  {
    2.19  	cpu_clear(smp_processor_id(), nohz_cpu_mask);
    2.20  }
    2.21  
    2.22 +void safe_halt(void)
    2.23 +{
    2.24 +	stop_hz_timer();
    2.25 +	/* Blocking includes an implicit local_irq_enable(). */
    2.26 +	HYPERVISOR_block();
    2.27 +	start_hz_timer();
    2.28 +}
    2.29 +EXPORT_SYMBOL(safe_halt);
    2.30 +
    2.31 +void halt(void)
    2.32 +{
    2.33 +	if (irqs_disabled())
    2.34 +		HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL);
    2.35 +}
    2.36 +EXPORT_SYMBOL(halt);
    2.37 +
    2.38  /* No locking required. We are only CPU running, and interrupts are off. */
    2.39  void time_resume(void)
    2.40  {
     3.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c	Tue May 30 12:37:49 2006 +0100
     3.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c	Tue May 30 13:29:29 2006 +0100
     3.3 @@ -60,6 +60,8 @@
     3.4  #include <asm/ia32.h>
     3.5  #include <asm/idle.h>
     3.6  
     3.7 +#include <xen/cpu_hotplug.h>
     3.8 +
     3.9  asmlinkage extern void ret_from_fork(void);
    3.10  
    3.11  unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED;
    3.12 @@ -118,8 +120,6 @@ void exit_idle(void)
    3.13  }
    3.14  
    3.15  /* XXX XEN doesn't use default_idle(), poll_idle(). Use xen_idle() instead. */
    3.16 -extern void stop_hz_timer(void);
    3.17 -extern void start_hz_timer(void);
    3.18  void xen_idle(void)
    3.19  {
    3.20  	local_irq_disable();
    3.21 @@ -129,10 +129,7 @@ void xen_idle(void)
    3.22  	else {
    3.23  		clear_thread_flag(TIF_POLLING_NRFLAG);
    3.24  		smp_mb__after_clear_bit();
    3.25 -		stop_hz_timer();
    3.26 -		/* Blocking includes an implicit local_irq_enable(). */
    3.27 -		HYPERVISOR_block();
    3.28 -		start_hz_timer();
    3.29 +		safe_halt();
    3.30  		set_thread_flag(TIF_POLLING_NRFLAG);
    3.31  	}
    3.32  }
    3.33 @@ -145,11 +142,7 @@ static inline void play_dead(void)
    3.34  	cpu_clear(smp_processor_id(), cpu_initialized);
    3.35  	preempt_enable_no_resched();
    3.36  	HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL);
    3.37 -	/* Same as drivers/xen/core/smpboot.c:cpu_bringup(). */
    3.38 -	cpu_init();
    3.39 -	touch_softlockup_watchdog();
    3.40 -	preempt_disable();
    3.41 -	local_irq_enable();
    3.42 +	cpu_bringup();
    3.43  }
    3.44  #else
    3.45  static inline void play_dead(void)
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c	Tue May 30 12:37:49 2006 +0100
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c	Tue May 30 13:29:29 2006 +0100
     4.3 @@ -150,12 +150,17 @@ static void xen_smp_intr_exit(unsigned i
     4.4  }
     4.5  #endif
     4.6  
     4.7 -static void cpu_bringup(void)
     4.8 +void cpu_bringup(void)
     4.9  {
    4.10  	cpu_init();
    4.11  	touch_softlockup_watchdog();
    4.12  	preempt_disable();
    4.13  	local_irq_enable();
    4.14 +}
    4.15 +
    4.16 +static void cpu_bringup_and_idle(void)
    4.17 +{
    4.18 +	cpu_bringup();
    4.19  	cpu_idle();
    4.20  }
    4.21  
    4.22 @@ -180,7 +185,7 @@ void cpu_initialize_context(unsigned int
    4.23  	ctxt.user_regs.fs = 0;
    4.24  	ctxt.user_regs.gs = 0;
    4.25  	ctxt.user_regs.ss = __KERNEL_DS;
    4.26 -	ctxt.user_regs.eip = (unsigned long)cpu_bringup;
    4.27 +	ctxt.user_regs.eip = (unsigned long)cpu_bringup_and_idle;
    4.28  	ctxt.user_regs.eflags = X86_EFLAGS_IF | 0x1000; /* IOPL_RING1 */
    4.29  
    4.30  	memset(&ctxt.fpu_ctxt, 0, sizeof(ctxt.fpu_ctxt));
     5.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/system.h	Tue May 30 12:37:49 2006 +0100
     5.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/system.h	Tue May 30 13:29:29 2006 +0100
     5.3 @@ -625,8 +625,8 @@ do {									\
     5.4  		preempt_enable_no_resched();				\
     5.5  } while (0)
     5.6  
     5.7 -#define safe_halt()		((void)0)
     5.8 -#define halt()			((void)0)
     5.9 +void safe_halt(void);
    5.10 +void halt(void);
    5.11  
    5.12  #define __save_and_cli(x)						\
    5.13  do {									\
     6.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/system.h	Tue May 30 12:37:49 2006 +0100
     6.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/system.h	Tue May 30 13:29:29 2006 +0100
     6.3 @@ -424,8 +424,8 @@ do {									\
     6.4  	preempt_enable_no_resched();					\
     6.5  	___x; })
     6.6  
     6.7 -#define safe_halt()		((void)0)
     6.8 -#define halt()			((void)0)
     6.9 +void safe_halt(void);
    6.10 +void halt(void);
    6.11  
    6.12  void cpu_idle_wait(void);
    6.13  
     7.1 --- a/linux-2.6-xen-sparse/include/xen/cpu_hotplug.h	Tue May 30 12:37:49 2006 +0100
     7.2 +++ b/linux-2.6-xen-sparse/include/xen/cpu_hotplug.h	Tue May 30 13:29:29 2006 +0100
     7.3 @@ -18,6 +18,8 @@ void init_xenbus_allowed_cpumask(void);
     7.4  int smp_suspend(void);
     7.5  void smp_resume(void);
     7.6  
     7.7 +void cpu_bringup(void);
     7.8 +
     7.9  #else /* !defined(CONFIG_HOTPLUG_CPU) */
    7.10  
    7.11  #define cpu_up_check(cpu)		(0)