From: Fabiano Rosas <farosas@suse.de>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
"Kevin Wolf" <kwolf@redhat.com>,
"Hanna Reitz" <hreitz@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"João Silva" <jsilva@suse.de>, "Lin Ma" <lma@suse.com>,
"Claudio Fontana" <cfontana@suse.de>,
"Dario Faggioli" <dfaggioli@suse.com>,
"Dr. David Alan Gilbert" <dave@treblig.org>
Subject: Re: [RFC PATCH 3/6] Convert query-block/info_block to coroutine
Date: Fri, 26 May 2023 11:05:08 -0300 [thread overview]
Message-ID: <87bki79oiz.fsf@suse.de> (raw)
In-Reply-To: <i2zakx3qtd5kodcay6uablx7pawdkx2sh2pl33ump4ssxwhuiv@z7auumqij7ry>
Eric Blake <eblake@redhat.com> writes:
> On Tue, May 23, 2023 at 06:39:00PM -0300, Fabiano Rosas wrote:
>> From: Lin Ma <lma@suse.com>
>>
>> Sometimes the query-block performs time-consuming I/O(say waiting for
>> the fstat of NFS complete), So let's make this QMP handler runs in a
>> coroutine.
>
> Grammar suggestions:
>
> Sometimes the query-block command performs time-consuming I/O (say
> waiting for the fstat of NFS to complete), so let's make this QMP
> handler run in a coroutine.
>
Thanks!
>>
>> The following patch moves the fstat() into a thread pool.
>>
>> Signed-off-by: Lin Ma <lma@suse.com>
>> Signed-off-by: Fabiano Rosas <farosas@suse.de>
>
>> ---
>> +++ b/qapi/block-core.json
>> @@ -838,7 +838,7 @@
>> # }
>> ##
>> { 'command': 'query-block', 'returns': ['BlockInfo'],
>> - 'allow-preconfig': true }
>> + 'allow-preconfig': true, 'coroutine': true }
>
> Rereading docs/devel/qapi-code-gen.rst:
>
> | Coroutine safety can be hard to prove, similar to thread safety. Common
> | pitfalls are:
> |
> | - The global mutex isn't held across ``qemu_coroutine_yield()``, so
> | operations that used to assume that they execute atomically may have
> | to be more careful to protect against changes in the global state.
> |
> | - Nested event loops (``AIO_WAIT_WHILE()`` etc.) are problematic in
> | coroutine context and can easily lead to deadlocks. They should be
> | replaced by yielding and reentering the coroutine when the condition
> | becomes false.
> |
> | Since the command handler may assume coroutine context, any callers
> | other than the QMP dispatcher must also call it in coroutine context.
> | In particular, HMP commands calling such a QMP command handler must be
> | marked ``.coroutine = true`` in hmp-commands.hx.
>
> I agree that you also need to change the HMP handler, but the commit
> message didn't mention that other than in the subject line. The
Ok, I'll update the message for v2.
> commit message could also do a better job at explaining how you have
> audited that merely adding the coroutine marker is safe (ie. that all
> of the calls made by query_block are already coroutine safe). While
> the intent behind this patch is on the right track, I'm not sure if I
> have enough information to say whether it is safe, or if there are
> other lurking problems we will need to fix first.
Fair point, I've been trusting the tests too much. A closer code audit
is necessary indeed.
next prev parent reply other threads:[~2023-05-26 14:05 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-23 21:38 [RFC PATCH 0/6] block: Make raw_co_get_allocated_file_size asynchronous Fabiano Rosas
2023-05-23 21:38 ` [RFC PATCH 1/6] block: Remove bdrv_query_block_node_info Fabiano Rosas
2023-05-24 8:31 ` Claudio Fontana
2023-05-23 21:38 ` [RFC PATCH 2/6] block: Mark bdrv_co_get_allocated_file_size() as mixed Fabiano Rosas
2023-05-25 14:17 ` Eric Blake
2023-05-26 9:12 ` Kevin Wolf
2023-05-23 21:39 ` [RFC PATCH 3/6] Convert query-block/info_block to coroutine Fabiano Rosas
2023-05-24 8:48 ` Claudio Fontana
2023-05-25 14:26 ` Eric Blake
2023-05-26 14:05 ` Fabiano Rosas [this message]
2023-05-23 21:39 ` [RFC PATCH 4/6] " Fabiano Rosas
2023-05-24 4:23 ` Lin Ma
2023-05-24 12:30 ` Fabiano Rosas
2023-05-24 8:49 ` Claudio Fontana
2023-05-24 9:24 ` Lin Ma
2023-05-24 15:57 ` Claudio Fontana
2023-05-23 21:39 ` [RFC PATCH 5/6] block: Allow bdrv_get_allocated_file_size to run in bdrv context Fabiano Rosas
2023-05-26 9:28 ` Kevin Wolf
2023-05-29 17:47 ` Fabiano Rosas
2023-05-23 21:39 ` [RFC PATCH 6/6] block: Add a thread-pool version of fstat Fabiano Rosas
2023-05-24 15:56 ` Claudio Fontana
2023-05-25 15:45 ` Eric Blake
2023-05-26 14:20 ` Fabiano Rosas
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=87bki79oiz.fsf@suse.de \
--to=farosas@suse.de \
--cc=armbru@redhat.com \
--cc=cfontana@suse.de \
--cc=dave@treblig.org \
--cc=dfaggioli@suse.com \
--cc=eblake@redhat.com \
--cc=hreitz@redhat.com \
--cc=jsilva@suse.de \
--cc=kwolf@redhat.com \
--cc=lma@suse.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.