From: Peter Zijlstra <peterz@infradead.org>
To: yajun.deng@linux.dev
Cc: will@kernel.org, boqun.feng@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] refcount: introduce refcount_is_one() helper function
Date: Thu, 18 Nov 2021 11:49:39 +0100 [thread overview]
Message-ID: <YZYvw/uOvjKnY/jM@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <aecc489431c38f170097ae1eb37a7d22@linux.dev>
On Thu, Nov 18, 2021 at 10:34:44AM +0000, yajun.deng@linux.dev wrote:
> November 18, 2021 4:44 PM, "Peter Zijlstra" <peterz@infradead.org> wrote:
>
> > On Thu, Nov 18, 2021 at 08:12:56AM +0000, yajun.deng@linux.dev wrote:
> >
> >> November 18, 2021 3:42 PM, "Peter Zijlstra" <peterz@infradead.org> wrote:
> >>
> >> On Thu, Nov 18, 2021 at 11:53:28AM +0800, Yajun Deng wrote:
> >>
> >> There are many cases where it is necessary to determine if refcount is one,
> >> introduce refcount_is_one() helper function for these cases.
> >>
> >> Give me one that is not racy?
> >>
> >> The following determine refcount is one, 35 count.
> >
> > Very good, now get me one that isn't broken :-)
>
> Sorry, I didn't understand what is the 'isn't broken'。
What's the value of refcount_read() given that at any moment a
concurrent refcount_{inc,dec}() can happen?
If you can't know the current value (per the above) then what's the
value of knowing it was one some time ago?
Fundamentally using refcount_read() in control flow is broken, it's a
very bad anti-pattern.
prev parent reply other threads:[~2021-11-18 10:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-18 3:53 [PATCH] refcount: introduce refcount_is_one() helper function Yajun Deng
2021-11-18 7:42 ` Peter Zijlstra
2021-11-18 8:12 ` yajun.deng
2021-11-18 8:44 ` Peter Zijlstra
2021-11-18 10:34 ` yajun.deng
2021-11-18 10:49 ` Peter Zijlstra [this message]
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=YZYvw/uOvjKnY/jM@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=boqun.feng@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=will@kernel.org \
--cc=yajun.deng@linux.dev \
/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 NNTP newsgroup(s).