From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: famz@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 4/5] coroutine-lock: make qemu_co_enter_next thread-safe
Date: Thu, 1 Feb 2018 10:28:29 -0500 [thread overview]
Message-ID: <0ffe6237-61c4-a69a-c9b7-7cb6774410aa@redhat.com> (raw)
In-Reply-To: <20180129132621.GD20446@stefanha-x1.localdomain>
On 29/01/2018 08:26, Stefan Hajnoczi wrote:
>> /**
>> - * Enter the next coroutine in the queue
>> + * Immediately enter the next coroutine in the queue. Release the mutex
>> + * while it runs.
>
> s/mutex/lock/
>
> Is this doc comment correct? I see multiple cases due to aio_co_wake():
>
> 1. Called from coroutine context with current AioContext matching next
> coroutine's AioContext: arrange for next coroutine to be entered
> *after* we yield (not "immediately").
>
> 2. Called from non-coroutine context with current AioContext matching
> next coroutine's AioContext: immediately enter next coroutine.
>
> 3. Called from different AioContext than next coroutine: arrange for
> next coroutine to be entered at some point.
Good point, it needs to be more specific. Here is the best I could come up
with:
+ * Removes the next coroutine from the CoQueue, and wake it up.
* Returns true if a coroutine was removed, false if the queue is empty.
*/
bool coroutine_fn qemu_co_queue_next(CoQueue *queue);
...
+ * Empties the CoQueue; all coroutines are woken up.
*/
void coroutine_fn qemu_co_queue_restart_all(CoQueue *queue);
...
+ * Removes the next coroutine from the CoQueue, and wake it up. Unlike
+ * qemu_co_queue_next, this function releases the lock during aio_co_wake
+ * because it is meant to be used outside coroutine context; in that case, the
+ * coroutine is entered immediately, before qemu_co_enter_next returns.
+ *
+ * If used in coroutine context, qemu_co_enter_next is equivalent to
+ * qemu_co_queue_next.
*/
#define qemu_co_enter_next(queue, lock) \
qemu_co_enter_next_impl(queue, QEMU_MAKE_LOCKABLE(lock))
next prev parent reply other threads:[~2018-02-01 15:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-25 17:59 [Qemu-devel] [PATCH v3 0/5] coroutine-lock: polymorphic CoQueue Paolo Bonzini
2018-01-25 17:59 ` [Qemu-devel] [PATCH 1/5] test-coroutine: add simple CoMutex test Paolo Bonzini
2018-01-29 13:26 ` Stefan Hajnoczi
2018-01-25 17:59 ` [Qemu-devel] [PATCH 2/5] lockable: add QemuLockable Paolo Bonzini
2018-01-25 20:13 ` Eric Blake
2018-01-26 3:11 ` Fam Zheng
2018-01-26 5:24 ` Fam Zheng
2018-01-29 11:42 ` Stefan Hajnoczi
2018-01-29 14:30 ` Paolo Bonzini
2018-01-25 17:59 ` [Qemu-devel] [PATCH 3/5] coroutine-lock: convert CoQueue to use QemuLockable Paolo Bonzini
2018-01-29 13:26 ` Stefan Hajnoczi
2018-01-25 17:59 ` [Qemu-devel] [PATCH 4/5] coroutine-lock: make qemu_co_enter_next thread-safe Paolo Bonzini
2018-01-25 20:15 ` Eric Blake
2018-01-29 13:26 ` Stefan Hajnoczi
2018-02-01 15:28 ` Paolo Bonzini [this message]
2018-01-25 17:59 ` [Qemu-devel] [PATCH 5/5] curl: convert to CoQueue Paolo Bonzini
2018-01-29 13:27 ` Stefan Hajnoczi
2018-01-25 18:08 ` [Qemu-devel] [PATCH v3 0/5] coroutine-lock: polymorphic CoQueue no-reply
2018-01-25 20:31 ` Eric Blake
-- strict thread matches above, loose matches on Subject: below --
2018-02-01 21:29 [Qemu-devel] [PATCH v4 " Paolo Bonzini
2018-02-01 21:29 ` [Qemu-devel] [PATCH 4/5] coroutine-lock: make qemu_co_enter_next thread-safe Paolo Bonzini
2018-02-03 15:39 [Qemu-devel] [PATCH v5 0/5] coroutine-lock: polymorphic CoQueue Paolo Bonzini
2018-02-03 15:39 ` [Qemu-devel] [PATCH 4/5] coroutine-lock: make qemu_co_enter_next thread-safe Paolo Bonzini
2018-02-03 20:57 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0ffe6237-61c4-a69a-c9b7-7cb6774410aa@redhat.com \
--to=pbonzini@redhat.com \
--cc=famz@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).