Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f0d733942750c1ee6358c3a4a1a5d7ba73b7122f
Commit:     f0d733942750c1ee6358c3a4a1a5d7ba73b7122f
Parent:     d626a1f1cbbdfac90c529216e40a4fa2a22ecc3d
Author:     Jeremy Fitzhardinge <[EMAIL PROTECTED]>
AuthorDate: Tue Oct 16 11:51:30 2007 -0700
Committer:  Jeremy Fitzhardinge <[EMAIL PROTECTED]>
CommitDate: Tue Oct 16 11:51:30 2007 -0700

    xen: yield to IPI target if necessary
    
    When sending a call-function IPI to a vcpu, yield if the vcpu isn't
    running.
    
    Signed-off-by: Jeremy Fitzhardinge <[EMAIL PROTECTED]>
---
 arch/x86/xen/smp.c     |   14 ++++++++++----
 arch/x86/xen/time.c    |    6 ++++++
 arch/x86/xen/xen-ops.h |    2 ++
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index 557b8e2..865953e 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -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 ||
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index dfd6db6..d083ff5 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -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;
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index b5697ba..3847eed 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -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);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to