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