ia64/xen-unstable

changeset 17056:e1dde6f8bc87

xen: Clean up SMP/hotplug headers and implementation a bit.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Feb 13 18:30:12 2008 +0000 (2008-02-13)
parents e7085b40dc08
children b9b6caf06f8c
files xen/arch/x86/smpboot.c xen/common/stop_machine.c xen/include/xen/smp.h xen/include/xen/stop_machine.h
line diff
     1.1 --- a/xen/arch/x86/smpboot.c	Wed Feb 13 18:09:27 2008 +0000
     1.2 +++ b/xen/arch/x86/smpboot.c	Wed Feb 13 18:30:12 2008 +0000
     1.3 @@ -112,7 +112,7 @@ static void map_cpu_to_logical_apicid(vo
     1.4  DEFINE_PER_CPU(int, cpu_state) = { 0 };
     1.5  
     1.6  static void *stack_base[NR_CPUS] __cacheline_aligned;
     1.7 -spinlock_t cpu_add_remove_lock;
     1.8 +static DEFINE_SPINLOCK(cpu_add_remove_lock);
     1.9  
    1.10  /*
    1.11   * The bootstrap kernel entry code has set these up. Save them for
    1.12 @@ -1164,7 +1164,6 @@ void __devinit smp_prepare_boot_cpu(void
    1.13  	cpu_set(smp_processor_id(), cpu_present_map);
    1.14  	cpu_set(smp_processor_id(), cpu_possible_map);
    1.15  	per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
    1.16 -	spin_lock_init(&cpu_add_remove_lock);
    1.17  }
    1.18  
    1.19  #ifdef CONFIG_HOTPLUG_CPU
    1.20 @@ -1298,7 +1297,7 @@ int cpu_down(unsigned int cpu)
    1.21  
    1.22  	printk("Prepare to bring CPU%d down...\n", cpu);
    1.23  
    1.24 -	err = __stop_machine_run(take_cpu_down, NULL, cpu);
    1.25 +	err = stop_machine_run(take_cpu_down, NULL, cpu);
    1.26  	if ( err < 0 )
    1.27  		goto out;
    1.28  
     2.1 --- a/xen/common/stop_machine.c	Wed Feb 13 18:09:27 2008 +0000
     2.2 +++ b/xen/common/stop_machine.c	Wed Feb 13 18:30:12 2008 +0000
     2.3 @@ -22,12 +22,13 @@
     2.4  
     2.5  #include <xen/config.h>
     2.6  #include <xen/init.h>
     2.7 +#include <xen/sched.h>
     2.8  #include <xen/spinlock.h>
     2.9 -#include <asm/smp.h>
    2.10 +#include <xen/softirq.h>
    2.11 +#include <xen/errno.h>
    2.12 +#include <xen/smp.h>
    2.13  #include <asm/current.h>
    2.14 -#include <xen/softirq.h>
    2.15  #include <asm/processor.h>
    2.16 -#include <xen/errno.h>
    2.17  
    2.18  enum stopmachine_state {
    2.19      STOPMACHINE_START,
    2.20 @@ -61,7 +62,7 @@ static void stopmachine_set_state(enum s
    2.21          cpu_relax();
    2.22  }
    2.23  
    2.24 -int __stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu)
    2.25 +int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu)
    2.26  {
    2.27      cpumask_t allbutself;
    2.28      unsigned int i, nr_cpus;
    2.29 @@ -116,17 +117,6 @@ int __stop_machine_run(int (*fn)(void *)
    2.30      return ret;
    2.31  }
    2.32  
    2.33 -int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu)
    2.34 -{
    2.35 -    int ret;
    2.36 -
    2.37 -    lock_cpu_hotplug();
    2.38 -    ret = __stop_machine_run(fn, data, cpu);
    2.39 -    unlock_cpu_hotplug();
    2.40 -
    2.41 -    return ret;
    2.42 -}
    2.43 -
    2.44  static void stopmachine_softirq(void)
    2.45  {
    2.46      enum stopmachine_state state = STOPMACHINE_START;
     3.1 --- a/xen/include/xen/smp.h	Wed Feb 13 18:09:27 2008 +0000
     3.2 +++ b/xen/include/xen/smp.h	Wed Feb 13 18:30:12 2008 +0000
     3.3 @@ -1,23 +1,10 @@
     3.4 -#ifndef __LINUX_SMP_H
     3.5 -#define __LINUX_SMP_H
     3.6 -
     3.7 -/*
     3.8 - *	Generic SMP support
     3.9 - *		Alan Cox. <alan@redhat.com>
    3.10 - */
    3.11 +#ifndef __XEN_SMP_H__
    3.12 +#define __XEN_SMP_H__
    3.13  
    3.14  #include <xen/config.h>
    3.15 -
    3.16 -#ifdef CONFIG_SMP
    3.17 -
    3.18  #include <asm/smp.h>
    3.19  
    3.20  /*
    3.21 - * main cross-CPU interfaces, handles INIT, TLB flush, STOP, etc.
    3.22 - * (defined in asm header):
    3.23 - */ 
    3.24 -
    3.25 -/*
    3.26   * stops all CPUs but the current one:
    3.27   */
    3.28  extern void smp_send_stop(void);
    3.29 @@ -66,38 +53,6 @@ extern int on_selected_cpus(
    3.30   */
    3.31  void smp_prepare_boot_cpu(void);
    3.32  
    3.33 -#else
    3.34 -
    3.35 -/*
    3.36 - *	These macros fold the SMP functionality into a single CPU system
    3.37 - */
    3.38 -
    3.39 -#define smp_send_event_check_mask(m)            ((void)0)
    3.40 -#define smp_send_event_check_cpu(p)             ((void)0) 
    3.41 -#define raw_smp_processor_id()			0
    3.42 -#define hard_smp_processor_id()			0
    3.43 -#define smp_call_function(func,info,retry,wait)	({ do {} while (0); 0; })
    3.44 -#define num_booting_cpus()			1
    3.45 -#define smp_prepare_boot_cpu()			do {} while (0)
    3.46 -
    3.47 -static inline int on_selected_cpus(
    3.48 -    cpumask_t selected,
    3.49 -    void (*func) (void *info),
    3.50 -    void *info,
    3.51 -    int retry,
    3.52 -    int wait)
    3.53 -{
    3.54 -    if ( cpu_isset(0, selected) )
    3.55 -    {
    3.56 -        local_irq_disable();
    3.57 -        func(info);
    3.58 -        local_irq_enable();
    3.59 -    }
    3.60 -    return 0;
    3.61 -}
    3.62 -
    3.63 -#endif
    3.64 -
    3.65  /*
    3.66   * Call a function on all processors
    3.67   */
    3.68 @@ -112,21 +67,8 @@ static inline int on_each_cpu(
    3.69  
    3.70  #define smp_processor_id() raw_smp_processor_id()
    3.71  
    3.72 -#ifdef CONFIG_HOTPLUG_CPU
    3.73 -extern spinlock_t cpu_add_remove_lock;
    3.74 -/*
    3.75 - * FIXME: need a better lock mechanism when real cpu hotplug is later
    3.76 - * supported, since spinlock may cause dead lock:
    3.77 - *     cpu0: in stop_machine with lock held. Wait for cpu1 to respond
    3.78 - *           to stop request
    3.79 - *     cpu1: spin loop on lock upon cpu hotplug request from guest,
    3.80 - *           without chance to handle softirq
    3.81 - * ...
    3.82 - */
    3.83 -#define lock_cpu_hotplug() spin_lock(&cpu_add_remove_lock);
    3.84 -#define unlock_cpu_hotplug() spin_unlock(&cpu_add_remove_lock);
    3.85 -#else
    3.86 -#define lock_cpu_hotplug() do { } while ( 0 )
    3.87 -#define unlock_cpu_hotplug() do { } while ( 0 )
    3.88 -#endif
    3.89 -#endif
    3.90 +/* No Xen contexts can be preempted by CPU hotplug. */
    3.91 +#define lock_cpu_hotplug() ((void)0)
    3.92 +#define unlock_cpu_hotplug() ((void)0)
    3.93 +
    3.94 +#endif /* __XEN_SMP_H__ */
     4.1 --- a/xen/include/xen/stop_machine.h	Wed Feb 13 18:09:27 2008 +0000
     4.2 +++ b/xen/include/xen/stop_machine.h	Wed Feb 13 18:30:12 2008 +0000
     4.3 @@ -16,15 +16,4 @@
     4.4   * grabbing every spinlock in the kernel. */
     4.5  int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu);
     4.6  
     4.7 -/**
     4.8 - * __stop_machine_run: freeze the machine on all CPUs and run this function
     4.9 - * @fn: the function to run
    4.10 - * @data: the data ptr for the @fn
    4.11 - * @cpu: the cpu to run @fn on (or any, if @cpu == NR_CPUS.
    4.12 - *
    4.13 - * Description: This is a special version of the above, without explicit
    4.14 - * lock acquisition. Used by hotplug cpu.
    4.15 - */
    4.16 -int __stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu);
    4.17 -
    4.18  #endif /* __XEN_STOP_MACHINE_H__ */