Re: [Qemu-devel] [PATCH v2 5/7] coroutine: rewrite pool to avoid mutex

2014-12-02 Thread Kevin Wolf
Am 02.12.2014 um 13:13 hat Paolo Bonzini geschrieben: > > > On 02/12/2014 13:09, Peter Lieven wrote: > >> > >> -static void __attribute__((destructor)) coroutine_pool_cleanup(void) > >> -{ > >> -Coroutine *co; > >> -Coroutine *tmp; > >> - > >> -QSLIST_FOREACH_SAFE(co, &pool, pool_next

Re: [Qemu-devel] [PATCH v2 5/7] coroutine: rewrite pool to avoid mutex

2014-12-02 Thread Paolo Bonzini
On 02/12/2014 13:18, Peter Lieven wrote: > On 02.12.2014 13:13, Paolo Bonzini wrote: >> >> On 02/12/2014 13:09, Peter Lieven wrote: -static void __attribute__((destructor)) coroutine_pool_cleanup(void) -{ -Coroutine *co; -Coroutine *tmp; - -QSLIST_FOREACH

Re: [Qemu-devel] [PATCH v2 5/7] coroutine: rewrite pool to avoid mutex

2014-12-02 Thread Peter Lieven
On 02.12.2014 13:13, Paolo Bonzini wrote: On 02/12/2014 13:09, Peter Lieven wrote: -static void __attribute__((destructor)) coroutine_pool_cleanup(void) -{ -Coroutine *co; -Coroutine *tmp; - -QSLIST_FOREACH_SAFE(co, &pool, pool_next, tmp) { -QSLIST_REMOVE_HEAD(&pool, pool_ne

Re: [Qemu-devel] [PATCH v2 5/7] coroutine: rewrite pool to avoid mutex

2014-12-02 Thread Paolo Bonzini
On 02/12/2014 13:09, Peter Lieven wrote: >> >> -static void __attribute__((destructor)) coroutine_pool_cleanup(void) >> -{ >> -Coroutine *co; >> -Coroutine *tmp; >> - >> -QSLIST_FOREACH_SAFE(co, &pool, pool_next, tmp) { >> -QSLIST_REMOVE_HEAD(&pool, pool_next); >> -qem

Re: [Qemu-devel] [PATCH v2 5/7] coroutine: rewrite pool to avoid mutex

2014-12-02 Thread Peter Lieven
On 02.12.2014 12:05, Paolo Bonzini wrote: This patch removes the mutex by using fancy lock-free manipulation of the pool. Lock-free stacks and queues are not hard, but they can suffer from the ABA problem so they are better avoided unless you have some deferred reclamation scheme like RCU. Othe

[Qemu-devel] [PATCH v2 5/7] coroutine: rewrite pool to avoid mutex

2014-12-02 Thread Paolo Bonzini
This patch removes the mutex by using fancy lock-free manipulation of the pool. Lock-free stacks and queues are not hard, but they can suffer from the ABA problem so they are better avoided unless you have some deferred reclamation scheme like RCU. Otherwise you have to stick with adding to a lis