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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C06EC001DC for ; Wed, 26 Jul 2023 08:10:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D49AC6B007D; Wed, 26 Jul 2023 04:10:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD3146B007E; Wed, 26 Jul 2023 04:10:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B4CF48D0001; Wed, 26 Jul 2023 04:10:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A0DF76B007D for ; Wed, 26 Jul 2023 04:10:32 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 780D3409BA for ; Wed, 26 Jul 2023 08:10:32 +0000 (UTC) X-FDA: 81053041104.03.256380A Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) by imf09.hostedemail.com (Postfix) with ESMTP id 9EE8814000C for ; Wed, 26 Jul 2023 08:10:30 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=CrBUyHbK; spf=pass (imf09.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.167.178 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690359030; a=rsa-sha256; cv=none; b=wPqQVIDi2JxKrKY0yRC/fEOAHxAw9mABkkHfDiad/dwMgopfL5idHt3X+QdgJtL0jX3MIb 9eeVZTJfkGzujgPRRNAoDuJN+NR8sg461MeUSwP87ZbpJu5aKbH0TPPAwg/SJvtmdHkmgx mPssPXQqrVI25D1hS5PLJfQ0DCFVjaE= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=CrBUyHbK; spf=pass (imf09.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.167.178 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690359030; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=v8uNs+P31bvWCjQDHXfNwA0J1eeKVpGhA2UwqZlpI48=; b=LuEN6yUEtTFMzV0nXB2HiBHL1bLeurDoGpAMKWpw6agBk62A4LnBSEd/5kt+bmwv7rF4CP 3ulZrHyI3M7Gbhg5lTF9+FaJpoU1sYWZ8wGT3T8NtYzo97QKjsvAhyRHKFC0P1cj+yb0RK wtBZuG/aolRlmRHvEHaqXW5G/pzcVWg= Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3a3e1152c23so4462586b6e.2 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=fWV4dpe5wOKXkcb26xuHKMHGV/I2TE5h5AUijaGbwGuG7Ecz8f1pq2dftR66QRUhLW xAP2eZ4qr2xvi/6Z3PbmvG/oBnluGrX1jEL/kPi4Qi3SG6D+Io1xuM3mt0Ywf7djOJ2K 1lsVlCwYSwgShrpfrQD8xZPUpAUxAkWM6HSWZcqmq0nTm1bVA79o78v8kJO4bL9OJpPg cypuH8BewXUHbI+WWpVkqlGvi2XBT62YkrvM8MKCWVNV7gWzOQRwgaQkcVdbATwncCxa dU7V9ozu11fi0Yi/73LK69m80zbD58sQg3qB1gZuw/65lA4WUV/8KO3EiGFKfaqxDs17 a46Q== X-Gm-Message-State: ABy/qLb+IDQdrsa+XFSqQXseC07r6cfNUsakDRI+HkayHXUGLS3zpG/T RXyjS2/sg4SgU0wfYQUJvL8sLQ== X-Google-Smtp-Source: APBJJlGhAux4gsHuRlskWB+2hAoyUd2LMLZZMtlCIKrNxAMe0PgykyqeVppW19z8AHH0EfD4FyyaJQ== 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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 9EE8814000C X-Stat-Signature: xeew38zf4z6sj5qxo897tmrztbps5q14 X-Rspam-User: X-HE-Tag: 1690359030-662159 X-HE-Meta: U2FsdGVkX18IVpzw6l6NOhuwIMeHhcd9WI+yH5LiK9oi2+BK5bjjDB/jIP1p0Hj3SLHDClBf+7VQnwAjgY00TUvdxwJx0kLvNxwMCW3Prbg1SZT8HN9H/BU7Dyi0fg5hMrU4tfrxG8Zy3J91AlmssaAoKQ3xNJ3wGirbkaI/8cXyZIeI7dVyGu/jG+HesnwgJqeAxUjsoiZBqbhCaoDhGDD7FSs4n0xVaKv6bCFey5iDw3rCHDDnu8cJTkIdVprhaLNuYPFN3wCVG2yI1eH90MM+GoAK5S+ix9vWz/L0lmF3zyZ3cmVowT23VFIeWMhFm5ZqmKPZRSuPxx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1QeEpHDqQCd57g0oRXBn9OH09KnTF2xuFDjfg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000132, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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