Stefan Hajnoczi c40a254570 coroutine: avoid co_queue_wakeup recursion
qemu_aio_coroutine_enter() is (indirectly) called recursively when
processing co_queue_wakeup.  This can lead to stack exhaustion.

This patch rewrites co_queue_wakeup in an iterative fashion (instead of
recursive) with bounded memory usage to prevent stack exhaustion.

qemu_co_queue_run_restart() is inlined into qemu_aio_coroutine_enter()
and the qemu_coroutine_enter() call is turned into a loop to avoid
recursion.

There is one change that is worth mentioning:  Previously, when
coroutine A queued coroutine B, qemu_co_queue_run_restart() entered
coroutine B from coroutine A.  If A was terminating then it would still
stay alive until B yielded.  After this patch B is entered by A's parent
so that a A can be deleted immediately if it is terminating.

It is safe to make this change since B could never interact with A if it
was terminating anyway.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 20180322152834.12656-3-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2018-03-27 13:05:28 +01:00
..
2018-02-10 10:43:18 +03:00
2018-03-26 14:37:15 +02:00
2017-09-22 14:11:25 +02:00
2017-09-22 14:11:23 +02:00
2017-09-07 19:02:30 +01:00
2016-02-04 17:01:04 +00:00
2016-02-04 17:01:04 +00:00
2018-02-07 14:09:25 +01:00
2016-02-04 17:01:04 +00:00
2018-01-23 12:33:07 +01:00
2016-02-04 17:01:04 +00:00
2016-02-04 17:01:04 +00:00
2018-02-08 09:22:03 +08:00
2017-12-20 22:01:24 +08:00