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.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[AJB: Some fixes, conditionally, commit rewording]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
2 files changed
tree: 9a1e1fd46081dbbc9384155ca72479ee2a4b890b
  1. audio/
  2. backends/
  3. block/
  4. bsd-user/
  5. chardev/
  6. contrib/
  7. crypto/
  8. default-configs/
  9. disas/
  10. docs/
  11. fpu/
  12. fsdev/
  13. gdb-xml/
  14. hw/
  15. include/
  16. io/
  17. libdecnumber/
  18. linux-headers/
  19. linux-user/
  20. migration/
  21. nbd/
  22. net/
  23. pc-bios/
  24. po/
  25. qapi/
  26. qga/
  27. qobject/
  28. qom/
  29. replay/
  30. roms/
  31. scripts/
  32. slirp/
  33. stubs/
  34. target/
  35. tcg/
  36. tests/
  37. trace/
  38. ui/
  39. util/
  40. .dir-locals.el
  41. .exrc
  42. .gitignore
  43. .gitmodules
  44. .mailmap
  45. .travis.yml
  46. accel.c
  47. arch_init.c
  48. atomic_template.h
  49. balloon.c
  50. block.c
  51. blockdev-nbd.c
  52. blockdev.c
  53. blockjob.c
  54. bootdevice.c
  55. bt-host.c
  56. bt-vhci.c
  57. Changelog
  58. CODING_STYLE
  59. configure
  60. COPYING
  61. COPYING.LIB
  62. cpu-exec-common.c
  63. cpu-exec.c
  64. cpus-common.c
  65. cpus.c
  66. cputlb.c
  67. device-hotplug.c
  68. device_tree.c
  69. disas.c
  70. dma-helpers.c
  71. dump.c
  72. exec.c
  73. gdbstub.c
  74. HACKING
  75. hax-stub.c
  76. hmp-commands-info.hx
  77. hmp-commands.hx
  78. hmp.c
  79. hmp.h
  80. ioport.c
  81. iothread.c
  82. kvm-all.c
  83. kvm-stub.c
  84. LICENSE
  85. MAINTAINERS
  86. Makefile
  87. Makefile.objs
  88. Makefile.target
  89. memory.c
  90. memory_ldst.inc.c
  91. memory_mapping.c
  92. module-common.c
  93. monitor.c
  94. numa.c
  95. os-posix.c
  96. os-win32.c
  97. page_cache.c
  98. qapi-schema.json
  99. qdev-monitor.c
  100. qdict-test-data.txt
  101. qemu-bridge-helper.c
  102. qemu-doc.texi
  103. qemu-ga.texi
  104. qemu-img-cmds.hx
  105. qemu-img.c
  106. qemu-img.texi
  107. qemu-io-cmds.c
  108. qemu-io.c
  109. qemu-nbd.c
  110. qemu-nbd.texi
  111. qemu-option-trace.texi
  112. qemu-options-wrapper.h
  113. qemu-options.h
  114. qemu-options.hx
  115. qemu-seccomp.c
  116. qemu-tech.texi
  117. qemu.nsi
  118. qemu.sasl
  119. qmp.c
  120. qtest.c
  121. README
  122. replication.c
  123. replication.h
  124. rules.mak
  125. softmmu_template.h
  126. spice-qemu-char.c
  127. tcg-runtime.c
  128. tci.c
  129. thunk.c
  130. tpm.c
  131. trace-events
  132. translate-all.c
  133. translate-all.h
  134. translate-common.c
  135. user-exec-stub.c
  136. user-exec.c
  137. VERSION
  138. version.rc
  139. vl.c
  140. xen-common-stub.c
  141. xen-common.c
  142. xen-hvm-stub.c
  143. xen-hvm.c
  144. xen-mapcache.c