lkml.org 
[lkml]   [2021]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 3/9] atomic: Introduce atomic_{inc,dec,dec_and_test}_overflow()
On Mon, Dec 13, 2021 at 10:06:01AM +0000, Mark Rutland wrote:
> On Fri, Dec 10, 2021 at 05:16:21PM +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_overflow(v, Label):
> >
> > increment and goto Label when the old value of v is zero or
> > negative.
> >
> > atomic_dec_overflow(v, Label):
> >
> > decrement and goto Label when the new value of v is zero or
> > negative
> >
> > atomic_dec_and_test_overflow(v, Label):
> >
> > decrement and return true when the result is zero and goto
> > Label when the new value of v is negative
>
> Maybe it's worth adding these as comments in the fallback, which we have for a
> few existing functions, e.g.
>
> | /**
> | * arch_${atomic}_add_negative - add and test if negative
> | * @i: integer value to add
> | * @v: pointer of type ${atomic}_t
> | *
> | * Atomically adds @i to @v and returns true
> | * if the result is negative, or false when
> | * result is greater than or equal to zero.
> | */
> | static __always_inline bool
> | arch_${atomic}_add_negative(${int} i, ${atomic}_t *v)
> | {
> | return arch_${atomic}_add_return(i, v) < 0;
> | }
>
> Not a big deal either way.

I can do that; but the whole ATOMIC*_OVERFLOW_OFFSET thing complicates
all this somewhat. Still, let me try, I've gotta document that anyway..

\
 
 \ /
  Last update: 2021-12-13 11:59    [W:0.682 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site