really fix -icount in the iothread case

The correct fix for -icount is to consider the biggest difference
between iothread and non-iothread modes.  In the traditional model,
CPUs run _before_ the iothread calls select (or WaitForMultipleObjects
for Win32).  In the iothread model, CPUs run while the iothread
isn't holding the mutex, i.e. _during_ those same calls.

So, the iothread should always block as long as possible to let
the CPUs run smoothly---the timeout might as well be infinite---and
either the OS or the CPU thread itself will let the iothread know
when something happens.  At this point, the iothread wakes up and
interrupts the CPU.

This is exactly the approach that this patch takes: when cpu_exec_all
returns in -icount mode, and it is because a vm_clock deadline has
been met, it wakes up the iothread to process the timers.  This is
really the "bulk" of fixing icount.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
1 file changed
tree: 206e5221bc65ea69cf03e60f72a006bef55f0cae
  1. audio/
  2. block/
  3. bsd-user/
  4. darwin-user/
  5. default-configs/
  6. docs/
  7. fpu/
  8. fsdev/
  9. gdb-xml/
  10. hw/
  11. libcacard/
  12. linux-user/
  13. net/
  14. pc-bios/
  15. QMP/
  16. roms/
  17. scripts/
  18. slirp/
  19. sysconfigs/
  20. target-alpha/
  21. target-arm/
  22. target-cris/
  23. target-i386/
  24. target-lm32/
  25. target-m68k/
  26. target-microblaze/
  27. target-mips/
  28. target-ppc/
  29. target-s390x/
  30. target-sh4/
  31. target-sparc/
  32. target-unicore32/
  33. tcg/
  34. tests/
  35. ui/
  36. .gitignore
  37. .gitmodules
  38. a.out.h
  39. acl.c
  40. acl.h
  41. aes.c
  42. aes.h
  43. aio.c
  44. alpha-dis.c
  45. alpha.ld
  46. arch_init.c
  47. arch_init.h
  48. arm-dis.c
  49. arm-semi.c
  50. arm.ld
  51. async.c
  52. balloon.c
  53. balloon.h
  54. bitmap.c
  55. bitmap.h
  56. bitops.c
  57. bitops.h
  58. block-migration.c
  59. block-migration.h
  60. block.c
  61. block.h
  62. block_int.h
  63. blockdev.c
  64. blockdev.h
  65. bswap.h
  66. bt-host.c
  67. bt-host.h
  68. bt-vhci.c
  69. buffered_file.c
  70. buffered_file.h
  71. cache-utils.c
  72. cache-utils.h
  73. Changelog
  74. check-qdict.c
  75. check-qfloat.c
  76. check-qint.c
  77. check-qjson.c
  78. check-qlist.c
  79. check-qstring.c
  80. cmd.c
  81. cmd.h
  82. CODING_STYLE
  83. compatfd.c
  84. compatfd.h
  85. config.h
  86. configure
  87. console.c
  88. console.h
  89. COPYING
  90. COPYING.LIB
  91. cpu-all.h
  92. cpu-common.h
  93. cpu-defs.h
  94. cpu-exec.c
  95. cpus.c
  96. cpus.h
  97. cris-dis.c
  98. cursor.c
  99. cursor_hidden.xpm
  100. cursor_left_ptr.xpm
  101. cutils.c
  102. def-helper.h
  103. device_tree.c
  104. device_tree.h
  105. dis-asm.h
  106. disas.c
  107. disas.h
  108. dma-helpers.c
  109. dma.h
  110. dyngen-exec.h
  111. elf.h
  112. envlist.c
  113. envlist.h
  114. exec-all.h
  115. exec.c
  116. gdbstub.c
  117. gdbstub.h
  118. gen-icount.h
  119. HACKING
  120. hmp-commands.hx
  121. host-utils.c
  122. host-utils.h
  123. hpet.h
  124. hppa-dis.c
  125. hppa.ld
  126. i386-dis.c
  127. i386.ld
  128. ia64-dis.c
  129. ia64.ld
  130. input.c
  131. iohandler.c
  132. ioport-user.c
  133. ioport.c
  134. ioport.h
  135. iorange.h
  136. iov.c
  137. iov.h
  138. json-lexer.c
  139. json-lexer.h
  140. json-parser.c
  141. json-parser.h
  142. json-streamer.c
  143. json-streamer.h
  144. kvm-all.c
  145. kvm-stub.c
  146. kvm.h
  147. libfdt_env.h
  148. LICENSE
  149. linux-aio.c
  150. m68k-dis.c
  151. m68k-semi.c
  152. m68k.ld
  153. MAINTAINERS
  154. Makefile
  155. Makefile.dis
  156. Makefile.hw
  157. Makefile.objs
  158. Makefile.target
  159. Makefile.user
  160. microblaze-dis.c
  161. migration-exec.c
  162. migration-fd.c
  163. migration-tcp.c
  164. migration-unix.c
  165. migration.c
  166. migration.h
  167. mips-dis.c
  168. mips.ld
  169. module.c
  170. module.h
  171. monitor.c
  172. monitor.h
  173. nbd.c
  174. nbd.h
  175. net.c
  176. net.h
  177. notify.c
  178. notify.h
  179. os-posix.c
  180. os-win32.c
  181. osdep.c
  182. osdep.h
  183. oslib-posix.c
  184. oslib-win32.c
  185. path.c
  186. pci-ids.txt
  187. pflib.c
  188. pflib.h
  189. poison.h
  190. posix-aio-compat.c
  191. ppc-dis.c
  192. ppc.ld
  193. ppc64.ld
  194. qbool.c
  195. qbool.h
  196. qdict-test-data.txt
  197. qdict.c
  198. qdict.h
  199. qemu-aio.h
  200. qemu-barrier.h
  201. qemu-char.c
  202. qemu-char.h
  203. qemu-common.h
  204. qemu-config.c
  205. qemu-config.h
  206. qemu-doc.texi
  207. qemu-error.c
  208. qemu-error.h
  209. qemu-img-cmds.hx
  210. qemu-img.c
  211. qemu-img.texi
  212. qemu-io.c
  213. qemu-lock.h
  214. qemu-log.h
  215. qemu-malloc.c
  216. qemu-nbd.c
  217. qemu-nbd.texi
  218. qemu-objects.h
  219. qemu-option.c
  220. qemu-option.h
  221. qemu-options.h
  222. qemu-options.hx
  223. qemu-os-posix.h
  224. qemu-os-win32.h
  225. qemu-progress.c
  226. qemu-queue.h
  227. qemu-sockets.c
  228. qemu-tech.texi
  229. qemu-thread-posix.c
  230. qemu-thread-posix.h
  231. qemu-thread-win32.c
  232. qemu-thread-win32.h
  233. qemu-thread.h
  234. qemu-timer-common.c
  235. qemu-timer.c
  236. qemu-timer.h
  237. qemu-tool.c
  238. qemu-x509.h
  239. qemu.sasl
  240. qemu_socket.h
  241. qerror.c
  242. qerror.h
  243. qfloat.c
  244. qfloat.h
  245. qint.c
  246. qint.h
  247. qjson.c
  248. qjson.h
  249. qlist.c
  250. qlist.h
  251. qmp-commands.hx
  252. qobject.h
  253. qstring.c
  254. qstring.h
  255. range.h
  256. readline.c
  257. readline.h
  258. README
  259. rules.mak
  260. rwhandler.c
  261. rwhandler.h
  262. s390-dis.c
  263. s390.ld
  264. savevm.c
  265. sh4-dis.c
  266. simpletrace.c
  267. simpletrace.h
  268. softmmu-semi.h
  269. softmmu_defs.h
  270. softmmu_exec.h
  271. softmmu_header.h
  272. softmmu_template.h
  273. sparc-dis.c
  274. sparc.ld
  275. sparc64.ld
  276. spice-qemu-char.c
  277. sysemu.h
  278. targphys.h
  279. tcg-runtime.c
  280. thunk.c
  281. thunk.h
  282. TODO
  283. trace-events
  284. translate-all.c
  285. uboot_image.h
  286. usb-bsd.c
  287. usb-linux.c
  288. usb-stub.c
  289. VERSION
  290. version.rc
  291. vgafont.h
  292. vl.c
  293. x86_64.ld