Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp742337rwb; Wed, 26 Jul 2023 02:00:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlGIQJkJ7Yz+JBte+JUkbn0TWnu+pSQz9mGwyyetaTzLPAn0iR+Zc4vE42NiC9l1rfIxwZEU X-Received: by 2002:a92:c56b:0:b0:348:dd94:3449 with SMTP id b11-20020a92c56b000000b00348dd943449mr1658694ilj.4.1690362030472; Wed, 26 Jul 2023 02:00:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690362030; cv=none; d=google.com; s=arc-20160816; b=ajc9OIisMi5sXUIWCyGHS/g8a79XNGQn+ayR2uhFBqriIl3VxYdi08+6L+ZFapeG/5 eNcORoq+A2w/qP7TWF0NrMezBeLnilI1Hig+oqfoEG/ByphCOX87a9QaseyC9Zp6vCwT AOo1cZL5kxQXhTrI7RJdG6nddvNJuPkzPIAmDRf1xhtw7zmUMxOjp2LujfeSMd/e4nbW qAQMd027a1ID4zjiGAfQtHHx+4F96Wi87j/PTzI8V8Fla3LIx/DDKpllx9Zix+yXpdLP gHqbPK3Knc7y2xGC3dCGvkrQ8jMLQue6b3gHVC2z/c1Bo7KBtlqGT2wlcay/jkZE+DVD 96Pg== 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=v8uNs+P31bvWCjQDHXfNwA0J1eeKVpGhA2UwqZlpI48=; fh=83ed9mee+o5Uq0I46ZSfSA+aUr2+chEOwR4qsJ7tckA=; b=VXk6ReznKtAHaPaydJLwhp0on6MR4wF8b6ECmy2xGUeNzXxn/x5C4BfBP9C2NnY4lc ZboG5j2zqVjlZAW8imq8pvinLqu2TzPhekBWreRarelGGjcEGNFXFdLyFoiFYU7MAvL6 srZofdrxwxAJPtQJQTNhSQIebRgGuO3/GwvNhAeqZw2d2h4LLKhNV7EQjLU14qhxD9Qo pqbo3KJRoVK71jYFlKKCE/ji8UtDv/UpbzQiAGo4R+SgwEYOih3dyoWJd8p0hzZanXw1 7Md0ftuphATd63RnMoaBJIpj5iZz/WlQ2CpBnkw1uMj8nx35ttVU7KLo85OiMUDkESxI wEyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=CrBUyHbK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q1-20020a17090a304100b00268345e910csi837241pjl.127.2023.07.26.02.00.17; Wed, 26 Jul 2023 02:00:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=CrBUyHbK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233165AbjGZIYO (ORCPT + 99 others); Wed, 26 Jul 2023 04:24:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233197AbjGZIXC (ORCPT ); Wed, 26 Jul 2023 04:23:02 -0400 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCF8E6EB5 for ; Wed, 26 Jul 2023 01:10:30 -0700 (PDT) Received: by mail-oi1-x232.google.com with SMTP id 5614622812f47-3a43cbb432aso4468802b6e.3 for ; Wed, 26 Jul 2023 01:10:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690359029; x=1690963829; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=v8uNs+P31bvWCjQDHXfNwA0J1eeKVpGhA2UwqZlpI48=; b=CrBUyHbKlHgI9bJ+PDdaaetEcpHr3E/W2ZfSeQBeKeVprTl52WIKA+JT3TW5+Ml/Vt ddWID0Zgv01crS6rbjypqKita+JfgnUG4tKAb+l2OFoy32E4s/A8cPZuepcKPkIfxCqK 2Ve0brfKitPbiuM5fkRL7lSTRVdwqr/fwvAm0+bDvcAYv7+oX/fJ7rugbAx694yPbS8C y79T2h1uzsi7M/59p+ojtXI3BlaoZ2svHDneAsizA7/Q0qzjd2Tay0M7mOc+/5KMlRpf Wyv+4A63YfHdc49RtDmJ13nR93qde273z4c2bCDXtCk6qfm/zbcgPqnD0ZeDszcCz3JY T0dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690359029; x=1690963829; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v8uNs+P31bvWCjQDHXfNwA0J1eeKVpGhA2UwqZlpI48=; b=GhND8y0QX/1y/JqADFWzvfY59Y4c2/pbLuJeOdjBZ19Z6VUpKmHoM18guKIg6eZ5ZB k1jMrt4Kr6xv2ZOzrHWbA91NinLaTUme/Ba5v3nwosyMbm0yxpXC3IZWwSlBbgoA3zU0 rXhAcPsGXtLxeRV7zl6aHIhVtbYJVb0n+T+7gzVrcNt/QpJEvfVSwrjm/cX5H5KV9dMA kKp8RjgnFLdqkZm3gAcopxinuEcaaPOm3WH7Ppx5++zGHpdmAvyIev8g1pGnLtoEoG62 7Eqnzb6eIhUS8fQ4mPF/LpJu9mGSt/QQB86V89dwOuryyukntZ6y49vi91hPqb8aU+MF d2MA== X-Gm-Message-State: ABy/qLblFcU3Y5VREasqwwAc9PLV+vMDub3cXjprnj+Hy1oBUr6mBoM9 BaXPqqy0IHRNW/TWHBXJsxZsrQ== X-Received: by 2002:a05:6808:1599:b0:3a1:e3ee:742a with SMTP id t25-20020a056808159900b003a1e3ee742amr1872990oiw.8.1690359029699; Wed, 26 Jul 2023 01:10:29 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id gc17-20020a17090b311100b002680b2d2ab6sm756540pjb.19.2023.07.26.01.10.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 26 Jul 2023 01:10:29 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com, corbet@lwn.net, akpm@linux-foundation.org, willy@infradead.org, brauner@kernel.org, surenb@google.com, michael.christie@oracle.com, peterz@infradead.org, mathieu.desnoyers@efficios.com, npiggin@gmail.com, avagin@gmail.com Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Peng Zhang Subject: [PATCH 07/11] maple_tree: Update the documentation of maple tree Date: Wed, 26 Jul 2023 16:09:12 +0800 Message-Id: <20230726080916.17454-8-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230726080916.17454-1-zhangpeng.00@bytedance.com> References: <20230726080916.17454-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduces the newly introduced mt_dup() and mas_replace_entry(). Signed-off-by: Peng Zhang --- Documentation/core-api/maple_tree.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/core-api/maple_tree.rst b/Documentation/core-api/maple_tree.rst index 45defcf15da7..a4fa991277c7 100644 --- a/Documentation/core-api/maple_tree.rst +++ b/Documentation/core-api/maple_tree.rst @@ -71,6 +71,11 @@ return -EEXIST if the range is not empty. You can search for an entry from an index upwards by using mt_find(). +If you want to duplicate a tree, you can use mt_dup(). It will build a new tree +that is exactly the same as the source tree, and it uses an efficient +implementation, so it is much faster than traversing the source tree and +inserting into the new tree one by one. + You can walk each entry within a range by calling mt_for_each(). You must provide a temporary variable to store a cursor. If you want to walk each element of the tree then ``0`` and ``ULONG_MAX`` may be used as the range. If @@ -115,6 +120,7 @@ Takes ma_lock internally: * mtree_destroy() * mt_set_in_rcu() * mt_clear_in_rcu() + * mt_dup() If you want to take advantage of the internal lock to protect the data structures that you are storing in the Maple Tree, you can call mtree_lock() @@ -155,6 +161,10 @@ You can set entries using mas_store(). mas_store() will overwrite any entry with the new entry and return the first existing entry that is overwritten. The range is passed in as members of the maple state: index and last. +If you have located an entry using something like mas_find(), and want to +replace this entry, you can use mas_replace_entry(), which is more efficient +than mas_store*(). + You can use mas_erase() to erase an entire range by setting index and last of the maple state to the desired range to erase. This will erase the first range that is found in that range, set the maple state index -- 2.20.1