mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00
cpus: kick all vCPUs when running thread=single
qemu_cpu_kick is used for a number of reasons including to indicate there is work to be done. However when thread=single the old qemu_cpu_kick_rr_cpu only advanced the vCPU to the next executing one which can lead to a hang in the case that: a) the kick is from outside the vCPUs (e.g. iothread) b) the timers are paused (i.e. iothread calling run_on_cpu) To avoid this lets split qemu_cpu_kick_rr into two functions. One for the timer which continues to advance to the next timeslice and another for all other kicks. Message-Id: <20191001160426.26644-1-alex.bennee@linaro.org> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
b7ce3cff21
commit
e8f22f7684
1 changed files with 18 additions and 6 deletions
24
cpus.c
24
cpus.c
|
@ -949,8 +949,8 @@ static inline int64_t qemu_tcg_next_kick(void)
|
||||||
return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + TCG_KICK_PERIOD;
|
return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + TCG_KICK_PERIOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Kick the currently round-robin scheduled vCPU */
|
/* Kick the currently round-robin scheduled vCPU to next */
|
||||||
static void qemu_cpu_kick_rr_cpu(void)
|
static void qemu_cpu_kick_rr_next_cpu(void)
|
||||||
{
|
{
|
||||||
CPUState *cpu;
|
CPUState *cpu;
|
||||||
do {
|
do {
|
||||||
|
@ -961,6 +961,16 @@ static void qemu_cpu_kick_rr_cpu(void)
|
||||||
} while (cpu != atomic_mb_read(&tcg_current_rr_cpu));
|
} while (cpu != atomic_mb_read(&tcg_current_rr_cpu));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Kick all RR vCPUs */
|
||||||
|
static void qemu_cpu_kick_rr_cpus(void)
|
||||||
|
{
|
||||||
|
CPUState *cpu;
|
||||||
|
|
||||||
|
CPU_FOREACH(cpu) {
|
||||||
|
cpu_exit(cpu);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static void do_nothing(CPUState *cpu, run_on_cpu_data unused)
|
static void do_nothing(CPUState *cpu, run_on_cpu_data unused)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -993,7 +1003,7 @@ void qemu_timer_notify_cb(void *opaque, QEMUClockType type)
|
||||||
static void kick_tcg_thread(void *opaque)
|
static void kick_tcg_thread(void *opaque)
|
||||||
{
|
{
|
||||||
timer_mod(tcg_kick_vcpu_timer, qemu_tcg_next_kick());
|
timer_mod(tcg_kick_vcpu_timer, qemu_tcg_next_kick());
|
||||||
qemu_cpu_kick_rr_cpu();
|
qemu_cpu_kick_rr_next_cpu();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void start_tcg_kick_timer(void)
|
static void start_tcg_kick_timer(void)
|
||||||
|
@ -1828,9 +1838,11 @@ void qemu_cpu_kick(CPUState *cpu)
|
||||||
{
|
{
|
||||||
qemu_cond_broadcast(cpu->halt_cond);
|
qemu_cond_broadcast(cpu->halt_cond);
|
||||||
if (tcg_enabled()) {
|
if (tcg_enabled()) {
|
||||||
cpu_exit(cpu);
|
if (qemu_tcg_mttcg_enabled()) {
|
||||||
/* NOP unless doing single-thread RR */
|
cpu_exit(cpu);
|
||||||
qemu_cpu_kick_rr_cpu();
|
} else {
|
||||||
|
qemu_cpu_kick_rr_cpus();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (hax_enabled()) {
|
if (hax_enabled()) {
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue