lkml.org 
[lkml]   [2010]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH RFC 02/12] x86/ticketlock: convert spin loop to C
    From
    Date
    On Fri, 2010-07-16 at 18:03 -0700, Jeremy Fitzhardinge wrote:
    > + register union {
    > + struct __raw_tickets tickets;
    > + unsigned short slock;
    > + } inc = { .slock = 1 << TICKET_SHIFT };

    register arch_spinlock_t inc = { .tickets = { .head = 1, .tail = 0 } };
    >From a quick look you can basically replace all TICKET_SHIFT usage (1 <<
    TICKET_SHIFT) with such a constant.

    [ Also, does gcc really listen to the register hint these days? ]

    > + asm volatile (LOCK_PREFIX "xaddw %w0, %1\n"
    > + : "+Q" (inc), "+m" (lock->slock) : : "memory", "cc");

    "+Q" (inc->slock)

    > + for (;;) {
    > + if (inc.tickets.head == inc.tickets.tail)
    > + return;
    > + cpu_relax();
    > + inc.tickets.head = ACCESS_ONCE(lock->tickets.head);
    > + }
    > + barrier(); /* make sure nothing creeps before the lock is taken */
    > }

    How will it ever get to that barrier() ?


    \
     
     \ /
      Last update: 2010-08-02 17:09    [W:1.420 / U:0.140 seconds]
    ©2003-2014 Jasper Spaans. hosted at Digital Ocean