tcg: rename tcg_current_cpu to tcg_current_rr_cpu

..and make the definition local to cpus. In preparation for MTTCG the
concept of a global tcg_current_cpu will no longer make sense. However
we still need to keep track of it in the single-threaded case to be able
to exit quickly when required.

qemu_cpu_kick_no_halt() moves and becomes qemu_cpu_kick_rr_cpu() to
emphasise its use-case. qemu_cpu_kick now kicks the relevant cpu as
well as qemu_kick_rr_cpu() which will become a no-op in MTTCG.

For the time being the setting of the global exit_request remains.

Backports commit 791158d93b27f22a17c2ada06621831d54f09a2c from qemu

Also atomically sets the unicorn equivalents
This commit is contained in:
Alex Bennée 2018-03-02 09:26:31 -05:00 committed by Lioncash
parent 18a229a69f
commit 4d90497d14
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
2 changed files with 5 additions and 5 deletions

View file

@ -194,7 +194,7 @@ struct uc_struct {
// qemu/cpu-exec.c
BounceBuffer bounce;
volatile sig_atomic_t exit_request;
CPUState *tcg_current_cpu;
CPUState *tcg_current_rr_cpu;
// qemu/memory.c
bool global_dirty_log;

View file

@ -491,8 +491,8 @@ int cpu_exec(struct uc_struct *uc, CPUState *cpu)
return EXCP_HALTED;
}
uc->current_cpu = cpu;
atomic_mb_set(&uc->tcg_current_cpu, cpu);
atomic_mb_set(&uc->current_cpu, cpu);
atomic_mb_set(&uc->tcg_current_rr_cpu, cpu);
if (unlikely(atomic_mb_read(&uc->exit_request))) {
cpu->exit_request = 1;
@ -546,8 +546,8 @@ int cpu_exec(struct uc_struct *uc, CPUState *cpu)
tb_flush(cpu);
/* fail safe : never use current_cpu outside cpu_exec() */
uc->current_cpu = NULL;
atomic_set(&uc->current_cpu, NULL);
/* Does not need atomic_mb_set because a spurious wakeup is okay. */
atomic_set(&uc->tcg_current_cpu, NULL);
atomic_set(&uc->tcg_current_rr_cpu, NULL);
return ret;
}