direct-io.hg

changeset 5215:69acd57e1bd8

bitkeeper revision 1.1602 (429c2005b_phBM8VV-zUAH99jBwhMw)

Updated process.c for x86-64.
Signed-off-by: Jun Nakajima <jun.nakajima@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue May 31 08:27:49 2005 +0000 (2005-05-31)
parents ca9531e574f4
children 3f244c5d2fe2 d85350beab5e
files linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/process.c
line diff
     1.1 --- a/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/process.c	Tue May 31 08:22:44 2005 +0000
     1.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/process.c	Tue May 31 08:27:49 2005 +0000
     1.3 @@ -21,6 +21,7 @@
     1.4  
     1.5  #include <stdarg.h>
     1.6  
     1.7 +#include <linux/cpu.h>
     1.8  #include <linux/errno.h>
     1.9  #include <linux/sched.h>
    1.10  #include <linux/kernel.h>
    1.11 @@ -84,28 +85,48 @@ 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 int set_timeout_timer(void);
    1.16 +extern void stop_hz_timer(void);
    1.17 +extern void start_hz_timer(void);
    1.18  void xen_idle(void)
    1.19  {
    1.20 -	int cpu;	
    1.21 -
    1.22  	local_irq_disable();
    1.23  
    1.24 -	cpu = smp_processor_id();
    1.25 -	if (rcu_pending(cpu))
    1.26 -		rcu_check_callbacks(cpu, 0);
    1.27 -
    1.28  	if (need_resched()) {
    1.29  		local_irq_enable();
    1.30 -	} else if (set_timeout_timer() == 0) {
    1.31 -		/* NB. Blocking reenable events in a race-free manner. */
    1.32 -		HYPERVISOR_block();
    1.33  	} else {
    1.34 -		local_irq_enable();
    1.35 -		HYPERVISOR_yield();
    1.36 +		stop_hz_timer();
    1.37 +		HYPERVISOR_block(); /* implicit local_irq_enable() */
    1.38 +		start_hz_timer();
    1.39  	}
    1.40  }
    1.41  
    1.42 +#ifdef CONFIG_HOTPLUG_CPU
    1.43 +#include <asm/nmi.h>
    1.44 +/* We don't actually take CPU down, just spin without interrupts. */
    1.45 +static inline void play_dead(void)
    1.46 +{
    1.47 +	/* Ack it */
    1.48 +	__get_cpu_var(cpu_state) = CPU_DEAD;
    1.49 +
    1.50 +	/* We shouldn't have to disable interrupts while dead, but
    1.51 +	 * some interrupts just don't seem to go away, and this makes
    1.52 +	 * it "work" for testing purposes. */
    1.53 +	/* Death loop */
    1.54 +	while (__get_cpu_var(cpu_state) != CPU_UP_PREPARE)
    1.55 +		HYPERVISOR_yield();
    1.56 +
    1.57 +	local_irq_disable();
    1.58 +	__flush_tlb_all();
    1.59 +	cpu_set(smp_processor_id(), cpu_online_map);
    1.60 +	local_irq_enable();
    1.61 +}
    1.62 +#else
    1.63 +static inline void play_dead(void)
    1.64 +{
    1.65 +	BUG();
    1.66 +}
    1.67 +#endif /* CONFIG_HOTPLUG_CPU */
    1.68 +
    1.69  /*
    1.70   * The idle thread. There's no useful work to be
    1.71   * done, so just try to conserve power and have a
    1.72 @@ -122,6 +143,9 @@ void cpu_idle (void)
    1.73  			if (cpu_isset(cpu, cpu_idle_map))
    1.74  				cpu_clear(cpu, cpu_idle_map);
    1.75  			rmb();
    1.76 +			
    1.77 +			if (cpu_is_offline(cpu))
    1.78 +				play_dead();
    1.79  
    1.80                          __IRQ_STAT(cpu,idle_timestamp) = jiffies;
    1.81  			xen_idle();
    1.82 @@ -130,6 +154,22 @@ void cpu_idle (void)
    1.83  	}
    1.84  }
    1.85  
    1.86 +void cpu_idle_wait(void)
    1.87 +{
    1.88 +	int cpu;
    1.89 +	cpumask_t map;
    1.90 +
    1.91 +	for_each_online_cpu(cpu)
    1.92 +		cpu_set(cpu, cpu_idle_map);
    1.93 +
    1.94 +	wmb();
    1.95 +	do {
    1.96 +		ssleep(1);
    1.97 +		cpus_and(map, cpu_idle_map, cpu_online_map);
    1.98 +	} while (!cpus_empty(map));
    1.99 +}
   1.100 +EXPORT_SYMBOL_GPL(cpu_idle_wait);
   1.101 +
   1.102  /* XXX XEN doesn't use mwait_idle(), select_idle_routine(), idle_setup(). */
   1.103  /* Always use xen_idle() instead. */
   1.104  void __init select_idle_routine(const struct cpuinfo_x86 *c) {}