lkml.org 
[lkml]   [2021]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH 1/5] atomic: Introduce atomic_{inc,dec,dec_and_test}_ofl()
On Thu, Dec 09, 2021 at 12:42:47PM +0000, Mark Rutland wrote:
> On Wed, Dec 08, 2021 at 07:36:56PM +0100, Peter Zijlstra wrote:
> > In order to facilitate architecture support for refcount_t, introduce
> > a number of new atomic primitives that have a uaccess style exception
> > for overflow.
> >
> > Notably:
> >
> > atomic_inc_ofl(v, Label) -- increment and goto Label when
> > v is zero or negative.
> >
> > atomic_dec_ofl(v, Label) -- decrement and goto Label when
> > the result is zero or negative
> >
> > atomic_dec_and_test_ofl(v, Label) -- decrement and return true when
> > the result is zero and goto Label
> > when the result is negative
>
> Just to check, atomic_inc_ofl() tests the *old* value of `v`, and the other
> cases check the *new* value of `v`?
>
> For clarity, in the descriptions it might be worth:
>
> s/v/the old value of v/
> s/the result/the new value of v/
>
> ... which I think makes that clearer.

Right, I'll clarify.

> > Since the GCC 'Labels as Values' extention doesn't allow having the
> > goto in an inline function, these new 'functions' must in fact be
> > implemented as macro magic.
>
> Oh; fun... :(

Yeah, I tried all sorta things, it's all >.< close to working but then
GCC refuses to do the sensible thing.

> > This meant extending the atomic generation scripts to deal with
> > wrapping macros instead of inline functions. Since
> > xchg/cmpxchg/try_cmpxchg were already macro magic, there was existant
> > code for that. While extending/improving that a few latent
> > 'instrumentation' bugs were uncovered and 'accidentally' fixed.
>
> I assume for non-RFC we can split that out into a preparatory patch. :)

Sure, I can split it in two; one add the infra and fix bugs and two
introduce the new ops.

\
 
 \ /
  Last update: 2021-12-09 14:34    [W:0.052 / U:1.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site