[Nouveau] [PATCH 2/3] drm/nouveau: add lockless dynamic semaphore allocator (v2)

2010-02-09 Thread Luca Barbieri
Changes in v2: - Addressed review comments - Fixed lockless algorithm (must not dec if negative in addition to if 0) - Made spinlock irqsave (fences are completed in IRQs) This patch adds code to allocate semaphores in a dynamic way using a lockless algorithm. 1. Semaphore BOs Semaphore BOs are

[Nouveau] [PATCH 2/3] drm/nouveau: add lockless dynamic semaphore allocator

2010-02-01 Thread Luca Barbieri
This patch adds code to allocate semaphores in a dynamic way using an algorithm with a lockless fast path. 1. Semaphore BOs Semaphore BOs are BOs containing semaphores. Each is 4KB large and contains 1024 4-byte semaphores. They are pinned. Semaphore BOs are allocated on-demand and freed at

Re: [Nouveau] [PATCH 2/3] drm/nouveau: add lockless dynamic semaphore allocator

2010-02-01 Thread Francisco Jerez
Luca Barbieri l...@luca-barbieri.com writes: This patch adds code to allocate semaphores in a dynamic way using an algorithm with a lockless fast path. 1. Semaphore BOs Semaphore BOs are BOs containing semaphores. Each is 4KB large and contains 1024 4-byte semaphores. They are pinned.

Re: [Nouveau] [PATCH 2/3] drm/nouveau: add lockless dynamic semaphore allocator

2010-02-01 Thread Luca Barbieri
How often do we expect cross-channel sync to kick in? Maybe 2-3 times per frame? I suspect contentions will be rare enough to make spinlocks as fast as atomics for all real-life cases, and they don't have such a high maintainability cost. What do you guys think? For the case of a single (or a

Re: [Nouveau] [PATCH 2/3] drm/nouveau: add lockless dynamic semaphore allocator

2010-02-01 Thread Francisco Jerez
Luca Barbieri l...@luca-barbieri.com writes: How often do we expect cross-channel sync to kick in? Maybe 2-3 times per frame? I suspect contentions will be rare enough to make spinlocks as fast as atomics for all real-life cases, and they don't have such a high maintainability cost. What do

Re: [Nouveau] [PATCH 2/3] drm/nouveau: add lockless dynamic semaphore allocator

2010-02-01 Thread Luca Barbieri
Sounds like premature optimization to me. I'm just stating my personal view here, but I have a feeling a patch with 60% of lines could do very well the same for most realistic cases. Perhaps, but really, the only thing you would probably save by using spinlocks in the fast path is retrying in

Re: [Nouveau] [PATCH 2/3] drm/nouveau: add lockless dynamic semaphore allocator

2010-02-01 Thread Marcin Slusarz
On Mon, Feb 01, 2010 at 10:50:09AM +0100, Luca Barbieri wrote: This patch adds code to allocate semaphores in a dynamic way using an algorithm with a lockless fast path. some minor comments below 1. Semaphore BOs Semaphore BOs are BOs containing semaphores. Each is 4KB large and