)]}'
{
  "commit": "ff4873cb8c81db89668d8b56e19e57b852edb5f5",
  "tree": "ce2f98f4e1a78de5de9db60e2d08c2fa5121e9f0",
  "parents": [
    "8589744aaf07b62e7be4233727c45b8866d27d43"
  ],
  "author": {
    "name": "Peter Maydell",
    "email": "peter.maydell@linaro.org",
    "time": "Mon Jun 23 15:55:03 2014 +0100"
  },
  "committer": {
    "name": "Peter Maydell",
    "email": "peter.maydell@linaro.org",
    "time": "Thu Jun 26 14:08:14 2014 +0100"
  },
  "message": "coroutine-win32.c: Add noinline attribute to work around gcc bug\n\nA gcc codegen bug in x86_64-w64-mingw32-gcc (GCC) 4.6.3 means that\nnon-debug builds of QEMU for Windows tend to assert when using\ncoroutines. Work around this by marking qemu_coroutine_switch\nas noinline.\n\nIf we allow gcc to inline qemu_coroutine_switch into\ncoroutine_trampoline, then it hoists the code to get the\naddress of the TLS variable \"current\" out of the while() loop.\nThis is an invalid transformation because the SwitchToFiber()\ncall may be called when running thread A but return in thread B,\nand so we might be in a different thread context each time\nround the loop. This can happen quite often.  Typically.\na coroutine is started when a VCPU thread does bdrv_aio_readv:\n\n     VCPU thread\n\n     main VCPU thread coroutine      I/O coroutine\n        bdrv_aio_readv -----\u003e\n                                     start I/O operation\n                                       thread_pool_submit_co\n                       \u003c------------ yields\n        back to emulation\n\nThen I/O finishes and the thread-pool.c event notifier triggers in\nthe I/O thread.  event_notifier_ready calls thread_pool_co_cb, and\nthe I/O coroutine now restarts *in another thread*:\n\n     iothread\n\n     main iothread coroutine         I/O coroutine (formerly in VCPU thread)\n        event_notifier_ready\n          thread_pool_co_cb -----\u003e   current \u003d I/O coroutine;\n                                     call AIO callback\n\nBut on Win32, because of the bug, the \"current\" being set here the\ncurrent coroutine of the VCPU thread, not the iothread.\n\nnoinline is a good-enough workaround, and quite unlikely to break in\nthe future.\n\n(Thanks to Paolo Bonzini for assistance in diagnosing the problem\nand providing the detailed example/ascii art quoted above.)\n\nSigned-off-by: Peter Maydell \u003cpeter.maydell@linaro.org\u003e\nMessage-id: 1403535303-14939-1-git-send-email-peter.maydell@linaro.org\nReviewed-by: Paolo Bonzini \u003cpbonzini@redhat.com\u003e\nReviewed-by: Richard Henderson \u003crth@twiddle.net\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "edc1f72c1823416a05e48d5ee1c5361285214bf0",
      "old_mode": 33188,
      "old_path": "coroutine-win32.c",
      "new_id": "17ace37deeb33a19d100f64e86c9ac780e4cd8bc",
      "new_mode": 33188,
      "new_path": "coroutine-win32.c"
    }
  ]
}
