From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
To: Dev Jain <dev.jain@arm.com>
Cc: akpm@linux-foundation.org, richard.weiyang@gmail.com,
maple-tree@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] maple tree: Add and fix some comments
Date: Thu, 26 Jun 2025 16:04:55 -0400 [thread overview]
Message-ID: <bxhfvhmk4iyyz7l3nitsgf4xgsydraskligg56n4ww3fe5zlvr@xqzh44dk3q5b> (raw)
In-Reply-To: <20250626171918.17261-2-dev.jain@arm.com>
* Dev Jain <dev.jain@arm.com> [250626 13:19]:
> 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.
That's not quite the entire story here.
The first pointer in the tree may not be a node at all, and may be an
entry. So having that bit set tells us the root of the tree is a node,
so the comment is correct but maybe you have a better way of expressing
this information?
>
> 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 <dev.jain@arm.com>
> ---
> 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 */
Thanks.
> };
>
> /*
> 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.
The => arrows here are a bit hard to parse, especially mixed with ==.
Maybe use more words?
> + */
> if (!mas->offset) {
> min = mas->min;
> set_min = true;
> --
> 2.30.2
>
next prev parent reply other threads:[~2025-06-26 20:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-26 17:19 [PATCH 1/2] maple tree: Clean up mtree_range_walk() Dev Jain
2025-06-26 17:19 ` [PATCH 2/2] maple tree: Add and fix some comments Dev Jain
2025-06-26 20:04 ` Liam R. Howlett [this message]
2025-06-28 11:56 ` Dev Jain
2025-06-29 23:16 ` Wei Yang
2025-07-03 5:54 ` Liam R. Howlett
2025-07-03 6:14 ` Dev Jain
2025-06-26 19:58 ` [PATCH 1/2] maple tree: Clean up mtree_range_walk() Liam R. Howlett
2025-06-28 11:57 ` Dev Jain
2025-07-03 6:00 ` Liam R. Howlett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bxhfvhmk4iyyz7l3nitsgf4xgsydraskligg56n4ww3fe5zlvr@xqzh44dk3q5b \
--to=liam.howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=dev.jain@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maple-tree@lists.infradead.org \
--cc=richard.weiyang@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox