search for: ticket_lock_head_inc

Displaying 4 results from an estimated 4 matches for "ticket_lock_head_inc".

2014 May 28
7
[RFC] Implement Batched (group) ticket lock
...== (inc.tail & + TICKET_LOCK_BATCH_MASK)) + goto spin; cpu_relax(); + inc.head = ACCESS_ONCE(lock->tickets.head); } while (--count); __ticket_lock_spinning(lock, inc.tail); } +spin: + for (;;) { + inc.head = ACCESS_ONCE(lock->tickets.head); + if (!(inc.head & TICKET_LOCK_HEAD_INC)) { + new.head = inc.head | TICKET_LOCK_HEAD_INC; + if (cmpxchg(&lock->tickets.head, inc.head, new.head) + == inc.head) + goto out; + } + cpu_relax(); + } + out: barrier(); /* make sure nothing creeps before the lock is taken */ } @@ -109,7 +122,8 @@ static __always_inline i...
2014 May 28
7
[RFC] Implement Batched (group) ticket lock
...== (inc.tail & + TICKET_LOCK_BATCH_MASK)) + goto spin; cpu_relax(); + inc.head = ACCESS_ONCE(lock->tickets.head); } while (--count); __ticket_lock_spinning(lock, inc.tail); } +spin: + for (;;) { + inc.head = ACCESS_ONCE(lock->tickets.head); + if (!(inc.head & TICKET_LOCK_HEAD_INC)) { + new.head = inc.head | TICKET_LOCK_HEAD_INC; + if (cmpxchg(&lock->tickets.head, inc.head, new.head) + == inc.head) + goto out; + } + cpu_relax(); + } + out: barrier(); /* make sure nothing creeps before the lock is taken */ } @@ -109,7 +122,8 @@ static __always_inline i...
2014 May 29
0
[RFC] Implement Batched (group) ticket lock
...gt; + goto spin; > cpu_relax(); > + inc.head = ACCESS_ONCE(lock->tickets.head); > } while (--count); > __ticket_lock_spinning(lock, inc.tail); > } > +spin: > + for (;;) { > + inc.head = ACCESS_ONCE(lock->tickets.head); > + if (!(inc.head& TICKET_LOCK_HEAD_INC)) { > + new.head = inc.head | TICKET_LOCK_HEAD_INC; > + if (cmpxchg(&lock->tickets.head, inc.head, new.head) > + == inc.head) > + goto out; > + } > + cpu_relax(); > + } > + It had taken me some time to figure out the the LSB of inc.head is used as a bit...
2014 May 28
0
[RFC] Implement Batched (group) ticket lock
...; typedef u16 __ticketpair_t; > #else > @@ -19,7 +20,12 @@ typedef u16 __ticket_t; > typedef u32 __ticketpair_t; > #endif > > -#define TICKET_LOCK_INC ((__ticket_t)__TICKET_LOCK_INC) > +#define TICKET_LOCK_TAIL_INC ((__ticket_t)__TICKET_LOCK_TAIL_INC) > + > +#define TICKET_LOCK_HEAD_INC ((__ticket_t)1) > +#define TICKET_BATCH 0x4 /* 4 waiters can contend simultaneously */ > +#define TICKET_LOCK_BATCH_MASK (~(TICKET_BATCH<<TICKET_LOCK_INC_SHIFT) + \ > + TICKET_LOCK_TAIL_INC - 1) I do not see the value in having TICKET_BATCH declared with a hexadecimal number...