direct-io.hg

changeset 10139:606db2959bd6

Move Xen CPU hotplug code into new file cpu_hotplug.c.
Cleaner and allows use by architectures which aren't currently
using Xen's smpboot.c.

Based on an original patch by Tristan Gingold.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue May 23 12:05:08 2006 +0100 (2006-05-23)
parents 2d08d6db792b
children 4c14bca8ca93
files linux-2.6-xen-sparse/drivers/xen/core/Makefile linux-2.6-xen-sparse/drivers/xen/core/cpu_hotplug.c linux-2.6-xen-sparse/drivers/xen/core/reboot.c linux-2.6-xen-sparse/drivers/xen/core/smpboot.c linux-2.6-xen-sparse/include/xen/cpu_hotplug.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/Makefile	Mon May 22 15:08:26 2006 -0600
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/Makefile	Tue May 23 12:05:08 2006 +0100
     1.3 @@ -4,8 +4,9 @@
     1.4  
     1.5  obj-y   := evtchn.o reboot.o gnttab.o features.o
     1.6  
     1.7 -obj-$(CONFIG_PROC_FS) += xen_proc.o
     1.8 -obj-$(CONFIG_NET)     += skbuff.o
     1.9 -obj-$(CONFIG_SMP)     += smpboot.o
    1.10 -obj-$(CONFIG_SYSFS)   += hypervisor_sysfs.o
    1.11 -obj-$(CONFIG_XEN_SYSFS) += xen_sysfs.o
    1.12 +obj-$(CONFIG_PROC_FS)     += xen_proc.o
    1.13 +obj-$(CONFIG_NET)         += skbuff.o
    1.14 +obj-$(CONFIG_SMP)         += smpboot.o
    1.15 +obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o
    1.16 +obj-$(CONFIG_SYSFS)       += hypervisor_sysfs.o
    1.17 +obj-$(CONFIG_XEN_SYSFS)   += xen_sysfs.o
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/cpu_hotplug.c	Tue May 23 12:05:08 2006 +0100
     2.3 @@ -0,0 +1,185 @@
     2.4 +#include <linux/config.h>
     2.5 +#include <linux/init.h>
     2.6 +#include <linux/kernel.h>
     2.7 +#include <linux/sched.h>
     2.8 +#include <linux/notifier.h>
     2.9 +#include <linux/cpu.h>
    2.10 +#include <xen/cpu_hotplug.h>
    2.11 +#include <xen/xenbus.h>
    2.12 +
    2.13 +/*
    2.14 + * Set of CPUs that remote admin software will allow us to bring online.
    2.15 + * Notified to us via xenbus.
    2.16 + */
    2.17 +static cpumask_t xenbus_allowed_cpumask;
    2.18 +
    2.19 +/* Set of CPUs that local admin will allow us to bring online. */
    2.20 +static cpumask_t local_allowed_cpumask = CPU_MASK_ALL;
    2.21 +
    2.22 +static int local_cpu_hotplug_request(void)
    2.23 +{
    2.24 +	/*
    2.25 +	 * We assume a CPU hotplug request comes from local admin if it is made
    2.26 +	 * via a userspace process (i.e., one with a real mm_struct).
    2.27 +	 */
    2.28 +	return (current->mm != NULL);
    2.29 +}
    2.30 +
    2.31 +static void vcpu_hotplug(unsigned int cpu)
    2.32 +{
    2.33 +	int err;
    2.34 +	char dir[32], state[32];
    2.35 +
    2.36 +	if ((cpu >= NR_CPUS) || !cpu_possible(cpu))
    2.37 +		return;
    2.38 +
    2.39 +	sprintf(dir, "cpu/%d", cpu);
    2.40 +	err = xenbus_scanf(XBT_NULL, dir, "availability", "%s", state);
    2.41 +	if (err != 1) {
    2.42 +		printk(KERN_ERR "XENBUS: Unable to read cpu state\n");
    2.43 +		return;
    2.44 +	}
    2.45 +
    2.46 +	if (strcmp(state, "online") == 0) {
    2.47 +		cpu_set(cpu, xenbus_allowed_cpumask);
    2.48 +		(void)cpu_up(cpu);
    2.49 +	} else if (strcmp(state, "offline") == 0) {
    2.50 +		cpu_clear(cpu, xenbus_allowed_cpumask);
    2.51 +		(void)cpu_down(cpu);
    2.52 +	} else {
    2.53 +		printk(KERN_ERR "XENBUS: unknown state(%s) on CPU%d\n",
    2.54 +		       state, cpu);
    2.55 +	}
    2.56 +}
    2.57 +
    2.58 +static void handle_vcpu_hotplug_event(
    2.59 +	struct xenbus_watch *watch, const char **vec, unsigned int len)
    2.60 +{
    2.61 +	int cpu;
    2.62 +	char *cpustr;
    2.63 +	const char *node = vec[XS_WATCH_PATH];
    2.64 +
    2.65 +	if ((cpustr = strstr(node, "cpu/")) != NULL) {
    2.66 +		sscanf(cpustr, "cpu/%d", &cpu);
    2.67 +		vcpu_hotplug(cpu);
    2.68 +	}
    2.69 +}
    2.70 +
    2.71 +static int smpboot_cpu_notify(struct notifier_block *notifier,
    2.72 +			      unsigned long action, void *hcpu)
    2.73 +{
    2.74 +	int cpu = (long)hcpu;
    2.75 +
    2.76 +	/*
    2.77 +	 * We do this in a callback notifier rather than __cpu_disable()
    2.78 +	 * because local_cpu_hotplug_request() does not work in the latter
    2.79 +	 * as it's always executed from within a stopmachine kthread.
    2.80 +	 */
    2.81 +	if ((action == CPU_DOWN_PREPARE) && local_cpu_hotplug_request())
    2.82 +		cpu_clear(cpu, local_allowed_cpumask);
    2.83 +
    2.84 +	return NOTIFY_OK;
    2.85 +}
    2.86 +
    2.87 +static int setup_cpu_watcher(struct notifier_block *notifier,
    2.88 +			      unsigned long event, void *data)
    2.89 +{
    2.90 +	int i;
    2.91 +
    2.92 +	static struct xenbus_watch cpu_watch = {
    2.93 +		.node = "cpu",
    2.94 +		.callback = handle_vcpu_hotplug_event,
    2.95 +		.flags = XBWF_new_thread };
    2.96 +	(void)register_xenbus_watch(&cpu_watch);
    2.97 +
    2.98 +	if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
    2.99 +		for_each_cpu(i)
   2.100 +			vcpu_hotplug(i);
   2.101 +		printk(KERN_INFO "Brought up %ld CPUs\n",
   2.102 +		       (long)num_online_cpus());
   2.103 +	}
   2.104 +
   2.105 +	return NOTIFY_DONE;
   2.106 +}
   2.107 +
   2.108 +static int __init setup_vcpu_hotplug_event(void)
   2.109 +{
   2.110 +	static struct notifier_block hotplug_cpu = {
   2.111 +		.notifier_call = smpboot_cpu_notify };
   2.112 +	static struct notifier_block xsn_cpu = {
   2.113 +		.notifier_call = setup_cpu_watcher };
   2.114 +
   2.115 +	register_cpu_notifier(&hotplug_cpu);
   2.116 +	register_xenstore_notifier(&xsn_cpu);
   2.117 +
   2.118 +	return 0;
   2.119 +}
   2.120 +
   2.121 +arch_initcall(setup_vcpu_hotplug_event);
   2.122 +
   2.123 +int smp_suspend(void)
   2.124 +{
   2.125 +	int i, err;
   2.126 +
   2.127 +	lock_cpu_hotplug();
   2.128 +
   2.129 +	/*
   2.130 +	 * Take all other CPUs offline. We hold the hotplug mutex to
   2.131 +	 * avoid other processes bringing up CPUs under our feet.
   2.132 +	 */
   2.133 +	while (num_online_cpus() > 1) {
   2.134 +		unlock_cpu_hotplug();
   2.135 +		for_each_online_cpu(i) {
   2.136 +			if (i == 0)
   2.137 +				continue;
   2.138 +			err = cpu_down(i);
   2.139 +			if (err) {
   2.140 +				printk(KERN_CRIT "Failed to take all CPUs "
   2.141 +				       "down: %d.\n", err);
   2.142 +				for_each_cpu(i)
   2.143 +					vcpu_hotplug(i);
   2.144 +				return err;
   2.145 +			}
   2.146 +		}
   2.147 +		lock_cpu_hotplug();
   2.148 +	}
   2.149 +
   2.150 +	return 0;
   2.151 +}
   2.152 +
   2.153 +void smp_resume(void)
   2.154 +{
   2.155 +	int cpu;
   2.156 +
   2.157 +	for_each_cpu(cpu)
   2.158 +		cpu_initialize_context(cpu);
   2.159 +
   2.160 +	unlock_cpu_hotplug();
   2.161 +
   2.162 +	for_each_cpu(cpu)
   2.163 +		vcpu_hotplug(cpu);
   2.164 +}
   2.165 +
   2.166 +int cpu_up_is_allowed(unsigned int cpu)
   2.167 +{
   2.168 +	int rc = 0;
   2.169 +
   2.170 +	if (local_cpu_hotplug_request()) {
   2.171 +		cpu_set(cpu, local_allowed_cpumask);
   2.172 +		if (!cpu_isset(cpu, xenbus_allowed_cpumask)) {
   2.173 +			printk("%s: attempt to bring up CPU %u disallowed by "
   2.174 +			       "remote admin.\n", __FUNCTION__, cpu);
   2.175 +			rc = -EBUSY;
   2.176 +		}
   2.177 +	} else if (!cpu_isset(cpu, local_allowed_cpumask) ||
   2.178 +		   !cpu_isset(cpu, xenbus_allowed_cpumask)) {
   2.179 +		rc = -EBUSY;
   2.180 +	}
   2.181 +
   2.182 +	return rc;
   2.183 +}
   2.184 +
   2.185 +void init_xenbus_allowed_cpumask(void)
   2.186 +{
   2.187 +	xenbus_allowed_cpumask = cpu_present_map;
   2.188 +}
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Mon May 22 15:08:26 2006 -0600
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Tue May 23 12:05:08 2006 +0100
     3.3 @@ -17,6 +17,7 @@
     3.4  #include <linux/kthread.h>
     3.5  #include <xen/gnttab.h>
     3.6  #include <xen/xencons.h>
     3.7 +#include <xen/cpu_hotplug.h>
     3.8  
     3.9  #if defined(__i386__) || defined(__x86_64__)
    3.10  /*
    3.11 @@ -81,14 +82,6 @@ static int shutting_down = SHUTDOWN_INVA
    3.12  static void __shutdown_handler(void *unused);
    3.13  static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL);
    3.14  
    3.15 -#ifdef CONFIG_SMP
    3.16 -int  smp_suspend(void);
    3.17 -void smp_resume(void);
    3.18 -#else
    3.19 -#define smp_suspend()	(0)
    3.20 -#define smp_resume()	((void)0)
    3.21 -#endif
    3.22 -
    3.23  /* Ensure we run on the idle task page tables so that we will
    3.24     switch page tables before running user space. This is needed
    3.25     on architectures with separate kernel and user page tables
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c	Mon May 22 15:08:26 2006 -0600
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c	Tue May 23 12:05:08 2006 +0100
     4.3 @@ -23,6 +23,7 @@
     4.4  #include <asm/pgalloc.h>
     4.5  #include <xen/evtchn.h>
     4.6  #include <xen/interface/vcpu.h>
     4.7 +#include <xen/cpu_hotplug.h>
     4.8  #include <xen/xenbus.h>
     4.9  
    4.10  #ifdef CONFIG_SMP_ALTERNATIVES
    4.11 @@ -79,15 +80,6 @@ EXPORT_SYMBOL(x86_cpu_to_apicid);
    4.12  unsigned int maxcpus = NR_CPUS;
    4.13  #endif
    4.14  
    4.15 -/*
    4.16 - * Set of CPUs that remote admin software will allow us to bring online.
    4.17 - * Notified to us via xenbus.
    4.18 - */
    4.19 -static cpumask_t xenbus_allowed_cpumask;
    4.20 -
    4.21 -/* Set of CPUs that local admin will allow us to bring online. */
    4.22 -static cpumask_t local_allowed_cpumask = CPU_MASK_ALL;
    4.23 -
    4.24  void __init prefill_possible_map(void)
    4.25  {
    4.26  	int i, rc;
    4.27 @@ -167,17 +159,17 @@ static void cpu_bringup(void)
    4.28  	cpu_idle();
    4.29  }
    4.30  
    4.31 -static void vcpu_prepare(int vcpu)
    4.32 +void cpu_initialize_context(unsigned int cpu)
    4.33  {
    4.34  	vcpu_guest_context_t ctxt;
    4.35 -	struct task_struct *idle = idle_task(vcpu);
    4.36 +	struct task_struct *idle = idle_task(cpu);
    4.37  #ifdef __x86_64__
    4.38 -	struct desc_ptr *gdt_descr = &cpu_gdt_descr[vcpu];
    4.39 +	struct desc_ptr *gdt_descr = &cpu_gdt_descr[cpu];
    4.40  #else
    4.41 -	struct Xgt_desc_struct *gdt_descr = &per_cpu(cpu_gdt_descr, vcpu);
    4.42 +	struct Xgt_desc_struct *gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
    4.43  #endif
    4.44  
    4.45 -	if (vcpu == 0)
    4.46 +	if (cpu == 0)
    4.47  		return;
    4.48  
    4.49  	memset(&ctxt, 0, sizeof(ctxt));
    4.50 @@ -226,10 +218,10 @@ static void vcpu_prepare(int vcpu)
    4.51  
    4.52  	ctxt.ctrlreg[3] = virt_to_mfn(init_level4_pgt) << PAGE_SHIFT;
    4.53  
    4.54 -	ctxt.gs_base_kernel = (unsigned long)(cpu_pda(vcpu));
    4.55 +	ctxt.gs_base_kernel = (unsigned long)(cpu_pda(cpu));
    4.56  #endif
    4.57  
    4.58 -	BUG_ON(HYPERVISOR_vcpu_op(VCPUOP_initialise, vcpu, &ctxt));
    4.59 +	BUG_ON(HYPERVISOR_vcpu_op(VCPUOP_initialise, cpu, &ctxt));
    4.60  }
    4.61  
    4.62  void __init smp_prepare_cpus(unsigned int max_cpus)
    4.63 @@ -304,10 +296,10 @@ void __init smp_prepare_cpus(unsigned in
    4.64  		cpu_set(cpu, cpu_present_map);
    4.65  #endif
    4.66  
    4.67 -		vcpu_prepare(cpu);
    4.68 +		cpu_initialize_context(cpu);
    4.69  	}
    4.70  
    4.71 -	xenbus_allowed_cpumask = cpu_present_map;
    4.72 +	init_xenbus_allowed_cpumask();
    4.73  
    4.74  	/* Currently, Xen gives no dynamic NUMA/HT info. */
    4.75  	for (cpu = 1; cpu < NR_CPUS; cpu++) {
    4.76 @@ -332,15 +324,6 @@ void __devinit smp_prepare_boot_cpu(void
    4.77  	cpu_online_map   = cpumask_of_cpu(0);
    4.78  }
    4.79  
    4.80 -static int local_cpu_hotplug_request(void)
    4.81 -{
    4.82 -	/*
    4.83 -	 * We assume a CPU hotplug request comes from local admin if it is made
    4.84 -	 * via a userspace process (i.e., one with a real mm_struct).
    4.85 -	 */
    4.86 -	return (current->mm != NULL);
    4.87 -}
    4.88 -
    4.89  #ifdef CONFIG_HOTPLUG_CPU
    4.90  
    4.91  /*
    4.92 @@ -355,141 +338,6 @@ static int __init initialize_cpu_present
    4.93  }
    4.94  core_initcall(initialize_cpu_present_map);
    4.95  
    4.96 -static void vcpu_hotplug(unsigned int cpu)
    4.97 -{
    4.98 -	int err;
    4.99 -	char dir[32], state[32];
   4.100 -
   4.101 -	if ((cpu >= NR_CPUS) || !cpu_possible(cpu))
   4.102 -		return;
   4.103 -
   4.104 -	sprintf(dir, "cpu/%d", cpu);
   4.105 -	err = xenbus_scanf(XBT_NULL, dir, "availability", "%s", state);
   4.106 -	if (err != 1) {
   4.107 -		printk(KERN_ERR "XENBUS: Unable to read cpu state\n");
   4.108 -		return;
   4.109 -	}
   4.110 -
   4.111 -	if (strcmp(state, "online") == 0) {
   4.112 -		cpu_set(cpu, xenbus_allowed_cpumask);
   4.113 -		(void)cpu_up(cpu);
   4.114 -	} else if (strcmp(state, "offline") == 0) {
   4.115 -		cpu_clear(cpu, xenbus_allowed_cpumask);
   4.116 -		(void)cpu_down(cpu);
   4.117 -	} else {
   4.118 -		printk(KERN_ERR "XENBUS: unknown state(%s) on CPU%d\n",
   4.119 -		       state, cpu);
   4.120 -	}
   4.121 -}
   4.122 -
   4.123 -static void handle_vcpu_hotplug_event(
   4.124 -	struct xenbus_watch *watch, const char **vec, unsigned int len)
   4.125 -{
   4.126 -	int cpu;
   4.127 -	char *cpustr;
   4.128 -	const char *node = vec[XS_WATCH_PATH];
   4.129 -
   4.130 -	if ((cpustr = strstr(node, "cpu/")) != NULL) {
   4.131 -		sscanf(cpustr, "cpu/%d", &cpu);
   4.132 -		vcpu_hotplug(cpu);
   4.133 -	}
   4.134 -}
   4.135 -
   4.136 -static int smpboot_cpu_notify(struct notifier_block *notifier,
   4.137 -			      unsigned long action, void *hcpu)
   4.138 -{
   4.139 -	int cpu = (long)hcpu;
   4.140 -
   4.141 -	/*
   4.142 -	 * We do this in a callback notifier rather than __cpu_disable()
   4.143 -	 * because local_cpu_hotplug_request() does not work in the latter
   4.144 -	 * as it's always executed from within a stopmachine kthread.
   4.145 -	 */
   4.146 -	if ((action == CPU_DOWN_PREPARE) && local_cpu_hotplug_request())
   4.147 -		cpu_clear(cpu, local_allowed_cpumask);
   4.148 -
   4.149 -	return NOTIFY_OK;
   4.150 -}
   4.151 -
   4.152 -static int setup_cpu_watcher(struct notifier_block *notifier,
   4.153 -			      unsigned long event, void *data)
   4.154 -{
   4.155 -	int i;
   4.156 -
   4.157 -	static struct xenbus_watch cpu_watch = {
   4.158 -		.node = "cpu",
   4.159 -		.callback = handle_vcpu_hotplug_event,
   4.160 -		.flags = XBWF_new_thread };
   4.161 -	(void)register_xenbus_watch(&cpu_watch);
   4.162 -
   4.163 -	if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
   4.164 -		for_each_cpu(i)
   4.165 -			vcpu_hotplug(i);
   4.166 -		printk(KERN_INFO "Brought up %ld CPUs\n",
   4.167 -		       (long)num_online_cpus());
   4.168 -	}
   4.169 -
   4.170 -	return NOTIFY_DONE;
   4.171 -}
   4.172 -
   4.173 -static int __init setup_vcpu_hotplug_event(void)
   4.174 -{
   4.175 -	static struct notifier_block hotplug_cpu = {
   4.176 -		.notifier_call = smpboot_cpu_notify };
   4.177 -	static struct notifier_block xsn_cpu = {
   4.178 -		.notifier_call = setup_cpu_watcher };
   4.179 -
   4.180 -	register_cpu_notifier(&hotplug_cpu);
   4.181 -	register_xenstore_notifier(&xsn_cpu);
   4.182 -
   4.183 -	return 0;
   4.184 -}
   4.185 -
   4.186 -arch_initcall(setup_vcpu_hotplug_event);
   4.187 -
   4.188 -int smp_suspend(void)
   4.189 -{
   4.190 -	int i, err;
   4.191 -
   4.192 -	lock_cpu_hotplug();
   4.193 -
   4.194 -	/*
   4.195 -	 * Take all other CPUs offline. We hold the hotplug mutex to
   4.196 -	 * avoid other processes bringing up CPUs under our feet.
   4.197 -	 */
   4.198 -	while (num_online_cpus() > 1) {
   4.199 -		unlock_cpu_hotplug();
   4.200 -		for_each_online_cpu(i) {
   4.201 -			if (i == 0)
   4.202 -				continue;
   4.203 -			err = cpu_down(i);
   4.204 -			if (err) {
   4.205 -				printk(KERN_CRIT "Failed to take all CPUs "
   4.206 -				       "down: %d.\n", err);
   4.207 -				for_each_cpu(i)
   4.208 -					vcpu_hotplug(i);
   4.209 -				return err;
   4.210 -			}
   4.211 -		}
   4.212 -		lock_cpu_hotplug();
   4.213 -	}
   4.214 -
   4.215 -	return 0;
   4.216 -}
   4.217 -
   4.218 -void smp_resume(void)
   4.219 -{
   4.220 -	int i;
   4.221 -
   4.222 -	for_each_cpu(i)
   4.223 -		vcpu_prepare(i);
   4.224 -
   4.225 -	unlock_cpu_hotplug();
   4.226 -
   4.227 -	for_each_cpu(i)
   4.228 -		vcpu_hotplug(i);
   4.229 -}
   4.230 -
   4.231  static void
   4.232  remove_siblinginfo(int cpu)
   4.233  {
   4.234 @@ -536,20 +384,6 @@ void __cpu_die(unsigned int cpu)
   4.235  
   4.236  #else /* !CONFIG_HOTPLUG_CPU */
   4.237  
   4.238 -int smp_suspend(void)
   4.239 -{
   4.240 -	if (num_online_cpus() > 1) {
   4.241 -		printk(KERN_WARNING "Can't suspend SMP guests "
   4.242 -		       "without CONFIG_HOTPLUG_CPU\n");
   4.243 -		return -EOPNOTSUPP;
   4.244 -	}
   4.245 -	return 0;
   4.246 -}
   4.247 -
   4.248 -void smp_resume(void)
   4.249 -{
   4.250 -}
   4.251 -
   4.252  int __cpu_disable(void)
   4.253  {
   4.254  	return -ENOSYS;
   4.255 @@ -566,17 +400,9 @@ int __devinit __cpu_up(unsigned int cpu)
   4.256  {
   4.257  	int rc;
   4.258  
   4.259 -	if (local_cpu_hotplug_request()) {
   4.260 -		cpu_set(cpu, local_allowed_cpumask);
   4.261 -		if (!cpu_isset(cpu, xenbus_allowed_cpumask)) {
   4.262 -			printk("%s: attempt to bring up CPU %u disallowed by "
   4.263 -			       "remote admin.\n", __FUNCTION__, cpu);
   4.264 -			return -EBUSY;
   4.265 -		}
   4.266 -	} else if (!cpu_isset(cpu, local_allowed_cpumask) ||
   4.267 -		   !cpu_isset(cpu, xenbus_allowed_cpumask)) {
   4.268 -		return -EBUSY;
   4.269 -	}
   4.270 +	rc = cpu_up_is_allowed(cpu);
   4.271 +	if (rc)
   4.272 +		return rc;
   4.273  
   4.274  #ifdef CONFIG_SMP_ALTERNATIVES
   4.275  	if (num_online_cpus() == 1)
   4.276 @@ -591,8 +417,7 @@ int __devinit __cpu_up(unsigned int cpu)
   4.277  	cpu_set(cpu, cpu_online_map);
   4.278  
   4.279  	rc = HYPERVISOR_vcpu_op(VCPUOP_up, cpu, NULL);
   4.280 -	if (rc != 0)
   4.281 -		BUG();
   4.282 +	BUG_ON(rc);
   4.283  
   4.284  	return 0;
   4.285  }
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/linux-2.6-xen-sparse/include/xen/cpu_hotplug.h	Tue May 23 12:05:08 2006 +0100
     5.3 @@ -0,0 +1,42 @@
     5.4 +#ifndef __XEN_CPU_HOTPLUG_H__
     5.5 +#define __XEN_CPU_HOTPLUG_H__
     5.6 +
     5.7 +#include <linux/config.h>
     5.8 +#include <linux/kernel.h>
     5.9 +#include <linux/cpumask.h>
    5.10 +
    5.11 +#if defined(CONFIG_HOTPLUG_CPU)
    5.12 +
    5.13 +#if defined(CONFIG_X86)
    5.14 +void cpu_initialize_context(unsigned int cpu);
    5.15 +#else
    5.16 +#define cpu_initialize_context(cpu)	((void)0)
    5.17 +#endif
    5.18 +
    5.19 +int cpu_up_is_allowed(unsigned int cpu);
    5.20 +void init_xenbus_allowed_cpumask(void);
    5.21 +int smp_suspend(void);
    5.22 +void smp_resume(void);
    5.23 +
    5.24 +#else /* !defined(CONFIG_HOTPLUG_CPU) */
    5.25 +
    5.26 +#define cpu_up_is_allowed(cpu)		(1)
    5.27 +#define init_xenbus_allowed_cpumask()	((void)0)
    5.28 +
    5.29 +static inline int smp_suspend(void)
    5.30 +{
    5.31 +	if (num_online_cpus() > 1) {
    5.32 +		printk(KERN_WARNING "Can't suspend SMP guests "
    5.33 +		       "without CONFIG_HOTPLUG_CPU\n");
    5.34 +		return -EOPNOTSUPP;
    5.35 +	}
    5.36 +	return 0;
    5.37 +}
    5.38 +
    5.39 +static inline void smp_resume(void)
    5.40 +{
    5.41 +}
    5.42 +
    5.43 +#endif /* !defined(CONFIG_HOTPLUG_CPU) */
    5.44 +
    5.45 +#endif /* __XEN_CPU_HOTPLUG_H__ */