[PATCH 07/11] maple_tree: Update the documentation of maple tree

From: Peng Zhang
Date: Wed Jul 26 2023 - 04:24:16 EST


Introduces the newly introduced mt_dup() and mas_replace_entry().

Signed-off-by: Peng Zhang <zhangpeng.00@xxxxxxxxxxxxx>
---
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