gfs2.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Alexander Aring <aahringo@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: will@kernel.org, gfs2@lists.linux.dev, boqun.feng@gmail.com,
	 mark.rutland@arm.com, linux-kernel@vger.kernel.org
Subject: Re: [RFC 1/2] refcount: introduce generic lockptr funcs
Date: Fri, 3 Nov 2023 15:20:08 -0400	[thread overview]
Message-ID: <CAK-6q+hQnTgmO_2qfNDzyYW36T1aH+a5q285G+Rfo+sN4dfEfA@mail.gmail.com> (raw)
In-Reply-To: <20231103185414.GD8262@noisy.programming.kicks-ass.net>

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


  reply	other threads:[~2023-11-03 19:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-03 16:16 [RFC 1/2] refcount: introduce generic lockptr funcs Alexander Aring
2023-11-03 16:16 ` [RFC 2/2] kref: introduce kref_put_lockptr() and use lockptr Alexander Aring
2023-11-03 18:54 ` [RFC 1/2] refcount: introduce generic lockptr funcs Peter Zijlstra
2023-11-03 19:20   ` Alexander Aring [this message]
2023-11-06 11:11     ` Peter Zijlstra
2023-11-06 15:12       ` Alexander Aring
  -- strict thread matches above, loose matches on Subject: below --
2023-11-03 16:06 Alexander Aring
2023-11-03 16:14 ` Alexander Aring
2023-11-03 16:16   ` Alexander Aring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK-6q+hQnTgmO_2qfNDzyYW36T1aH+a5q285G+Rfo+sN4dfEfA@mail.gmail.com \
    --to=aahringo@redhat.com \
    --cc=boqun.feng@gmail.com \
    --cc=gfs2@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=peterz@infradead.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).