lkml.org 
[lkml]   [2010]   [Aug]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH RFC 02/12] x86/ticketlock: convert spin loop to C
>>> On 02.08.10 at 17:17, Jeremy Fitzhardinge <jeremy@goop.org> wrote:
> On 08/02/2010 08:07 AM, Peter Zijlstra wrote:
>> On Fri, 2010-07-16 at 18:03 -0700, Jeremy Fitzhardinge wrote:
>>> + 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() ?
>
> The compiler treats this as being:

You certainly mean "the compiler currently treats this as being:" - I
don't think there's a guarantee it'll always be doing so.

> for (;;) {
> if (inc.tickets.head == inc.tickets.tail)
> goto out;
> ...
> }
> out: barrier();
> }
>
> (Which would probably be a reasonable way to clarify the code.)

I therefore think it needs to be written this way.

Jan



\
 
 \ /
  Last update: 2010-08-06 14:45    [W:0.395 / U:0.556 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site