qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 3/3] thread-pool: use ThreadPool from the running thread


From: Kevin Wolf
Subject: Re: [PATCH v3 3/3] thread-pool: use ThreadPool from the running thread
Date: Fri, 28 Oct 2022 17:34:15 +0200

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]