Re: [PATCH] maple_tree: document that "last" in mtree_insert_range() is inclusive
From: SeongJae Park
Date: Fri May 08 2026 - 21:00:02 EST
On Fri, 8 May 2026 22:51:51 +0200 "Liam R. Howlett" <liam@xxxxxxxxxxxxx> wrote:
> On 26/05/07 06:44AM, Alice Ryhl wrote:
> > On Wed, May 06, 2026 at 10:52:18AM -0400, Steven Rostedt wrote:
> > > From: Steven Rostedt <rostedt@xxxxxxxxxxx>
> > >
> > > The kernel doc of mtree_insert_range() does not state if the address
> > > represented by the "last" parameter is inclusive or exclusive. This can
> > > lead to bugs by code that assumes it is exclusive. Explicitly state that
> > > the parameter is inclusive, and add '[' and ']' around the word "end" to
> > > also stress this point.
> > >
> > > Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
> >
> > Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> >
> > > lib/maple_tree.c | 4 +++-
> > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> > > index 60ae5e6fc1ee..dc9591218446 100644
> > > --- a/lib/maple_tree.c
> > > +++ b/lib/maple_tree.c
> > > @@ -5730,10 +5730,12 @@ EXPORT_SYMBOL(mtree_store);
> > > * mtree_insert_range() - Insert an entry at a given range if there is no value.
> > > * @mt: The maple tree
> > > * @first: The start of the range
> > > - * @last: The end of the range
> > > + * @last: The [end] of the range
> > > * @entry: The entry to store
> > > * @gfp: The GFP_FLAGS to use for allocations.
> > > *
> > > + * Note that @last is inclusive. That is, @last = @first + length - 1;
> >
> > How about writing it like this?
> >
> > * @first: The start of the range
> > * @last: The end of the range (inclusive)
>
>
> I like this.
+1. I'm also wondering if it make sense to add '(inclusive)' for 'first', too.
>
> I think the range should be identified in the initial statement.
> Something like this:
>
> mtree_insert_range() - Insert an entry from [first, last] if there isn't
> an entry within that range.
+1.
Thanks,
SJ
[...]