tcg: enable thread-per-vCPU

There are a couple of changes that occur at the same time here:

- introduce a single vCPU qemu_tcg_cpu_thread_fn

One of these is spawned per vCPU with its own Thread and Condition
variables. qemu_tcg_rr_cpu_thread_fn is the new name for the old
single threaded function.

- the TLS current_cpu variable is now live for the lifetime of MTTCG
vCPU threads. This is for future work where async jobs need to know
the vCPU context they are operating in.

The user to switch on multi-thread behaviour and spawn a thread
per-vCPU. For a simple test kvm-unit-test like:

./arm/run ./arm/locking-test.flat -smp 4 -accel tcg,thread=multi

Will now use 4 vCPU threads and have an expected FAIL (instead of the
unexpected PASS) as the default mode of the test has no protection when
incrementing a shared variable.

We enable the parallel_cpus flag to ensure we generate correct barrier
and atomic code if supported by the front and backends. This doesn't
automatically enable MTTCG until default_mttcg_enabled() is updated to
check the configuration is supported.

Backports relevant parts of commit 372579427a5040a26dfee78464b50e2bdf27ef26
This commit is contained in:
Alex Bennée 2018-03-02 09:43:09 -05:00 committed by Lioncash
parent 632b853761
commit 6760605e1c
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
2 changed files with 1 additions and 5 deletions

View file

@ -539,9 +539,5 @@ int cpu_exec(struct uc_struct *uc, CPUState *cpu)
// TODO: optimize this for better performance
tb_flush(cpu);
/* fail safe : never use current_cpu outside cpu_exec() */
atomic_set(&uc->current_cpu, NULL);
/* Does not need atomic_mb_set because a spurious wakeup is okay. */
atomic_set(&uc->tcg_current_rr_cpu, NULL);
return ret;
}

View file

@ -78,7 +78,7 @@
* mmap_lock.
*/
#ifdef CONFIG_SOFTMMU
#define assert_memory_lock() do { /* nothing */ } while (0)
#define assert_memory_lock() tcg_debug_assert(have_tb_lock)
#else
#define assert_memory_lock() tcg_debug_assert(have_mmap_lock())
#endif