[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJhGHyBBqdD7cpxDbRL3myGF7924EDrp0_-RLEd8m10dQGFXzA@mail.gmail.com>
Date: Fri, 28 Aug 2020 12:03:54 +0800
From: Lai Jiangshan <jiangshanlai+lkml@...il.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
Masami Hiramatsu <mhiramat@...nel.org>, Eddy_Wu@...ndmicro.com,
X86 ML <x86@...nel.org>, davem@...emloft.net,
Steven Rostedt <rostedt@...dmis.org>,
naveen.n.rao@...ux.ibm.com, anil.s.keshavamurthy@...el.com,
linux-arch@...r.kernel.org, cameron@...dycamel.com,
Oleg Nesterov <oleg@...hat.com>, Will Deacon <will@...nel.org>,
"Paul E. McKenney" <paulmck@...nel.org>
Subject: Re: [RFC][PATCH 6/7] freelist: Lock less freelist
On Fri, Aug 28, 2020 at 12:23 AM Peter Zijlstra <peterz@...radead.org> wrote:
> +static inline void __freelist_add(struct freelist_node *node, struct freelist_head *list)
> +{
> + /*
> + * Since the refcount is zero, and nobody can increase it once it's
> + * zero (except us, and we run only one copy of this method per node at
> + * a time, i.e. the single thread case), then we know we can safely
> +
> + /*
> + * OK, the head must have changed on us, but we still need to decrement
> + * the refcount we increased.
> + */
> + refs = atomic_fetch_add(-1, &prev->refs);
> + if (refs == REFS_ON_FREELIST + 1)
> + __freelist_add(prev, list);
I'm curious whether it is correct to just set the prev->refs to zero and return
@prev? So that it can remove an unneeded "add()&get()" pair (although in
an unlikely branch) and __freelist_add() can be folded into freelist_add()
for tidier code.
Thanks
Lai.
Powered by blists - more mailing lists