qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org, Fam Zheng <fam@euphon.net>,
	Paolo Bonzini <pbonzini@redhat.com>,
	qemu-block@nongnu.org
Subject: Re: [PATCH 0/2] aio-posix: do not nest poll handlers
Date: Wed, 17 May 2023 18:07:40 +0200	[thread overview]
Message-ID: <ZGT7zNqA085Ym5Fp@redhat.com> (raw)
In-Reply-To: <20230502184134.534703-1-stefanha@redhat.com>

Am 02.05.2023 um 20:41 hat Stefan Hajnoczi geschrieben:
> The following stack exhaustion was reported in
> https://bugzilla.redhat.com/show_bug.cgi?id=2186181:
> 
>   ...
>   #51 0x000055884fca7451 aio_poll (qemu-kvm + 0x9d6451)
>   #52 0x000055884fab9cbd bdrv_poll_co (qemu-kvm + 0x7e8cbd)
>   #53 0x000055884fab654b blk_io_plug (qemu-kvm + 0x7e554b)
>   #54 0x000055884f927fef virtio_blk_handle_vq (qemu-kvm + 0x656fef)
>   #55 0x000055884f96d384 virtio_queue_host_notifier_aio_poll_ready (qemu-kvm + 0x69c384)
>   #56 0x000055884fca671b aio_dispatch_handler (qemu-kvm + 0x9d571b)
>   #57 0x000055884fca7451 aio_poll (qemu-kvm + 0x9d6451)
>   #58 0x000055884fab9cbd bdrv_poll_co (qemu-kvm + 0x7e8cbd)
>   #59 0x000055884fab654b blk_io_plug (qemu-kvm + 0x7e554b)
>   #60 0x000055884f927fef virtio_blk_handle_vq (qemu-kvm + 0x656fef)
>   #61 0x000055884f96d384 virtio_queue_host_notifier_aio_poll_ready (qemu-kvm + 0x69c384)
>   #62 0x000055884fca671b aio_dispatch_handler (qemu-kvm + 0x9d571b)
>   #63 0x000055884fca7451 aio_poll (qemu-kvm + 0x9d6451)
>   ...
> 
> This happens because some block layer APIs in QEMU 8.0 run in coroutines in
> order to take the graph rdlock. Existing virtqueue handler functions weren't
> written with this in mind.
> 
> A simplified example of the problem is:
> 
>   void my_fd_handler(void *opaque)
>   {
>       do_something();
>       event_notifier_test_and_clear(opaque);
>       do_something_else();
>   }
> 
> When do_something() calls aio_poll(), my_fd_handler() will be entered again
> immediately because the fd is still readable and stack exhaustion will occur.
> 
> When do_something_else() calls aio_poll(), there is no stack exhaustion since
> the event notifier has been cleared and the fd is not readable.
> 
> The actual bug is more involved. The handler in question is a poll handler, not
> an fd handler, but the principle is the same.
> 
> I haven't been able to reproduce the bug, but I have included a test case that
> demonstrates the problem.

Thanks, applied to the block branch.

Kevin



      parent reply	other threads:[~2023-05-17 16:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-02 18:41 [PATCH 0/2] aio-posix: do not nest poll handlers Stefan Hajnoczi
2023-05-02 18:41 ` [PATCH 1/2] " Stefan Hajnoczi
2023-05-02 18:41 ` [PATCH 2/2] tested: add test for nested aio_poll() in " Stefan Hajnoczi
2023-05-17 16:07 ` Kevin Wolf [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=ZGT7zNqA085Ym5Fp@redhat.com \
    --to=kwolf@redhat.com \
    --cc=fam@euphon.net \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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).