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 0FEA4C7EE30 for ; Thu, 26 Jun 2025 17:19:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4DEC6B0089; Thu, 26 Jun 2025 13:19:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B70E6B00AC; Thu, 26 Jun 2025 13:19:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8023C6B00A5; Thu, 26 Jun 2025 13:19:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6A7506B0089 for ; Thu, 26 Jun 2025 13:19:34 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id DE4C014031F for ; Thu, 26 Jun 2025 17:19:33 +0000 (UTC) X-FDA: 83598213426.15.BFECB45 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf19.hostedemail.com (Postfix) with ESMTP id 418441A000A for ; Thu, 26 Jun 2025 17:19:32 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of dev.jain@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=dev.jain@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750958372; a=rsa-sha256; cv=none; b=EBh20yZ25i949Zmv8g1DzrRBoHw0yD8/cb07PlUyuRAD4Mw2wfU6P8R+YnIaIDYkOpJyoK Mov9gVoXFRm1Abiq5xv9LIsojk72bWco8shzs6BCgNP9cGUVjqBjAfCDN5xWknJ8W6tSuB 2/sMxQn38aF9lYLkgCsUlgSc3CABmxw= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of dev.jain@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=dev.jain@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750958372; 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; bh=emSiER9cLgUulyiFw2YB4vAitc/TQK0+e+yWttkqi04=; b=YypjcJr5PYYAhIQfApLpDy6a/XGQzMiiyP7hcM9WkjV1eJJuL0p4OnEQZmRvQU4d8ekfwi MeGR6vA2QMhH/JjTf+xTZK29EyUV/REFTx0hsDsF8IarPzzcV+FYUJVR8qpzDPsNF7u2a3 0JztnMt1orPMs9RwEOYMccG3roTnD4I= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BAD771E8D; Thu, 26 Jun 2025 10:19:13 -0700 (PDT) Received: from localhost.localdomain (unknown [10.163.88.58]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9B9B33F762; Thu, 26 Jun 2025 10:19:28 -0700 (PDT) From: Dev Jain To: akpm@linux-foundation.org, Liam.Howlett@oracle.com Cc: richard.weiyang@gmail.com, maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dev Jain Subject: [PATCH 2/2] maple tree: Add and fix some comments Date: Thu, 26 Jun 2025 22:49:18 +0530 Message-Id: <20250626171918.17261-2-dev.jain@arm.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20250626171918.17261-1-dev.jain@arm.com> References: <20250626171918.17261-1-dev.jain@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Stat-Signature: jp94y34m6cwntg5fnfs54dgrkrhtamuo X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 418441A000A X-HE-Tag: 1750958372-798095 X-HE-Meta: U2FsdGVkX1/GNQtaLp/pKL0zZFq172C7XeO11Fgh4vPLbSPIkepPxRNr6xydfIYFbeC3DsM0+yTv8nTtaOm7I23KnTf3oby43ZH9A7WxwDYH6SJHDy3rEooDnl86b707gptoGVvriLqyh5p6MSOArLkGj2x1VLdi5fqF9KZMjaGqvD82TR9euZSpTvkKdeNKsT11bRTtcgley1p6VWwa1l0dLlHiMGt+9zeviTEPThwPoNK2kb8BqdKXT52D+FY4GcM7vd9lMQK6ceKVIlVErrHamRhEgbaZ/sV/b5CHwbHliuQ386FSy9UslKhBKnoaHGWsF/mVfw0QoxZpLyIf5Bh0fwafJmgKuB2X4t9F9pDAInzVG7l87aXemD3/rwzpBRElfO22N0pvbZPOjpqmz+CQ8MtLjMQfQUx3y9x36Akz0/2IOMK7j2ZDXAFG7yOORkuakB6XCHgqldrlg1LhYGqmrtvHdKqrp0Z/dx1cUdfXLsoDbu2InlqPk5M4j53LBCN61g+/tf55sODRw8gjmBWgDLR/nlxLMzXu7FbCI+1XxjnG4fGTZWuN6xsyqCYXihjrJ0+AC6mOgPVT+BmlGNY6p9pJ6iiFhytSL1AzkS3YIFcnb/KthWvYKmP8HiNNbdzFevU0LXXMIFYlbG0UADxlc2YQXWpI0hweE6NmnhUBQyAkudzHLQyxGWCEwjrV9hp9WuhaEpwn5BZ2leFYMtQ0UMGrbJ1lMmJ04FEjZIOg+AJ01a5ydYxXEThso2mie7myQgTIULWWQUdYdjcliCO+9E1XU26hcmGajNnV8w2knRdTzpTpgygicTsINbujA3TPO3jXvp+36xws6jZnWTC9VqSgv2wb+xv6nUO/phG3gEZ1SgGBNZst1PpnqpBREury2ccLkupe/WpC25Dmaqgujx9gSR2a5bHcQ9mysBniF24KreC9yw8lMk2WFerGiPvSEiN0ziTcjnKfjP5 P8zbGPEX 2xjCPHGdEfAua6PeA0/IYIJ2Wy7NgpLRezNpqjtu/SOQZeFDbG4YyzK/XmG2K8PNpESnUH7zeV6C3gBdZE0pTD+T3+fIy/NiIW7wl5SI8CVCUJMAcH7/+owa3MnxdvEMMEro+v8rHC/qqp9HhlAmKezwfciCaMNnyF3xI5rPIpZFjVvm+8AA/SxbfNQARYn6/p1dKTW+n3JsqyXQHHuAIdPPdtQDh4Eem3ji8 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add comments explaining the fields for maple_metadata, since "end" is ambiguous and "gap" can be confused as the largest gap, whereas it is actually the offset of the largest gap. MAPLE_ROOT_NODE is used for mt_mk_root() and mt_safe_root(), indicating that it is used to mark the node as root. So fix the comment. Add comment for mas_ascend() to explain, whose min and max we are trying to find. Explain that, for example, if we are already on offset zero, then the parent min is mas->min, otherwise we need to walk up to find the implied pivot min. Signed-off-by: Dev Jain --- include/linux/maple_tree.h | 4 ++-- lib/maple_tree.c | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index 9ef129038224..bafe143b1f78 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -75,8 +75,8 @@ * searching for gaps or any other code that needs to find the end of the data. */ struct maple_metadata { - unsigned char end; - unsigned char gap; + unsigned char end; /* end of data */ + unsigned char gap; /* offset of largest gap */ }; /* diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 6c89e6790fb5..e4735ccd06f2 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -338,7 +338,7 @@ static inline void mte_set_node_dead(struct maple_enode *mn) smp_wmb(); /* Needed for RCU */ } -/* Bit 1 indicates the root is a node */ +/* Bit 1 indicates the node is the root */ #define MAPLE_ROOT_NODE 0x02 /* maple_type stored bit 3-6 */ #define MAPLE_ENODE_TYPE_SHIFT 0x03 @@ -1053,7 +1053,7 @@ static inline void mte_set_gap(const struct maple_enode *mn, * mas_ascend() - Walk up a level of the tree. * @mas: The maple state * - * Sets the @mas->max and @mas->min to the correct values when walking up. This + * Sets the @mas->max and @mas->min for the parent node of mas->node. This * may cause several levels of walking up to find the correct min and max. * May find a dead node which will cause a premature return. * Return: 1 on dead node, 0 otherwise @@ -1098,6 +1098,11 @@ static int mas_ascend(struct ma_state *mas) min = 0; max = ULONG_MAX; + + /* + * !mas->offset => parent node min == mas->min. mas->offset => need + * to walk up to find the implied pivot min. + */ if (!mas->offset) { min = mas->min; set_min = true; -- 2.30.2