lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALZtONCNiNdjGdjYUCq3emL+=d=DQmfgVyKS-n0WQyC3CEHWQg@mail.gmail.com>
Date:	Thu, 28 May 2015 17:12:00 -0400
From:	Dan Streetman <ddstreet@...e.org>
To:	Steven Rostedt <rostedt@...dmis.org>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
	Josh Triplett <josh@...htriplett.org>,
	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
	Lai Jiangshan <laijs@...fujitsu.com>,
	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/2] rcu: introduce list_last_or_null_rcu

On Thu, May 28, 2015 at 5:05 PM, Steven Rostedt <rostedt@...dmis.org> wrote:
> On Thu, 28 May 2015 16:35:27 -0400
> Dan Streetman <ddstreet@...e.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).

>
> -- Steve
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ