From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A66EBC433E1 for ; Fri, 15 May 2020 15:59:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9093E206C0 for ; Fri, 15 May 2020 15:59:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727084AbgEOP7g (ORCPT ); Fri, 15 May 2020 11:59:36 -0400 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:35329 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727012AbgEOP7f (ORCPT ); Fri, 15 May 2020 11:59:35 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04397;MF=laijs@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0Tydbepr_1589558370; Received: from localhost(mailfrom:laijs@linux.alibaba.com fp:SMTPD_---0Tydbepr_1589558370) by smtp.aliyun-inc.com(127.0.0.1); Fri, 15 May 2020 23:59:31 +0800 From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Lai Jiangshan , "Paul E . McKenney" , Oleg Nesterov , Michel Lespinasse , Andrea Arcangeli , Rik van Riel , Mathieu Desnoyers , Peter Zijlstra Subject: [PATCH V2 2/2] rbtree_latch: don't need to check seq when it found a node Date: Fri, 15 May 2020 15:59:09 +0000 Message-Id: <20200515155912.1713-2-laijs@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200515155912.1713-1-laijs@linux.alibaba.com> References: <20200515150122.GY2957@hirez.programming.kicks-ass.net> <20200515155912.1713-1-laijs@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Cc: Paul E. McKenney Cc: Oleg Nesterov Cc: Michel Lespinasse Cc: Andrea Arcangeli Cc: Rik van Riel Cc: Mathieu Desnoyers Acked-by: Peter Zijlstra (Intel) Signed-off-by: Lai Jiangshan --- include/linux/rbtree_latch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/rbtree_latch.h b/include/linux/rbtree_latch.h index 638942f53c0a..affc4b026d9b 100644 --- a/include/linux/rbtree_latch.h +++ b/include/linux/rbtree_latch.h @@ -245,7 +245,7 @@ latch_tree_find(void *key, struct latch_tree_root *root, do { seq = raw_read_seqcount_latch(&root->seq); node = __lt_find(key, root, seq & 1, ops->comp); - } while (read_seqcount_retry(&root->seq, seq)); + } while (!node && read_seqcount_retry(&root->seq, seq)); return node; } -- 2.20.1