From: Kevin Wolf <kwolf@redhat.com>
To: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Cc: qemu-block@nongnu.org, Hanna Reitz <hreitz@redhat.com>,
Stefan Weil <sw@weilnetz.de>,
Aarushi Mehta <mehta.aaru20@gmail.com>,
Julia Suvorova <jusual@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Stefano Garzarella <sgarzare@redhat.com>,
Fam Zheng <fam@euphon.net>,
qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v3 3/3] thread-pool: use ThreadPool from the running thread
Date: Fri, 28 Oct 2022 17:34:15 +0200 [thread overview]
Message-ID: <Y1v2dwsk7lSnfmg0@redhat.com> (raw)
In-Reply-To: <20221028122048.3101120-4-eesposit@redhat.com>
Am 28.10.2022 um 14:20 hat Emanuele Giuseppe Esposito geschrieben:
> Use qemu_get_current_aio_context() where possible, since we always
> submit work to the current thread anyways.
>
> We want to also be sure that the thread submitting the work is
> the same as the one processing the pool, to avoid adding
> synchronization to the pool list.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> diff --git a/util/thread-pool.c b/util/thread-pool.c
> index 31113b5860..0e26687e97 100644
> --- a/util/thread-pool.c
> +++ b/util/thread-pool.c
> @@ -48,7 +48,7 @@ struct ThreadPoolElement {
> /* Access to this list is protected by lock. */
> QTAILQ_ENTRY(ThreadPoolElement) reqs;
>
> - /* Access to this list is protected by the global mutex. */
> + /* This list is only written by the thread pool's mother thread. */
> QLIST_ENTRY(ThreadPoolElement) all;
> };
>
> @@ -251,6 +251,9 @@ BlockAIOCB *thread_pool_submit_aio(ThreadPool *pool,
> {
> ThreadPoolElement *req;
>
> + /* Assert that the thread submitting work is the same running the pool */
> + assert(pool->ctx == qemu_get_current_aio_context());
> +
> req = qemu_aio_get(&thread_pool_aiocb_info, NULL, cb, opaque);
> req->func = func;
> req->arg = arg;
Why don't you drop the aio_context_acquire/release() pair in
thread_pool_completion_bh() any more now that we've added the assertion
to show that it's safe?
Kevin
prev parent reply other threads:[~2022-10-28 15:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-28 12:20 [PATCH v3 0/3] AioContext removal: LinuxAioState and ThreadPool Emanuele Giuseppe Esposito
2022-10-28 12:20 ` [PATCH v3 1/3] linux-aio: use LinuxAioState from the running thread Emanuele Giuseppe Esposito
2022-10-28 15:39 ` Kevin Wolf
2022-10-28 12:20 ` [PATCH v3 2/3] io_uring: use LuringState " Emanuele Giuseppe Esposito
2022-10-28 12:20 ` [PATCH v3 3/3] thread-pool: use ThreadPool " Emanuele Giuseppe Esposito
2022-10-28 15:34 ` 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=Y1v2dwsk7lSnfmg0@redhat.com \
--to=kwolf@redhat.com \
--cc=eesposit@redhat.com \
--cc=fam@euphon.net \
--cc=hreitz@redhat.com \
--cc=jusual@redhat.com \
--cc=mehta.aaru20@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
--cc=sw@weilnetz.de \
/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.