lkml.org 
[lkml]   [2023]   [Nov]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [RFC 1/2] refcount: introduce generic lockptr funcs
Hi,

On Fri, Nov 3, 2023 at 2:54 PM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Fri, Nov 03, 2023 at 12:16:34PM -0400, Alexander Aring wrote:
>
> > diff --git a/lib/refcount.c b/lib/refcount.c
> > index a207a8f22b3c..e28678f0f473 100644
> > --- a/lib/refcount.c
> > +++ b/lib/refcount.c
> > @@ -94,6 +94,34 @@ bool refcount_dec_not_one(refcount_t *r)
> > }
> > EXPORT_SYMBOL(refcount_dec_not_one);
> >
> > +bool refcount_dec_and_lockptr(refcount_t *r, void (*lock)(void *lockptr),
> > + void (*unlock)(void *lockptr), void *lockptr)
> > +{
> > + if (refcount_dec_not_one(r))
> > + return false;
> > +
> > + lock(lockptr);
> > + if (!refcount_dec_and_test(r)) {
> > + unlock(lockptr);
> > + return false;
> > + }
> > +
> > + return true;
> > +}
> > +EXPORT_SYMBOL(refcount_dec_and_lockptr);
>
> This is terrible, you're forcing indirect calls on everything.
>

Okay, I see. How about introducing a macro producing all the code at
preprocessor time?

- Alex

\
 
 \ /
  Last update: 2023-11-20 13:48    [W:0.105 / U:1.532 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site