]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
xen: yield to IPI target if necessary
authorJeremy Fitzhardinge <jeremy@xensource.com>
Tue, 16 Oct 2007 18:51:30 +0000 (11:51 -0700)
committerJeremy Fitzhardinge <jeremy@goop.org>
Tue, 16 Oct 2007 18:51:30 +0000 (11:51 -0700)
When sending a call-function IPI to a vcpu, yield if the vcpu isn't
running.

Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
arch/x86/xen/smp.c
arch/x86/xen/time.c
arch/x86/xen/xen-ops.h

index 557b8e24706a94e3511b9a802f333dbb5a2f573f..865953e6f341ef7da3699106684f5803553209cf 100644 (file)
@@ -360,7 +360,8 @@ int xen_smp_call_function_mask(cpumask_t mask, void (*func)(void *),
                               void *info, int wait)
 {
        struct call_data_struct data;
-       int cpus;
+       int cpus, cpu;
+       bool yield;
 
        /* Holding any lock stops cpus from going down. */
        spin_lock(&call_lock);
@@ -389,9 +390,14 @@ int xen_smp_call_function_mask(cpumask_t mask, void (*func)(void *),
        /* Send a message to other CPUs and wait for them to respond */
        xen_send_IPI_mask(mask, XEN_CALL_FUNCTION_VECTOR);
 
-       /* Make sure other vcpus get a chance to run.
-          XXX too severe?  Maybe we should check the other CPU's states? */
-       HYPERVISOR_sched_op(SCHEDOP_yield, 0);
+       /* Make sure other vcpus get a chance to run if they need to. */
+       yield = false;
+       for_each_cpu_mask(cpu, mask)
+               if (xen_vcpu_stolen(cpu))
+                       yield = true;
+
+       if (yield)
+               HYPERVISOR_sched_op(SCHEDOP_yield, 0);
 
        /* Wait for response */
        while (atomic_read(&data.started) != cpus ||
index dfd6db69ead5072dd5a7430ad4750285d44d7031..d083ff5ef088eba01ddebb86cabccf4fa9a4202b 100644 (file)
@@ -105,6 +105,12 @@ static void get_runstate_snapshot(struct vcpu_runstate_info *res)
        } while (get64(&state->state_entry_time) != state_time);
 }
 
+/* return true when a vcpu could run but has no real cpu to run on */
+bool xen_vcpu_stolen(int vcpu)
+{
+       return per_cpu(runstate, vcpu).state == RUNSTATE_runnable;
+}
+
 static void setup_runstate_info(int cpu)
 {
        struct vcpu_register_runstate_memory_area area;
index b5697bae52d0bbc15ad15eb384230c9b4502438c..3847eed0bb0914b11cafe1bb655599f0b76a4416 100644 (file)
@@ -27,6 +27,8 @@ unsigned long xen_get_wallclock(void);
 int xen_set_wallclock(unsigned long time);
 unsigned long long xen_sched_clock(void);
 
+bool xen_vcpu_stolen(int vcpu);
+
 void xen_mark_init_mm_pinned(void);
 
 void __init xen_fill_possible_map(void);