From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
To: Alice Ryhl <aliceryhl@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Andrew Ballance <andrewjballance@gmail.com>,
maple-tree@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] maple_tree: update mas_next[_range] docs
Date: Tue, 20 Jan 2026 12:54:47 -0500 [thread overview]
Message-ID: <tal36hph2g5azjk33h564bllr2n6bz2xhdw4vcvizkhptedfuq@56chjersnkfe> (raw)
In-Reply-To: <20260118-mas-next-doc-v1-1-827d9f4924ce@google.com>
* Alice Ryhl <aliceryhl@google.com> [260118 06:00]:
> If you read the docs, it sounds like the difference between these
> functions is whether mas->index and mas->last are updated. However, if
> you read the implementation, you will instead find that the difference
> is whether NULL entries are skipped.
This is not the intent.
mas_ should return special values including the XA_ZERO_ENTRY.
mas_next() should get the next non-NULL value.
mas_next_range() should advance the maple state to the next range,
regardless of what is in the range (NULL, special, or a regular entry).
Both should update the mas->index and mas->last values, if it moves
(ie, no error state is encountered).
>
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
> ---
> lib/maple_tree.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 5aa4c95000188d3ba461418e09445be78098578e..fe0f0440cd84e7a0fe946d5371e651d153f40d21 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -5293,13 +5293,14 @@ static bool mas_next_setup(struct ma_state *mas, unsigned long max,
> }
>
> /**
> - * mas_next() - Get the next entry.
> + * mas_next() - Advance the maple state to the next range, skipping zero entries.
> * @mas: The maple state
> * @max: The maximum index to check.
> *
> * Returns the next entry after @mas->index.
> + * Updates @mas->index and @mas->last to the range.
> * Must hold rcu_read_lock or the write lock.
> - * Can return the zero entry.
> + * Skips entries reserved with XA_ZERO_ENTRY.
> *
> * Return: The next entry or %NULL
> */
> @@ -5316,11 +5317,12 @@ void *mas_next(struct ma_state *mas, unsigned long max)
> EXPORT_SYMBOL_GPL(mas_next);
>
> /**
> - * mas_next_range() - Advance the maple state to the next range
> + * mas_next_range() - Advance the maple state to the next range.
> * @mas: The maple state
> * @max: The maximum index to check.
> *
> - * Sets @mas->index and @mas->last to the range.
> + * Returns the next entry after @mas->index.
> + * Updates @mas->index and @mas->last to the range.
> * Must hold rcu_read_lock or the write lock.
> * Can return the zero entry.
> *
>
> ---
> base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
> change-id: 20260118-mas-next-doc-20171df817bd
>
> Best regards,
> --
> Alice Ryhl <aliceryhl@google.com>
>
next prev parent reply other threads:[~2026-01-20 17:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-18 11:00 Alice Ryhl
2026-01-20 17:54 ` Liam R. Howlett [this message]
2026-01-21 9:56 ` Alice Ryhl
2026-01-26 20:20 ` Liam R. Howlett
2026-02-04 15:29 ` Alice Ryhl
2026-02-07 8:16 ` Liam R. Howlett
2026-02-09 8:22 ` Alice Ryhl
2026-02-09 18:01 ` 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=tal36hph2g5azjk33h564bllr2n6bz2xhdw4vcvizkhptedfuq@56chjersnkfe \
--to=liam.howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=aliceryhl@google.com \
--cc=andrewjballance@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maple-tree@lists.infradead.org \
/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