linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: akpm@linux-foundation.org, willy@infradead.org,
	linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org,
	linux-mm@kvack.org
Subject: Re: [RESEND Patch v2 3/3] maple_tree: assert retrieving new value on a tree containing just a leaf node
Date: Mon, 7 Apr 2025 21:45:55 -0400	[thread overview]
Message-ID: <vgiarjjxk2hy2m5nm6vuotizgndofyb6436eaulhamt56ytra3@cjswiccpnrii> (raw)
In-Reply-To: <20250407231354.11771-4-richard.weiyang@gmail.com>

* Wei Yang <richard.weiyang@gmail.com> [250407 19:14]:
> Original code may not get the new value after overwriting the whole
> range on a maple tree containing just a leaf node. The reason is we didn't
> set the only root node dead during destroy.
> 
> Add a test case to ensure the new value is returned when overwriting a
> tree containing just a leaf node.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> CC: Liam R. Howlett <Liam.Howlett@Oracle.com>

Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>

> 
> ---
> v2: adjust the changelog according to Liam's suggestion
> ---
>  tools/testing/radix-tree/maple.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/tools/testing/radix-tree/maple.c b/tools/testing/radix-tree/maple.c
> index bc30050227fd..1e293e4d856d 100644
> --- a/tools/testing/radix-tree/maple.c
> +++ b/tools/testing/radix-tree/maple.c
> @@ -35256,6 +35256,30 @@ static noinline void __init check_rcu_simulated(struct maple_tree *mt)
>  	MT_BUG_ON(mt, mas_prev(&mas_reader, 0) != xa_mk_value(val));
>  	rcu_read_unlock();
>  
> +	/* Clear out tree & create one with only root node */
> +	mas_lock(&mas_writer);
> +	mas_set_range(&mas_writer, 0, ULONG_MAX);
> +	mas_store_gfp(&mas_writer, NULL, GFP_KERNEL);
> +	mas_set_range(&mas_writer, 0, 0);
> +	for (i = 0; i <= 5; i++) {
> +		mas_writer.index = i * 10;
> +		mas_writer.last = i * 10 + 5;
> +		mas_store_gfp(&mas_writer, xa_mk_value(i), GFP_KERNEL);
> +	}
> +	mas_unlock(&mas_writer);
> +	target = 10;
> +	mas_set_range(&mas_reader, target, target);
> +	rcu_read_lock();
> +	MT_BUG_ON(mt, mas_walk(&mas_reader) != xa_mk_value(target/10));
> +
> +	/* Overwrite the whole range */
> +	mas_lock(&mas_writer);
> +	mas_set_range(&mas_writer, 0, ULONG_MAX);
> +	mas_store_gfp(&mas_writer, xa_mk_value(val), GFP_KERNEL);
> +	mas_unlock(&mas_writer);
> +	MT_BUG_ON(mt, mas_walk(&mas_reader) != xa_mk_value(val));
> +	rcu_read_unlock();
> +
>  	rcu_unregister_thread();
>  }
>  
> -- 
> 2.34.1
> 


      reply	other threads:[~2025-04-08  1:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-07 23:13 [RESEND Patch v2 0/3] maple_tree: Fix the replacement of a root " Wei Yang
2025-04-07 23:13 ` [RESEND Patch v2 1/3] maple_tree: Fix mt_destroy_walk() on " Wei Yang
2025-04-08  1:43   ` Liam R. Howlett
2025-04-07 23:13 ` [RESEND Patch v2 2/3] maple_tree: restart walk on correct status Wei Yang
2025-04-07 23:13 ` [RESEND Patch v2 3/3] maple_tree: assert retrieving new value on a tree containing just a leaf node Wei Yang
2025-04-08  1:45   ` Liam R. Howlett [this message]

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=vgiarjjxk2hy2m5nm6vuotizgndofyb6436eaulhamt56ytra3@cjswiccpnrii \
    --to=liam.howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=maple-tree@lists.infradead.org \
    --cc=richard.weiyang@gmail.com \
    --cc=willy@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