From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Dan Streetman <ddstreet@ieee.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Andrew Morton <akpm@linux-foundation.org>,
Josh Triplett <josh@joshtriplett.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <laijs@cn.fujitsu.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] rcu: introduce list_last_or_null_rcu
Date: Thu, 28 May 2015 14:16:47 -0700 [thread overview]
Message-ID: <20150528211647.GO5989@linux.vnet.ibm.com> (raw)
In-Reply-To: <CALZtONCNiNdjGdjYUCq3emL+=d=DQmfgVyKS-n0WQyC3CEHWQg@mail.gmail.com>
On Thu, May 28, 2015 at 05:12:00PM -0400, Dan Streetman wrote:
> On Thu, May 28, 2015 at 5:05 PM, Steven Rostedt <rostedt@goodmis.org> wrote:
> > On Thu, 28 May 2015 16:35:27 -0400
> > Dan Streetman <ddstreet@ieee.org> wrote:
> >
> >> Add list_last_or_null_rcu(), to simplify getting the last entry from a
> >> rcu-protected list. The standard list_last_entry() can't be used as it
> >> is not rcu-protected; the list may be modified concurrently. And the
> >> ->prev pointer can't be used, as only the ->next pointers are protected
> >> by rcu.
> >>
> >> This simply iterates forward through the entire list, to get to the last
> >> entry. If the list is empty, it returns NULL.
> >
> > May I asked what this would be used for? It seems awfully inefficient
> > in its implementation. What use cases would this be for? I hate to add
> > something like this as a generic function which would encourage people
> > to use it. Iterating over an entire list to find the last element is
> > just nasty.
>
> i have a patch series that will update zswap to be able to change its
> parameters at runtime, instead of only at boot time. To do that, it
> creates new "pools" dynamically, and keeps them all in a list, with
> only the 1st pool being actively used; any following pools still have
> everything that was stored in them, but they aren't added to. When
> zswap has to "shrink" - by telling one of the pools to get rid of 1 or
> more items - it picks the last on the list. Once a pool is empty,
> it's removed/freed.
>
> So zswap *could* just manually iterate the list to the last element,
> instead of using this new function. But if rcu lists are ever
> improved later on, e.g. if ->prev is somehow rcu-protected as well as
> ->next, then this function should be faster than manually iterating.
>
> if there's a better rcu-way to get to the last list entry, then we
> should definitely use it, although based on my understanding of the
> rcu list implementation, you can only iterate forwards, safely
> (without locking).
The usual approach would be to maintain a tail pointer. How big are
these lists likely to get?
Thanx, Paul
next prev parent reply other threads:[~2015-05-28 21:17 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-28 20:35 [PATCH 1/2] rcu: introduce list_last_or_null_rcu Dan Streetman
2015-05-28 20:36 ` [PATCH 2/2] list: introduce list_last_entry_or_null Dan Streetman
2015-05-28 20:39 ` [PATCH 1/2] rcu: introduce list_last_or_null_rcu josh
2015-05-28 20:42 ` Dan Streetman
2015-05-28 20:44 ` Dan Streetman
2015-05-28 21:06 ` Paul E. McKenney
2015-05-28 21:10 ` josh
2015-05-28 21:05 ` Paul E. McKenney
2015-05-28 21:14 ` Dan Streetman
2015-05-28 21:17 ` Paul E. McKenney
2015-05-28 21:19 ` Dan Streetman
2015-05-28 21:28 ` Steven Rostedt
2015-05-28 21:30 ` Dan Streetman
2015-05-28 21:33 ` Dan Streetman
2015-05-28 21:05 ` Steven Rostedt
2015-05-28 21:12 ` Dan Streetman
2015-05-28 21:16 ` Paul E. McKenney [this message]
2015-05-28 21:24 ` Dan Streetman
2015-05-28 22:29 ` Paul E. McKenney
2015-05-28 23:22 ` Dan Streetman
2015-05-29 13:40 ` Dan Streetman
2015-06-01 18:17 ` Paul E. McKenney
2015-06-01 22:11 ` Dan Streetman
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=20150528211647.GO5989@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=ddstreet@ieee.org \
--cc=josh@joshtriplett.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=rostedt@goodmis.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