Commit f0d73394 authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge Committed by Jeremy Fitzhardinge

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: default avatarJeremy Fitzhardinge <jeremy@xensource.com>
parent d626a1f1
...@@ -360,7 +360,8 @@ int xen_smp_call_function_mask(cpumask_t mask, void (*func)(void *), ...@@ -360,7 +360,8 @@ int xen_smp_call_function_mask(cpumask_t mask, void (*func)(void *),
void *info, int wait) void *info, int wait)
{ {
struct call_data_struct data; struct call_data_struct data;
int cpus; int cpus, cpu;
bool yield;
/* Holding any lock stops cpus from going down. */ /* Holding any lock stops cpus from going down. */
spin_lock(&call_lock); spin_lock(&call_lock);
...@@ -389,8 +390,13 @@ int xen_smp_call_function_mask(cpumask_t mask, void (*func)(void *), ...@@ -389,8 +390,13 @@ int xen_smp_call_function_mask(cpumask_t mask, void (*func)(void *),
/* Send a message to other CPUs and wait for them to respond */ /* Send a message to other CPUs and wait for them to respond */
xen_send_IPI_mask(mask, XEN_CALL_FUNCTION_VECTOR); xen_send_IPI_mask(mask, XEN_CALL_FUNCTION_VECTOR);
/* Make sure other vcpus get a chance to run. /* Make sure other vcpus get a chance to run if they need to. */
XXX too severe? Maybe we should check the other CPU's states? */ yield = false;
for_each_cpu_mask(cpu, mask)
if (xen_vcpu_stolen(cpu))
yield = true;
if (yield)
HYPERVISOR_sched_op(SCHEDOP_yield, 0); HYPERVISOR_sched_op(SCHEDOP_yield, 0);
/* Wait for response */ /* Wait for response */
......
...@@ -105,6 +105,12 @@ static void get_runstate_snapshot(struct vcpu_runstate_info *res) ...@@ -105,6 +105,12 @@ static void get_runstate_snapshot(struct vcpu_runstate_info *res)
} while (get64(&state->state_entry_time) != state_time); } 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) static void setup_runstate_info(int cpu)
{ {
struct vcpu_register_runstate_memory_area area; struct vcpu_register_runstate_memory_area area;
......
...@@ -27,6 +27,8 @@ unsigned long xen_get_wallclock(void); ...@@ -27,6 +27,8 @@ unsigned long xen_get_wallclock(void);
int xen_set_wallclock(unsigned long time); int xen_set_wallclock(unsigned long time);
unsigned long long xen_sched_clock(void); unsigned long long xen_sched_clock(void);
bool xen_vcpu_stolen(int vcpu);
void xen_mark_init_mm_pinned(void); void xen_mark_init_mm_pinned(void);
void __init xen_fill_possible_map(void); void __init xen_fill_possible_map(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment