lkml.org 
[lkml]   [2021]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] block: switch to atomic_t for request references
On Tue, Dec 07, 2021 at 02:28:22PM +0100, Peter Zijlstra wrote:
> +static inline void refcount_inc(refcount_t *r)
> +{
> + int one = 1;
> +
> + asm_volatile_goto (LOCK_PREFIX "xaddl %%eax, %[var]\n\t"
> + "addl $1, %%eax\n\t"
> + "je %l[cc_zero]\n\t"
> + "js %l[cc_error]"
> + : : [var] "m" (r->refs.counter), "a" (one)
> + : "memory"
> + : cc_zero, cc_error);

+ asm_volatile_goto (LOCK_PREFIX "xaddl %[reg], %[var]\n\t"
+ "addl $1, %[reg]\n\t"
+ "jz %l[cc_zero]\n\t"
+ "js %l[cc_error]"
+ : : [var] "m" (r->refs.counter), [reg] "r" (1)
+ : "memory"
+ : cc_zero, cc_error);

Is of course a better implementation, but I'm not sure I actually
understand this code. Afaict: add $1,%[reg], will only set ZF when
%[reg] was -1 such that the result is now 0.

But that's not what the code said; is this GCC going funny in the head
or should I just stop staring at this...

\
 
 \ /
  Last update: 2021-12-07 16:52    [W:0.165 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site