On Tue, Jun 11, 2024 at 07:24:48PM +0200, Christoph Hellwig wrote: > On Tue, Jun 11, 2024 at 11:22:04AM -0600, Keith Busch wrote: > > > Is this actually valid for a (S)RCU protected list? If the entry gets > > > added to the new list before the grace period has completed, we could > > > trick a concurrent traversal into following the new list unless I'm > > > mistaken (although chances I'm mistaken on RCU corner cases aren't that > > > low..). > > > > Good call, you are absolutely right that a sync should happen between > > the del and the add for readers to consistently iterate this list. > > > > I might be able to weasel out of this though: our namespace list is > > sorted, and this function wants to append everything from this element > > all the way to the end to the "rm_list": a reader should get the same > > result either way, whether if it was torn at this element or the move > > happened without the reader seeing it. > > > > Now if there was a way to rcu split the list so we don't have to do it > > element by element... > > Isn't that exactly what the list_splice helpers do? We'd just need to > do that exactly once at the cutoff point and not once per namespace. Not a splice since that takes the entire source list; this usage is more aligned to "list_cut_position()", which doesn't look rcu safe as-is, but I think we can make one!