diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2012-10-31 16:34:36 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2012-11-14 18:19:21 +0100 |
commit | d37c975fb134e1b16f09b4e6545e2c0591fb6455 (patch) | |
tree | 284796e24c44051fe9ff58b910d48d34e5184211 /qemu-aio.h | |
parent | 8c82e9a4331bad42dfc01158fbd1e8f4c2f1c957 (diff) | |
download | qemu-d37c975fb134e1b16f09b4e6545e2c0591fb6455.tar.gz qemu-d37c975fb134e1b16f09b4e6545e2c0591fb6455.tar.bz2 qemu-d37c975fb134e1b16f09b4e6545e2c0591fb6455.zip |
aio: use g_slice_alloc() for AIOCB pooling
AIO control blocks are frequently acquired and released because each aio
request involves at least one AIOCB. Therefore, we pool them to avoid
heap allocation overhead.
The problem with the freelist approach in AIOPool is thread-safety. If
we want BlockDriverStates to associate with AioContexts that execute in
multiple threads, then a global freelist becomes a problem.
This patch drops the freelist and instead uses g_slice_alloc() which is
tuned for per-thread fixed-size object pools. qemu_aio_get() and
qemu_aio_release() are now thread-safe.
Note that the change from g_malloc0() to g_slice_alloc() should be safe
since the freelist reuse case doesn't zero the AIOCB either.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qemu-aio.h')
-rw-r--r-- | qemu-aio.h | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/qemu-aio.h b/qemu-aio.h index 111b0b3f0a..b29c509f27 100644 --- a/qemu-aio.h +++ b/qemu-aio.h @@ -24,7 +24,6 @@ typedef void BlockDriverCompletionFunc(void *opaque, int ret); typedef struct AIOPool { void (*cancel)(BlockDriverAIOCB *acb); size_t aiocb_size; - BlockDriverAIOCB *free_aiocb; } AIOPool; struct BlockDriverAIOCB { @@ -32,7 +31,6 @@ struct BlockDriverAIOCB { BlockDriverState *bs; BlockDriverCompletionFunc *cb; void *opaque; - BlockDriverAIOCB *next; }; void *qemu_aio_get(AIOPool *pool, BlockDriverState *bs, |