coroutine: switch per-thread free pool to a global pool
authorAvi Kivity <avi@redhat.com>
Mon, 5 Dec 2011 17:20:12 +0000 (19:20 +0200)
committerJustin M. Forbes <jforbes@redhat.com>
Tue, 10 Jan 2012 19:36:39 +0000 (13:36 -0600)
commit8939eabe4a4a0402ba604c3bce29904020e5d373
tree9f5df68149392c00027a2f0693ca7393d9051aa9
parenta1cae6a61e85470f15579c1defb38fe7f8318260
coroutine: switch per-thread free pool to a global pool

ucontext-based coroutines use a free pool to reduce allocations and
deallocations of coroutine objects.  The pool is per-thread, presumably
to improve locality.  However, as coroutines are usually allocated in
a vcpu thread and freed in the I/O thread, the pool accounting gets
screwed up and we end allocating and freeing a coroutine for every I/O
request.  This is expensive since large objects are allocated via the
kernel, and are not cached by the C runtime.

Fix by switching to a global pool.  This is safe since we're protected
by the global mutex.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
coroutine-ucontext.c