lkml.org 
[lkml]   [2014]   [Jan]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v11 0/4] Introducing a queue read/write lock implementation
On Fri, Jan 31, 2014 at 05:03:48AM -0500, George Spelvin wrote:
> How about getting rid of that TICKET_MSB mess and doing something like:
>
> #define TICKET_MASK 0xFFFF
>
> static inline void ticket_spin_unlock(atomic_t *tickets)
> {
> u32 t = *tickets;
>
> smp_mb__before_atomic_inc();
>
> /* Increment the low 16 bits without affecting the upper. */
> if (unlikely((~t & TICKET_MASK) == 0))
> atomic_add(-(atomic_t)TICKET_MASK, tickets);
> else
> atomic_inc(tickets);
> }
>
> That also allows up to 2^16 waiters, up from 2^15.
> (Minus one on both cases, if you want to be fussy.)

Ah indeed. That'll work. That said, any arch that can single-copy
address shorts can probably do better than this generic atomic_t thing.

My main point was that we should seriously look at a ticket lock instead
of the MCS one, because while the MCS has better contention behaviour,
we shouldn't optimize locks for the worst contention.


\
 
 \ /
  Last update: 2014-01-31 12:01    [W:1.085 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site