On Sat, May 16, 2020 at 12:28 PM Michel Lespinasse <wal...@google.com> wrote: > > On Fri, May 15, 2020 at 03:59:09PM +0000, Lai Jiangshan wrote: > > latch_tree_find() should be protected by caller via RCU or so. > > When it find a node in an attempt, the node must be a valid one > > in RCU's point's of view even the tree is (being) updated with a > > new node with the same key which is entirely subject to timing > > anyway. > > I'm not sure I buy this. Even if we get a valid node, is it the one we > were searching for ? I don't see how this could be guaranteed if the > read raced with a tree rebalancing.
It is valid because ops->comp() returns 0 and it should be the one we were searching for unless ops->comp() is wrong. The searched one could be possible just deleted, but it is still a legitimate searched result in RCU's point's of view. A tree rebalancing can cause a searching fails to find an existing target. This is the job of read_seqcount_retry() to tell you to retry. > > -- > Michel "Walken" Lespinasse > A program is never fully debugged until the last user dies.