[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH 06/10] aio-posix: remove walking_handlers, prote
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-block] [PATCH 06/10] aio-posix: remove walking_handlers, protecting AioHandler list with list_lock |
Date: |
Wed, 30 Nov 2016 13:31:16 +0000 |
User-agent: |
Mutt/1.7.1 (2016-10-04) |
On Tue, Nov 29, 2016 at 12:47:03PM +0100, Paolo Bonzini wrote:
> @@ -272,22 +275,32 @@ bool aio_prepare(AioContext *ctx)
> bool aio_pending(AioContext *ctx)
> {
> AioHandler *node;
> + bool result = false;
>
> - QLIST_FOREACH(node, &ctx->aio_handlers, node) {
> + /*
> + * We have to walk very carefully in case aio_set_fd_handler is
> + * called while we're walking.
> + */
> + qemu_lockcnt_inc(&ctx->list_lock);
> +
> + QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) {
> int revents;
>
> revents = node->pfd.revents & node->pfd.events;
> if (revents & (G_IO_IN | G_IO_HUP | G_IO_ERR) && node->io_read &&
> aio_node_check(ctx, node->is_external)) {
> - return true;
> + result = true;
> + break;
> }
> if (revents & (G_IO_OUT | G_IO_ERR) && node->io_write &&
> aio_node_check(ctx, node->is_external)) {
> - return true;
> + result = true;
> + break;
> }
> }
> + qemu_lockcnt_dec(&ctx->list_lock);
>
> - return false;
> + return result;
> }
>
> bool aio_dispatch(AioContext *ctx)
> @@ -308,13 +321,12 @@ bool aio_dispatch(AioContext *ctx)
> * We have to walk very carefully in case aio_set_fd_handler is
> * called while we're walking.
> */
> - ctx->walking_handlers++;
> + qemu_lockcnt_inc(&ctx->list_lock);
>
> - QLIST_FOREACH_SAFE(node, &ctx->aio_handlers, node, tmp) {
> + QLIST_FOREACH_SAFE_RCU(node, &ctx->aio_handlers, node, tmp) {
> int revents;
>
> - revents = node->pfd.revents & node->pfd.events;
> - node->pfd.revents = 0;
> + revents = atomic_xchg(&node->pfd.revents, 0) & node->pfd.events;
Why is node->pfd.revents accessed with atomic_*() here and in aio_poll()
but not in aio_pending()?
signature.asc
Description: PGP signature
- Re: [Qemu-block] [Qemu-devel] [PATCH 02/10] qemu-thread: introduce QemuLockCnt, (continued)
- [Qemu-block] [PATCH 08/10] aio: document locking, Paolo Bonzini, 2016/11/29
- [Qemu-block] [PATCH 09/10] aio: push aio_context_acquire/release down to dispatching, Paolo Bonzini, 2016/11/29
- [Qemu-block] [PATCH 05/10] aio: tweak walking in dispatch phase, Paolo Bonzini, 2016/11/29
- [Qemu-block] [PATCH 10/10] async: optimize aio_bh_poll, Paolo Bonzini, 2016/11/29
- [Qemu-block] [PATCH 06/10] aio-posix: remove walking_handlers, protecting AioHandler list with list_lock, Paolo Bonzini, 2016/11/29
- Re: [Qemu-block] [PATCH 06/10] aio-posix: remove walking_handlers, protecting AioHandler list with list_lock,
Stefan Hajnoczi <=
- [Qemu-block] [PATCH 04/10] qemu-thread: optimize QemuLockCnt with futexes on Linux, Paolo Bonzini, 2016/11/29
- [Qemu-block] [PATCH 07/10] aio-win32: remove walking_handlers, protecting AioHandler list with list_lock, Paolo Bonzini, 2016/11/29
- [Qemu-block] [PATCH for-2.9 00/10] aio_context_acquire/release pushdown, part 1, Paolo Bonzini, 2016/11/29