Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp610442ybk; Fri, 15 May 2020 09:01:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdKCV3s29QoB0mSx4KV1vPDHGwJNrOxtv3Ebzd0ELJukcUAQqL6IwrodF67g787YtHyAqc X-Received: by 2002:a17:906:2296:: with SMTP id p22mr3348010eja.269.1589558502837; Fri, 15 May 2020 09:01:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589558502; cv=none; d=google.com; s=arc-20160816; b=oh6Y8I83/7cJnip8Ts8z1ivW4F7+TkumVuZ9uR2dJiU0FHXzZ/kg3GFM1pp8ZE0BQi 4Pf5BnJG7NKq41JenPf5ahQt2ytbwghKP23rstQXKJK4mwRR7RkHOQ+GqQs85lcP5gkm u2aA3qQMC0resFigKkdDlg5dY5pVx2rYt7z1XbTTpZCnQT2p+SNTBSF18i+jxSb3gBx6 C/ORXm4jLGI7CRpYbUGRmja49VGVPND6Kbe/Ow3gKsRd0Y3HJDqZJ0n0zfhpNjn6WVg6 OKEWLs/d/bhC1wd06416B0G5FHV3ilrL0yJp+C4WgCfP0921dkNhZDkOtshCk6kG43in f21w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=RcngKTGZLaXD1qK4DRdFIv8yoGnm+yQ5Vpj2lokVS50=; b=c90HjP3ww8WOX5XiHTbQ9eJyPQ8f/puHq74CkbM4z9Z7VkYqhx0+EMbEz10Aeq9iE2 Ohqb3xPvnFzp8s/yi/C+YVYbFK/+FBMxKfLKn31z0Ajtw2GlGnGb4VEudiFLDky+YDJD gxCg8CA4WKZEeEiIRmuMqGmkJB4MQMcpZkzj3W35vKr4WXsEZKr+gw+jJ7lxmZxmV3BG 8Kij0LpsmOqTDzHmkAEs5vQOct/b+WHoaNGSmHT11xeG2IPs3CxD+w7Zy/G+wzUCR+gE 0ntNbgcQev5ANDEw9+GAMEtFAYEg/GphtnbclkFyohiEr1wRdJY2Vfd8k2UMhs04PjQZ DSmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 5si486439edm.573.2020.05.15.09.01.19; Fri, 15 May 2020 09:01:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727072AbgEOP7g (ORCPT + 99 others); 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