From patchwork Tue Oct 10 11:10:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 150684 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp114839vqb; Tue, 10 Oct 2023 04:11:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWS2Z6yyAib40xqrKpLU2T7/ZwevQwYzM6RmmTvYqUoezmXUTpLf7SPAsLnGoG9n+0iXDx X-Received: by 2002:a05:6a20:144c:b0:14e:a1f0:a8ea with SMTP id a12-20020a056a20144c00b0014ea1f0a8eamr16703576pzi.3.1696936291663; Tue, 10 Oct 2023 04:11:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696936291; cv=none; d=google.com; s=arc-20160816; b=Ck4g56d+6fhoq7qgpf0fYKOduYhSS4pJZKYboIY2ooaziPl1TwhwhecTWi+wAO578N 7ulbN7wEz8Oh0gogDF96vrkdJ7Phjo6kiDcmNlDaoaGBW4aAEHsGiiTjZucMKRCixwPF qVuaxU7mfipaIRfQIk8w1WiINzdP9rS+6VBfm3yXt0tqgt3SdqcXwbUZxsj6MtCYfZnr gP/9Agt/x+V/QzOBEtkYJ6FMMsfpBcAPv9RObVnP6fvWS00hMTwq2vMPvrG/e1aX/qWr 6fX6KAHwLXwe0trQWCgndYI1AZLlR4nr8ZSLnIQaqutT1XioIogwUTA7J3SudgpStjdi CDEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PaGa9fxLLf2KE3s2bExW3RPP2Mjz1tFLZQKVEOxyQek=; fh=FR4fmcRsqBfTLnPLiRL7z/tt06jfKmQoTqOpSCsUl3A=; b=PlhkGmCGMI2CMj0Xg1WUFhaQbzyDjPNANd+vSMxr6Tl9Z+XES5ndxk7xDPDar1dbFA NypMW2xd4DTIT90yZYBzX7ljs2VCepc7CrSzCglO9iHFMParqSZqKwHIUkqO+Ox0IUa5 f59epA5puUcmiN2sMVlg+LyXGcnfWM62hUaToK6sVliLjGtY3SukF//e1ZtZZnFy30jU Fr2Hyd/Ryf7UZNAgu5t6SyaOCf1jo/Sw2ga+pZtqkCDvyYAGjTzhar09SSOtWwcHxOgO mdiPYTjYUyx0372MwLmjUoPA0gBvS7ynW+bxn+ONViB+9TCHalJOVDAuU8erYSjKKRRl g1HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Jc/XD19T"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id dw26-20020a056a00369a00b00690d8c05582si9272351pfb.372.2023.10.10.04.11.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 04:11:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Jc/XD19T"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id CDDCF8024A2D; Tue, 10 Oct 2023 04:11:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231316AbjJJLLJ (ORCPT + 20 others); Tue, 10 Oct 2023 07:11:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231304AbjJJLLI (ORCPT ); Tue, 10 Oct 2023 07:11:08 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 792D1B7; Tue, 10 Oct 2023 04:11:06 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99775C433C7; Tue, 10 Oct 2023 11:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696936266; bh=9iKuAypH43DUxvnbXpZPc2dgGWiCm/Nxs3g2+wjMZ54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jc/XD19T3XpJw9d8eiZM41pJR/YtEhU1RbsWd4HNiYZYM+u/8fYfrkbsEsLzSzoS9 sjOK1rUe5Z0OmZU3wOaJ0BnVGB1pKbToYRugsfscehJBj7hK0V4gv/9uwMgniFdI7d Lje1+mdLML+vyxYpML2y6NtlQkF7EQ11bm2Oonf5Ol5J5wMivmFAOEornBXa3eJoan +Spf8jFvb1ulB5AD1XESR8YyejjSwzRd8v52UjENzEDyv4+Ga/4FjkTq1Yvn1HalX4 j0TNV0yZgnC6qgbSH+1fpj34ALoZlydg/2V4UuoKj2wQY7WEiVJcjqcC9nU+tfI27v Rrhys+jmkvc3Q== From: Frederic Weisbecker To: LKML Cc: "Matthew Wilcox (Oracle)" , Boqun Feng , Joel Fernandes , Josh Triplett , Mathieu Desnoyers , Neeraj Upadhyay , "Paul E . McKenney" , Steven Rostedt , Uladzislau Rezki , rcu , Frederic Weisbecker Subject: [PATCH 2/3] rcu: Describe listRCU read-side guarantees Date: Tue, 10 Oct 2023 13:10:52 +0200 Message-Id: <20231010111053.986507-3-frederic@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010111053.986507-1-frederic@kernel.org> References: <20231010111053.986507-1-frederic@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 10 Oct 2023 04:11:26 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779366668692383121 X-GMAIL-MSGID: 1779366668692383121 From: "Matthew Wilcox (Oracle)" More explicitly state what is, and what is not guaranteed to those who iterate a list while protected by RCU. [ paulmck: Apply Joel Fernandes feedback. ] Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joel Fernandes (Google) Signed-off-by: Paul E. McKenney Signed-off-by: Frederic Weisbecker --- Documentation/RCU/listRCU.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/RCU/listRCU.rst b/Documentation/RCU/listRCU.rst index bdc4bcc5289f..ed5c9d8c9afe 100644 --- a/Documentation/RCU/listRCU.rst +++ b/Documentation/RCU/listRCU.rst @@ -8,6 +8,15 @@ One of the most common uses of RCU is protecting read-mostly linked lists that all of the required memory ordering is provided by the list macros. This document describes several list-based RCU use cases. +When iterating a list while holding the rcu_read_lock(), writers may +modify the list. The reader is guaranteed to see all of the elements +which were added to the list before they acquired the rcu_read_lock() +and are still on the list when they drop the rcu_read_unlock(). +Elements which are added to, or removed from the list may or may not +be seen. If the writer calls list_replace_rcu(), the reader may see +either the old element or the new element; they will not see both, +nor will they see neither. + Example 1: Read-mostly list: Deferred Destruction -------------------------------------------------