qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org, armbru@redhat.com, eesposit@redhat.com,
	vsementsov@yandex-team.ru
Subject: Re: Question about QMP and BQL
Date: Tue, 16 May 2023 12:13:33 -0300	[thread overview]
Message-ID: <87r0rg71ia.fsf@suse.de> (raw)
In-Reply-To: <ZGIxOOucbBsS1jwi@redhat.com>

Kevin Wolf <kwolf@redhat.com> writes:

> Am 12.05.2023 um 20:01 hat Fabiano Rosas geschrieben:
>> Is there a way to execute a long-standing QMP command outside of the
>> BQL?
>> 
>> The situation we're seeing is a slow query-block due to a slow system
>> call (fstat over NFS) causing the main thread to spend too long
>> holding the global mutex and locking up the vcpu thread when it goes
>> out of the guest for MMIO.
>> 
>> The call chain for QMP is:
>> 
>> qmp_query_block
>> bdrv_query_info
>> bdrv_block_device_info
>> bdrv_query_image_info
>> bdrv_do_query_node_info
>> bdrv_get_allocated_file_size
>> bdrv_poll_co <- Waiting with qemu_global_mutex locked
>> 
>> [coroutine] bdrv_co_get_allocated_file_size_entry
>> bdrv_co_get_allocated_file_size
>> raw_co_get_allocated_file_size
>> fstat <- SLOW!
>
> The first part of the right solution there should be moving fstat() to a
> worker thread like we do for other requests where we care about not
> blocking. See existing raw_thread_pool_submit() callers for examples.
>
> Note that this isn't the full solution yet. QMP still has to wait for
> bdrv_get_allocated_file_size() to return. bdrv_poll_co() runs a nested
> event loop, but it doesn't unlock the BQL.
>
> So the second part would be converting the block-block QMP handler to
> a coroutine so that it can actually yield to the main loop, which will
> then drop the BQL while waiting. We would have to be careful there to
> make sure that we don't break anything because the sets of things
> allowed inside and outside coroutines are different.
>
> Kevin

Hi Kevin,

Thank you, this is what I was looking for. I was missing the
raw_thread_pool_submit right there under my nose!

I'll put together an RFC so we can discuss the details.


      reply	other threads:[~2023-05-16 15:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-12 18:01 Question about QMP and BQL Fabiano Rosas
2023-05-15 11:08 ` Markus Armbruster
2023-05-15 13:18 ` Kevin Wolf
2023-05-16 15:13   ` Fabiano Rosas [this message]

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=87r0rg71ia.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=armbru@redhat.com \
    --cc=eesposit@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@yandex-team.ru \
    /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).