On Tue, Dec 07, 2021 at 05:52:13PM +0100, Peter Zijlstra wrote: > It's a bit gross, and there seems to be a problem with macro expansion > of __ofl, but it 'works'. > > --- > diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h > index 5e754e895767..921ecfd5a40b 100644 > --- a/arch/x86/include/asm/atomic.h > +++ b/arch/x86/include/asm/atomic.h > @@ -263,6 +263,22 @@ static __always_inline int arch_atomic_fetch_xor(int i, atomic_t *v) > } > #define arch_atomic_fetch_xor arch_atomic_fetch_xor > > +#define atomic_dec_and_test_ofl(_v, __ofl) \ > +({ \ > + __label__ __zero; \ > + __label__ __out; \ > + bool __ret = false; \ > + asm_volatile_goto (LOCK_PREFIX "decl %[var]\n\t" \ > + "jz %l[__zero]\n\t" \ > + "jl %l[__ofl]" \ %l2 and it works much better... > + : : [var] "m" ((_v)->counter) \ > + : "memory" \ > + : __zero, __ofl); \ > + goto __out; \ > +__zero: __ret = true; \ > +__out: __ret; \ > +})