lkml.org 
[lkml]   [2011]   [Jun]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH RFC 0/7] x86: convert ticketlocks to C and remove duplicate code
On 06/21/2011 07:01 AM, Peter Zijlstra wrote:
> One other thing you could contemplate is adding something like:
>
> #define xadd(ptr, inc) \
> do { \
> switch(sizeof(*(ptr))) { \
> case 1: \
> asm volatile (LOCK_PREFIX "xaddb %0, %1\n" \
> : "+r" (inc), "+m" (*(ptr)) \
> : : "memory", "cc"); \
> case 2:
> ... xaddw ...
> case 4:
> ... xaddl ...
> } while (0)
>
> and a similar something for inc. For both there seem to be various asm
> bits left (we could even consider adding xadd to
> arch/x86/include/asm/cmpxchg*.h).

A friend just pointed out that gcc has a "__sync_fetch_and_add()"
intrinsic, which compiles to xadd when used in this context. What's the
general feeling about using these kinds of gcc features?

It also has __sync_bool_compare_and_swap(), which would simplify a lot
of asm/cmpxchg.h...

J


\
 
 \ /
  Last update: 2011-06-22 21:43    [W:0.584 / U:0.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site