[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] posix-aio-compat: Fix idle_threads counter
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH] posix-aio-compat: Fix idle_threads counter |
Date: |
Tue, 3 May 2011 16:56:17 +0100 |
On Tue, May 3, 2011 at 2:26 PM, Kevin Wolf <address@hidden> wrote:
> A thread should only be counted as idle when it really is waiting for new
> requests. Without this patch, sometimes too few threads are started as busy
> threads are counted as idle.
>
> Not sure if it makes a difference in practice outside some artificial
> qemu-io/qemu-img tests, but I think the change makes sense in any case.
>
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
> posix-aio-compat.c | 6 ++----
> 1 files changed, 2 insertions(+), 4 deletions(-)
I think the critical change here is that idle_threads is not being
incremented by spawn_thread(). This means that we will keep spawning
threads as new requests come in and until the first thread goes idle.
Previously you could imagine a scenario where we spawn a thread but
don't schedule it yet. Then we immediately submit more I/O and since
idle_threads was incremented we don't spawn additional threads to
handle the requests.
Are these the cases you were thinking about?
I like your patch because it reduces the number of places where we
mess with idle_threads. I'd move the increment/decrement out of the
loop since the mutex is held here anyway so no one will test
idle_threads between loop iterations, but it's up to you if you want
to send a v2 or not.
Stefan