Skip to content

Commit

Permalink
cpus: remove tcg_halt_cond and tcg_cpu_thread globals
Browse files Browse the repository at this point in the history
This hides the tcg_halt_cond and tcg_cpu_thread global variables
inside qemu_tcg_init_vcpu.  Multi-threaded TCG will need one
QemuCond and one QemuThread per virtual cpu, so it's preferrable
to use cpu->halt_cond and cpu->thread.

Signed-off-by: KONRAD Frederic <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
konrad-fred authored and bonzini committed Sep 9, 2015
1 parent 376692b commit d5f8d61
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions cpus.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,6 @@ static unsigned iothread_requesting_mutex;

static QemuThread io_thread;

static QemuThread *tcg_cpu_thread;
static QemuCond *tcg_halt_cond;

/* cpu creation */
static QemuCond qemu_cpu_cond;
/* system init */
Expand Down Expand Up @@ -907,15 +904,13 @@ static void qemu_wait_io_event_common(CPUState *cpu)
cpu->thread_kicked = false;
}

static void qemu_tcg_wait_io_event(void)
static void qemu_tcg_wait_io_event(CPUState *cpu)
{
CPUState *cpu;

while (all_cpu_threads_idle()) {
/* Start accounting real time to the virtual clock if the CPUs
are idle. */
qemu_clock_warp(QEMU_CLOCK_VIRTUAL);
qemu_cond_wait(tcg_halt_cond, &qemu_global_mutex);
qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex);
}

while (iothread_requesting_mutex) {
Expand Down Expand Up @@ -1040,7 +1035,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)

/* wait for initial kick-off after machine start */
while (first_cpu->stopped) {
qemu_cond_wait(tcg_halt_cond, &qemu_global_mutex);
qemu_cond_wait(first_cpu->halt_cond, &qemu_global_mutex);

/* process any pending work */
CPU_FOREACH(cpu) {
Expand All @@ -1061,7 +1056,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
}
}
qemu_tcg_wait_io_event();
qemu_tcg_wait_io_event(QTAILQ_FIRST(&cpus));
}

return NULL;
Expand Down Expand Up @@ -1224,6 +1219,8 @@ void resume_all_vcpus(void)
static void qemu_tcg_init_vcpu(CPUState *cpu)
{
char thread_name[VCPU_THREAD_NAME_SIZE];
static QemuCond *tcg_halt_cond;
static QemuThread *tcg_cpu_thread;

tcg_cpu_address_space_init(cpu, cpu->as);

Expand Down

0 comments on commit d5f8d61

Please sign in to comment.