From: Kevin Wolf <kwolf@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
Fam Zheng <fam@euphon.net>,
qemu-stable@nongnu.org, Qing Wang <qinwang@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH for-8.0 v2] aio-posix: fix race between epoll upgrade and aio_set_fd_handler()
Date: Mon, 27 Mar 2023 15:14:57 +0200 [thread overview]
Message-ID: <ZCGW0TaUKriIVi4V@redhat.com> (raw)
In-Reply-To: <20230323144859.1338495-1-stefanha@redhat.com>
Am 23.03.2023 um 15:48 hat Stefan Hajnoczi geschrieben:
> If another thread calls aio_set_fd_handler() while the IOThread event
> loop is upgrading from ppoll(2) to epoll(7) then we might miss new
> AioHandlers. The epollfd will not monitor the new AioHandler's fd,
> resulting in hangs.
>
> Take the AioHandler list lock while upgrading to epoll. This prevents
> AioHandlers from changing while epoll is being set up. If we cannot lock
> because we're in a nested event loop, then don't upgrade to epoll (it
> will happen next time we're not in a nested call).
>
> The downside to taking the lock is that the aio_set_fd_handler() thread
> has to wait until the epoll upgrade is finished, which involves many
> epoll_ctl(2) system calls. However, this scenario is rare and I couldn't
> think of another solution that is still simple.
>
> Reported-by: Qing Wang <qinwang@redhat.com>
> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2090998
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Fam Zheng <fam@euphon.net>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> v2:
> - Use qemu_lockcnt_inc_and_unlock() instead of qemu_lockcnt_unlock() [Paolo]
Thanks, applied to the block branch.
Kevin
prev parent reply other threads:[~2023-03-27 13:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 14:48 [PATCH for-8.0 v2] aio-posix: fix race between epoll upgrade and aio_set_fd_handler() Stefan Hajnoczi
2023-03-27 13:14 ` 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=ZCGW0TaUKriIVi4V@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=qemu-stable@nongnu.org \
--cc=qinwang@redhat.com \
--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 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.