coroutine: switch per-thread free pool to a global pool
commit39a7a362e16bb27e98738d63f24d1ab5811e26a8
authorAvi Kivity <avi@redhat.com>
Mon, 5 Dec 2011 17:20:12 +0000 (5 19:20 +0200)
committerKevin Wolf <kwolf@redhat.com>
Thu, 15 Dec 2011 11:40:33 +0000 (15 12:40 +0100)
treef9f9a0bb72461a25ecafcf0d9e5986573ad9ff4f
parentc2c9a46609164a36b477f6cff1d10ed27a6b53fc
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