[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YbcnHZtbcpLMkoGp@hirez.programming.kicks-ass.net>
Date: Mon, 13 Dec 2021 11:57:33 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Mark Rutland <mark.rutland@....com>
Cc: will@...nel.org, boqun.feng@...il.com,
linux-kernel@...r.kernel.org, x86@...nel.org, elver@...gle.com,
keescook@...omium.org, hch@...radead.org,
torvalds@...ux-foundation.org, axboe@...nel.dk
Subject: Re: [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..
Powered by blists - more mailing lists