lkml.org 
[lkml]   [2021]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] refcount: introduce refcount_is_one() helper function
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.

\
 
 \ /
  Last update: 2021-11-18 11:51    [W:0.117 / U:0.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site