All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/5] refine storing NULL
@ 2024-10-19  2:37 Wei Yang
  2024-10-19  2:37 ` [PATCH v4 1/5] maple_tree: print empty for an empty tree on mt_dump() Wei Yang
                   ` (5 more replies)
  0 siblings, 6 replies; 19+ messages in thread
From: Wei Yang @ 2024-10-19  2:37 UTC (permalink / raw)
  To: akpm, Liam.Howlett; +Cc: maple-tree, linux-mm, Wei Yang

The original thread[1] thoughts it is a problem in mas_new_root(). But after                                                                                                                             
discussion, this should be an improvement on storing NULL.                                                                                                                                               
                                                                                                                                                                                                         
Patch 1/2 preparation for refine.                                                                                                                                                                        
                                                                                                                                                                                                         
Patch 3 remove redundant check in mas_new_root().                                                                                                                                                        
                                                                                                                                                                                                         
Patch 4 refine mas_store_root() to improve memory efficiency and remove                                                                                                                                  
possible consecutive NULL slot.                                                                                                                                                                          
                                                                                                                                                                                                         
Patch 5 adds a test for storing NULL.                                                                                                                                                                    
                                                                                                                                                                                                         
[1]: https://lkml.kernel.org/r/20241015233909.23592-1-richard.weiyang@gmail.com                                                                                                                          

v4:
  patch 3 add a WARN_ON_ONCE()
  patch 4 add a comment and simplify the logic a little
                                                                                                                                                                                                         
v3:                                                                                                                                                                                                      
  patch 4 move the change into mas_store_root()                                                                                                                                                          
  patch 5 move test into lib/test_maple_tree.c

Wei Yang (5):
  maple_tree: print empty for an empty tree on mt_dump()
  maple_tree: the return value of mas_root_expand() is not used
  maple_tree: not necessary to check index/last again
  maple_tree: refine mas_store_root() on storing NULL
  maple_tree: add a test checking storing null

 lib/maple_tree.c      | 29 ++++++++++----
 lib/test_maple_tree.c | 90 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 112 insertions(+), 7 deletions(-)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v4 1/5] maple_tree: print empty for an empty tree on mt_dump()
  2024-10-19  2:37 [PATCH v4 0/5] refine storing NULL Wei Yang
@ 2024-10-19  2:37 ` Wei Yang
  2024-10-29 15:23   ` Liam R. Howlett
  2024-10-19  2:37 ` [PATCH v4 2/5] maple_tree: the return value of mas_root_expand() is not used Wei Yang
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 19+ messages in thread
From: Wei Yang @ 2024-10-19  2:37 UTC (permalink / raw)
  To: akpm, Liam.Howlett
  Cc: maple-tree, linux-mm, Wei Yang, Liam R . Howlett, Sidhartha Kumar,
	Lorenzo Stoakes

Currently for an empty tree, it would print:

  maple_tree(0x7ffcd02c6ee0) flags 1, height 0 root (nil)
  0: (nil)

This is a little misleading.

Let's print (empty) for an empty tree.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
---
 lib/maple_tree.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 3619301dda2e..21e6895b7aef 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -7287,10 +7287,12 @@ void mt_dump(const struct maple_tree *mt, enum mt_dump_format format)
 
 	pr_info("maple_tree(%p) flags %X, height %u root %p\n",
 		 mt, mt->ma_flags, mt_height(mt), entry);
-	if (!xa_is_node(entry))
-		mt_dump_entry(entry, 0, 0, 0, format);
-	else if (entry)
+	if (xa_is_node(entry))
 		mt_dump_node(mt, entry, 0, mt_node_max(entry), 0, format);
+	else if (entry)
+		mt_dump_entry(entry, 0, 0, 0, format);
+	else
+		pr_info("(empty)\n");
 }
 EXPORT_SYMBOL_GPL(mt_dump);
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v4 2/5] maple_tree: the return value of mas_root_expand() is not used
  2024-10-19  2:37 [PATCH v4 0/5] refine storing NULL Wei Yang
  2024-10-19  2:37 ` [PATCH v4 1/5] maple_tree: print empty for an empty tree on mt_dump() Wei Yang
@ 2024-10-19  2:37 ` Wei Yang
  2024-10-29 15:23   ` Liam R. Howlett
  2024-10-19  2:37 ` [PATCH v4 3/5] maple_tree: not necessary to check index/last again Wei Yang
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 19+ messages in thread
From: Wei Yang @ 2024-10-19  2:37 UTC (permalink / raw)
  To: akpm, Liam.Howlett
  Cc: maple-tree, linux-mm, Wei Yang, Liam R . Howlett, Sidhartha Kumar,
	Lorenzo Stoakes

No user of the return value now, just remove it.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
---
 lib/maple_tree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 21e6895b7aef..517ddf2950e6 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -3400,7 +3400,7 @@ static noinline_for_kasan void mas_commit_b_node(struct ma_wr_state *wr_mas,
  * @mas: The maple state
  * @entry: The entry to store into the tree
  */
-static inline int mas_root_expand(struct ma_state *mas, void *entry)
+static inline void mas_root_expand(struct ma_state *mas, void *entry)
 {
 	void *contents = mas_root_locked(mas);
 	enum maple_type type = maple_leaf_64;
@@ -3436,7 +3436,7 @@ static inline int mas_root_expand(struct ma_state *mas, void *entry)
 	ma_set_meta(node, maple_leaf_64, 0, slot);
 	/* swap the new root into the tree */
 	rcu_assign_pointer(mas->tree->ma_root, mte_mk_root(mas->node));
-	return slot;
+	return;
 }
 
 static inline void mas_store_root(struct ma_state *mas, void *entry)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v4 3/5] maple_tree: not necessary to check index/last again
  2024-10-19  2:37 [PATCH v4 0/5] refine storing NULL Wei Yang
  2024-10-19  2:37 ` [PATCH v4 1/5] maple_tree: print empty for an empty tree on mt_dump() Wei Yang
  2024-10-19  2:37 ` [PATCH v4 2/5] maple_tree: the return value of mas_root_expand() is not used Wei Yang
@ 2024-10-19  2:37 ` Wei Yang
  2024-10-29 15:23   ` Liam R. Howlett
  2024-10-19  2:37 ` [PATCH v4 4/5] maple_tree: refine mas_store_root() on storing NULL Wei Yang
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 19+ messages in thread
From: Wei Yang @ 2024-10-19  2:37 UTC (permalink / raw)
  To: akpm, Liam.Howlett
  Cc: maple-tree, linux-mm, Wei Yang, Liam R . Howlett, Sidhartha Kumar,
	Lorenzo Stoakes

Before calling mas_new_root(), the range has been checked.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

---
v4: add WARN_ON_ONCE() to check mis-usage.
---
 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 517ddf2950e6..2226e77c00cb 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -3662,7 +3662,9 @@ static inline void mas_new_root(struct ma_state *mas, void *entry)
 	void __rcu **slots;
 	unsigned long *pivots;
 
-	if (!entry && !mas->index && mas->last == ULONG_MAX) {
+	WARN_ON_ONCE(mas->index || mas->last != ULONG_MAX);
+
+	if (!entry) {
 		mas->depth = 0;
 		mas_set_height(mas);
 		rcu_assign_pointer(mas->tree->ma_root, entry);
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v4 4/5] maple_tree: refine mas_store_root() on storing NULL
  2024-10-19  2:37 [PATCH v4 0/5] refine storing NULL Wei Yang
                   ` (2 preceding siblings ...)
  2024-10-19  2:37 ` [PATCH v4 3/5] maple_tree: not necessary to check index/last again Wei Yang
@ 2024-10-19  2:37 ` Wei Yang
  2024-10-29 15:24   ` Liam R. Howlett
  2024-10-19  2:37 ` [PATCH v4 5/5] maple_tree: add a test checking storing null Wei Yang
  2024-10-19  2:42 ` [PATCH v4 0/5] refine storing NULL Wei Yang
  5 siblings, 1 reply; 19+ messages in thread
From: Wei Yang @ 2024-10-19  2:37 UTC (permalink / raw)
  To: akpm, Liam.Howlett
  Cc: maple-tree, linux-mm, Wei Yang, Liam R . Howlett, Sidhartha Kumar,
	Lorenzo Stoakes

Currently, when storing NULL on mas_store_root(), the behavior could be
improved.

For example possible cases are:

  * store NULL at any range result a new node
  * store NULL at range [m, n] where m > 0 to a single entry tree result
    a new node with range [m, n] set to NULL
  * store NULL at range [m, n] where m > 0 to an empty tree result
    consecutive NULL slot 
  * it allows for multiple NULL entries by expanding root to
    store NULLs to an empty tree

This patch tries to improve in:

  * memory efficient by setting to empty tree instead of using a node
  * remove the possibility of consecutive NULL slot which will prohibit
    extended null in later operation

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

---
v3: move change into mas_store_root()
v4: add a comment and simplify the logic a little
    adjust the change log a little
---
 lib/maple_tree.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 2226e77c00cb..1205a5208cfe 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -3439,9 +3439,20 @@ static inline void mas_root_expand(struct ma_state *mas, void *entry)
 	return;
 }
 
+/*
+ * mas_store_root() - Storing value into root.
+ * @mas: The maple state
+ * @entry: The entry to store.
+ *
+ * There is no root node now and we are storing a value into the root - this
+ * function either assigns the pointer or expands into a node.
+ */
 static inline void mas_store_root(struct ma_state *mas, void *entry)
 {
-	if (likely((mas->last != 0) || (mas->index != 0)))
+	if (!entry) {
+		if (!mas->index)
+			rcu_assign_pointer(mas->tree->ma_root, NULL);
+	} else if (likely((mas->last != 0) || (mas->index != 0)))
 		mas_root_expand(mas, entry);
 	else if (((unsigned long) (entry) & 3) == 2)
 		mas_root_expand(mas, entry);
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v4 5/5] maple_tree: add a test checking storing null
  2024-10-19  2:37 [PATCH v4 0/5] refine storing NULL Wei Yang
                   ` (3 preceding siblings ...)
  2024-10-19  2:37 ` [PATCH v4 4/5] maple_tree: refine mas_store_root() on storing NULL Wei Yang
@ 2024-10-19  2:37 ` Wei Yang
  2024-10-22 17:37   ` kernel test robot
  2024-10-29 15:17   ` Liam R. Howlett
  2024-10-19  2:42 ` [PATCH v4 0/5] refine storing NULL Wei Yang
  5 siblings, 2 replies; 19+ messages in thread
From: Wei Yang @ 2024-10-19  2:37 UTC (permalink / raw)
  To: akpm, Liam.Howlett
  Cc: maple-tree, linux-mm, Wei Yang, Liam R . Howlett, Sidhartha Kumar,
	Lorenzo Stoakes

Add a test to assert that, when storing null to am empty tree or a
single entry tree it will not result into:

  * a root node with range [0, ULONG_MAX] set to NULL
  * a root node with consecutive slot set to NULL

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

---
v3: move test into lib/test_maple_tree.c
---
 lib/test_maple_tree.c | 90 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)

diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c
index 31561e0e1a0d..2ef72f6c6d1b 100644
--- a/lib/test_maple_tree.c
+++ b/lib/test_maple_tree.c
@@ -1387,6 +1387,92 @@ static noinline void __init check_prev_entry(struct maple_tree *mt)
 	mas_unlock(&mas);
 }
 
+static noinline void __init check_store_null(struct maple_tree *mt)
+{
+	MA_STATE(mas, mt, 0, ULONG_MAX);
+
+	/*
+	 * Store NULL at range [0, ULONG_MAX] to an empty tree should result
+	 * in an empty tree
+	 */
+	mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
+	mas_lock(&mas);
+	mas_store_gfp(&mas, NULL, GFP_KERNEL);
+	MT_BUG_ON(mt, !mtree_empty(mt));
+	mas_unlock(&mas);
+	mtree_destroy(mt);
+
+	/*
+	 * Store NULL at any range to an empty tree should result in an empty
+	 * tree
+	 */
+	mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
+	mas_lock(&mas);
+	mas_set_range(&mas, 3, 10);
+	mas_store_gfp(&mas, NULL, GFP_KERNEL);
+	MT_BUG_ON(mt, !mtree_empty(mt));
+	mas_unlock(&mas);
+	mtree_destroy(mt);
+
+	/*
+	 * Store NULL at range [0, ULONG_MAX] to a single entry tree should
+	 * result in an empty tree
+	 */
+	mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
+	mas_lock(&mas);
+	mas_set(&mas, 0);
+	mas_store_gfp(&mas, &mas, GFP_KERNEL);
+	mas_set_range(&mas, 0, ULONG_MAX);
+	mas_store_gfp(&mas, NULL, GFP_KERNEL);
+	MT_BUG_ON(mt, !mtree_empty(mt));
+	mas_unlock(&mas);
+	mtree_destroy(mt);
+
+	/*
+	 * Store NULL at range [0, n] to a single entry tree should
+	 * result in an empty tree
+	 */
+	mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
+	mas_lock(&mas);
+	mas_set(&mas, 0);
+	mas_store_gfp(&mas, &mas, GFP_KERNEL);
+	mas_set_range(&mas, 0, 5);
+	mas_store_gfp(&mas, NULL, GFP_KERNEL);
+	MT_BUG_ON(mt, !mtree_empty(mt));
+	mas_unlock(&mas);
+	mtree_destroy(mt);
+
+	/*
+	 * Store NULL at range [m, n] where m > 0 to a single entry tree
+	 * should still be a single entry tree
+	 */
+	mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
+	mas_lock(&mas);
+	mas_set(&mas, 0);
+	mas_store_gfp(&mas, &mas, GFP_KERNEL);
+	mas_set_range(&mas, 2, 5);
+	mas_store_gfp(&mas, NULL, GFP_KERNEL);
+	MT_BUG_ON(mt, mtree_empty(mt));
+	MT_BUG_ON(mt, xa_is_node(mt->ma_root));
+	mas_unlock(&mas);
+	mtree_destroy(mt);
+
+	/*
+	 * Store NULL at range [0, ULONG_MAX] to a tree with node should
+	 * result in an empty tree
+	 */
+	mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
+	mas_lock(&mas);
+	mas_set_range(&mas, 1, 3);
+	mas_store_gfp(&mas, &mas, GFP_KERNEL);
+	MT_BUG_ON(mt, !xa_is_node(mt->ma_root));
+	mas_set_range(&mas, 0, ULONG_MAX);
+	mas_store_gfp(&mas, NULL, GFP_KERNEL);
+	MT_BUG_ON(mt, !mtree_empty(mt));
+	mas_unlock(&mas);
+	mtree_destroy(mt);
+}
+
 static noinline void __init check_root_expand(struct maple_tree *mt)
 {
 	MA_STATE(mas, mt, 0, 0);
@@ -3710,6 +3796,10 @@ static int __init maple_tree_seed(void)
 	goto skip;
 #endif
 
+	mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE);
+	check_store_null(&tree);
+	mtree_destroy(&tree);
+
 	mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE);
 	check_root_expand(&tree);
 	mtree_destroy(&tree);
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 0/5] refine storing NULL
  2024-10-19  2:37 [PATCH v4 0/5] refine storing NULL Wei Yang
                   ` (4 preceding siblings ...)
  2024-10-19  2:37 ` [PATCH v4 5/5] maple_tree: add a test checking storing null Wei Yang
@ 2024-10-19  2:42 ` Wei Yang
  5 siblings, 0 replies; 19+ messages in thread
From: Wei Yang @ 2024-10-19  2:42 UTC (permalink / raw)
  To: Wei Yang; +Cc: akpm, Liam.Howlett, maple-tree, linux-mm

On Sat, Oct 19, 2024 at 02:37:11AM +0000, Wei Yang wrote:
>The original thread[1] thoughts it is a problem in mas_new_root(). But after                                                                                                                             
>discussion, this should be an improvement on storing NULL.                                                                                                                                               
>                                                                                                                                                                                                         
>Patch 1/2 preparation for refine.                                                                                                                                                                        
>                                                                                                                                                                                                         
>Patch 3 remove redundant check in mas_new_root().                                                                                                                                                        
>                                                                                                                                                                                                         
>Patch 4 refine mas_store_root() to improve memory efficiency and remove                                                                                                                                  
>possible consecutive NULL slot.                                                                                                                                                                          
>                                                                                                                                                                                                         
>Patch 5 adds a test for storing NULL.                                                                                                                                                                    

Forget to say, this is still based on yesterday's master.

4d939780b705 2024-10-17 Merge tag 'mm-hotfixes-stable-2024-10-17-16-08' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

>                                                                                                                                                                                                         
>[1]: https://lkml.kernel.org/r/20241015233909.23592-1-richard.weiyang@gmail.com                                                                                                                          
>
>v4:
>  patch 3 add a WARN_ON_ONCE()
>  patch 4 add a comment and simplify the logic a little
>                                                                                                                                                                                                         
>v3:                                                                                                                                                                                                      
>  patch 4 move the change into mas_store_root()                                                                                                                                                          
>  patch 5 move test into lib/test_maple_tree.c
>
>Wei Yang (5):
>  maple_tree: print empty for an empty tree on mt_dump()
>  maple_tree: the return value of mas_root_expand() is not used
>  maple_tree: not necessary to check index/last again
>  maple_tree: refine mas_store_root() on storing NULL
>  maple_tree: add a test checking storing null
>
> lib/maple_tree.c      | 29 ++++++++++----
> lib/test_maple_tree.c | 90 +++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 112 insertions(+), 7 deletions(-)
>
>-- 
>2.34.1

-- 
Wei Yang
Help you, Help me


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 5/5] maple_tree: add a test checking storing null
  2024-10-19  2:37 ` [PATCH v4 5/5] maple_tree: add a test checking storing null Wei Yang
@ 2024-10-22 17:37   ` kernel test robot
  2024-10-22 23:32     ` Wei Yang
  2024-10-29 15:17   ` Liam R. Howlett
  1 sibling, 1 reply; 19+ messages in thread
From: kernel test robot @ 2024-10-22 17:37 UTC (permalink / raw)
  To: Wei Yang, akpm, Liam.Howlett
  Cc: oe-kbuild-all, maple-tree, linux-mm, Wei Yang, Liam R . Howlett,
	Sidhartha Kumar, Lorenzo Stoakes

Hi Wei,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-nonmm-unstable]
[also build test WARNING on akpm-mm/mm-everything linus/master v6.12-rc4 next-20241022]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Wei-Yang/maple_tree-print-empty-for-an-empty-tree-on-mt_dump/20241019-103832
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable
patch link:    https://lore.kernel.org/r/20241019023716.4516-6-richard.weiyang%40gmail.com
patch subject: [PATCH v4 5/5] maple_tree: add a test checking storing null
config: x86_64-randconfig-123-20241022 (https://download.01.org/0day-ci/archive/20241023/202410230105.UApdwd9S-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241023/202410230105.UApdwd9S-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410230105.UApdwd9S-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> lib/test_maple_tree.c:1456:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
   lib/test_maple_tree.c:1456:9: sparse:     expected void const *entry
   lib/test_maple_tree.c:1456:9: sparse:     got void [noderef] __rcu *ma_root
>> lib/test_maple_tree.c:1456:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
   lib/test_maple_tree.c:1456:9: sparse:     expected void const *entry
   lib/test_maple_tree.c:1456:9: sparse:     got void [noderef] __rcu *ma_root
   lib/test_maple_tree.c:1468:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
   lib/test_maple_tree.c:1468:9: sparse:     expected void const *entry
   lib/test_maple_tree.c:1468:9: sparse:     got void [noderef] __rcu *ma_root
   lib/test_maple_tree.c:1468:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
   lib/test_maple_tree.c:1468:9: sparse:     expected void const *entry
   lib/test_maple_tree.c:1468:9: sparse:     got void [noderef] __rcu *ma_root

vim +1456 lib/test_maple_tree.c

  1389	
  1390	static noinline void __init check_store_null(struct maple_tree *mt)
  1391	{
  1392		MA_STATE(mas, mt, 0, ULONG_MAX);
  1393	
  1394		/*
  1395		 * Store NULL at range [0, ULONG_MAX] to an empty tree should result
  1396		 * in an empty tree
  1397		 */
  1398		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
  1399		mas_lock(&mas);
  1400		mas_store_gfp(&mas, NULL, GFP_KERNEL);
  1401		MT_BUG_ON(mt, !mtree_empty(mt));
  1402		mas_unlock(&mas);
  1403		mtree_destroy(mt);
  1404	
  1405		/*
  1406		 * Store NULL at any range to an empty tree should result in an empty
  1407		 * tree
  1408		 */
  1409		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
  1410		mas_lock(&mas);
  1411		mas_set_range(&mas, 3, 10);
  1412		mas_store_gfp(&mas, NULL, GFP_KERNEL);
  1413		MT_BUG_ON(mt, !mtree_empty(mt));
  1414		mas_unlock(&mas);
  1415		mtree_destroy(mt);
  1416	
  1417		/*
  1418		 * Store NULL at range [0, ULONG_MAX] to a single entry tree should
  1419		 * result in an empty tree
  1420		 */
  1421		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
  1422		mas_lock(&mas);
  1423		mas_set(&mas, 0);
  1424		mas_store_gfp(&mas, &mas, GFP_KERNEL);
  1425		mas_set_range(&mas, 0, ULONG_MAX);
  1426		mas_store_gfp(&mas, NULL, GFP_KERNEL);
  1427		MT_BUG_ON(mt, !mtree_empty(mt));
  1428		mas_unlock(&mas);
  1429		mtree_destroy(mt);
  1430	
  1431		/*
  1432		 * Store NULL at range [0, n] to a single entry tree should
  1433		 * result in an empty tree
  1434		 */
  1435		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
  1436		mas_lock(&mas);
  1437		mas_set(&mas, 0);
  1438		mas_store_gfp(&mas, &mas, GFP_KERNEL);
  1439		mas_set_range(&mas, 0, 5);
  1440		mas_store_gfp(&mas, NULL, GFP_KERNEL);
  1441		MT_BUG_ON(mt, !mtree_empty(mt));
  1442		mas_unlock(&mas);
  1443		mtree_destroy(mt);
  1444	
  1445		/*
  1446		 * Store NULL at range [m, n] where m > 0 to a single entry tree
  1447		 * should still be a single entry tree
  1448		 */
  1449		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
  1450		mas_lock(&mas);
  1451		mas_set(&mas, 0);
  1452		mas_store_gfp(&mas, &mas, GFP_KERNEL);
  1453		mas_set_range(&mas, 2, 5);
  1454		mas_store_gfp(&mas, NULL, GFP_KERNEL);
  1455		MT_BUG_ON(mt, mtree_empty(mt));
> 1456		MT_BUG_ON(mt, xa_is_node(mt->ma_root));
  1457		mas_unlock(&mas);
  1458		mtree_destroy(mt);
  1459	
  1460		/*
  1461		 * Store NULL at range [0, ULONG_MAX] to a tree with node should
  1462		 * result in an empty tree
  1463		 */
  1464		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
  1465		mas_lock(&mas);
  1466		mas_set_range(&mas, 1, 3);
  1467		mas_store_gfp(&mas, &mas, GFP_KERNEL);
  1468		MT_BUG_ON(mt, !xa_is_node(mt->ma_root));
  1469		mas_set_range(&mas, 0, ULONG_MAX);
  1470		mas_store_gfp(&mas, NULL, GFP_KERNEL);
  1471		MT_BUG_ON(mt, !mtree_empty(mt));
  1472		mas_unlock(&mas);
  1473		mtree_destroy(mt);
  1474	}
  1475	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 5/5] maple_tree: add a test checking storing null
  2024-10-22 17:37   ` kernel test robot
@ 2024-10-22 23:32     ` Wei Yang
  2024-10-29 15:29       ` Liam R. Howlett
  0 siblings, 1 reply; 19+ messages in thread
From: Wei Yang @ 2024-10-22 23:32 UTC (permalink / raw)
  To: kernel test robot
  Cc: Wei Yang, akpm, Liam.Howlett, oe-kbuild-all, maple-tree, linux-mm,
	Sidhartha Kumar, Lorenzo Stoakes

On Wed, Oct 23, 2024 at 01:37:50AM +0800, kernel test robot wrote:
>Hi Wei,
>
>kernel test robot noticed the following build warnings:
>
>[auto build test WARNING on akpm-mm/mm-nonmm-unstable]
>[also build test WARNING on akpm-mm/mm-everything linus/master v6.12-rc4 next-20241022]
>[If your patch is applied to the wrong git tree, kindly drop us a note.
>And when submitting patch, we suggest to use '--base' as documented in
>https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
>url:    https://github.com/intel-lab-lkp/linux/commits/Wei-Yang/maple_tree-print-empty-for-an-empty-tree-on-mt_dump/20241019-103832
>base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable
>patch link:    https://lore.kernel.org/r/20241019023716.4516-6-richard.weiyang%40gmail.com
>patch subject: [PATCH v4 5/5] maple_tree: add a test checking storing null
>config: x86_64-randconfig-123-20241022 (https://download.01.org/0day-ci/archive/20241023/202410230105.UApdwd9S-lkp@intel.com/config)
>compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
>reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241023/202410230105.UApdwd9S-lkp@intel.com/reproduce)
>
>If you fix the issue in a separate patch/commit (i.e. not just a new version of
>the same patch/commit), kindly add following tags
>| Reported-by: kernel test robot <lkp@intel.com>
>| Closes: https://lore.kernel.org/oe-kbuild-all/202410230105.UApdwd9S-lkp@intel.com/
>
>sparse warnings: (new ones prefixed by >>)
>>> lib/test_maple_tree.c:1456:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
>   lib/test_maple_tree.c:1456:9: sparse:     expected void const *entry
>   lib/test_maple_tree.c:1456:9: sparse:     got void [noderef] __rcu *ma_root
>>> lib/test_maple_tree.c:1456:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
>   lib/test_maple_tree.c:1456:9: sparse:     expected void const *entry
>   lib/test_maple_tree.c:1456:9: sparse:     got void [noderef] __rcu *ma_root
>   lib/test_maple_tree.c:1468:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
>   lib/test_maple_tree.c:1468:9: sparse:     expected void const *entry
>   lib/test_maple_tree.c:1468:9: sparse:     got void [noderef] __rcu *ma_root
>   lib/test_maple_tree.c:1468:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
>   lib/test_maple_tree.c:1468:9: sparse:     expected void const *entry
>   lib/test_maple_tree.c:1468:9: sparse:     got void [noderef] __rcu *ma_root
>
>vim +1456 lib/test_maple_tree.c
>
>  1389	
>  1390	static noinline void __init check_store_null(struct maple_tree *mt)
>  1391	{
>  1392		MA_STATE(mas, mt, 0, ULONG_MAX);
>  1393	
>  1394		/*
>  1395		 * Store NULL at range [0, ULONG_MAX] to an empty tree should result
>  1396		 * in an empty tree
>  1397		 */
>  1398		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>  1399		mas_lock(&mas);
>  1400		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>  1401		MT_BUG_ON(mt, !mtree_empty(mt));
>  1402		mas_unlock(&mas);
>  1403		mtree_destroy(mt);
>  1404	
>  1405		/*
>  1406		 * Store NULL at any range to an empty tree should result in an empty
>  1407		 * tree
>  1408		 */
>  1409		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>  1410		mas_lock(&mas);
>  1411		mas_set_range(&mas, 3, 10);
>  1412		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>  1413		MT_BUG_ON(mt, !mtree_empty(mt));
>  1414		mas_unlock(&mas);
>  1415		mtree_destroy(mt);
>  1416	
>  1417		/*
>  1418		 * Store NULL at range [0, ULONG_MAX] to a single entry tree should
>  1419		 * result in an empty tree
>  1420		 */
>  1421		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>  1422		mas_lock(&mas);
>  1423		mas_set(&mas, 0);
>  1424		mas_store_gfp(&mas, &mas, GFP_KERNEL);
>  1425		mas_set_range(&mas, 0, ULONG_MAX);
>  1426		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>  1427		MT_BUG_ON(mt, !mtree_empty(mt));
>  1428		mas_unlock(&mas);
>  1429		mtree_destroy(mt);
>  1430	
>  1431		/*
>  1432		 * Store NULL at range [0, n] to a single entry tree should
>  1433		 * result in an empty tree
>  1434		 */
>  1435		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>  1436		mas_lock(&mas);
>  1437		mas_set(&mas, 0);
>  1438		mas_store_gfp(&mas, &mas, GFP_KERNEL);
>  1439		mas_set_range(&mas, 0, 5);
>  1440		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>  1441		MT_BUG_ON(mt, !mtree_empty(mt));
>  1442		mas_unlock(&mas);
>  1443		mtree_destroy(mt);
>  1444	
>  1445		/*
>  1446		 * Store NULL at range [m, n] where m > 0 to a single entry tree
>  1447		 * should still be a single entry tree
>  1448		 */
>  1449		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>  1450		mas_lock(&mas);
>  1451		mas_set(&mas, 0);
>  1452		mas_store_gfp(&mas, &mas, GFP_KERNEL);
>  1453		mas_set_range(&mas, 2, 5);
>  1454		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>  1455		MT_BUG_ON(mt, mtree_empty(mt));
>> 1456		MT_BUG_ON(mt, xa_is_node(mt->ma_root));

Thanks.

Will fix it to xa_is_node(mas_root(&mas)) in next version.


>  1457		mas_unlock(&mas);
>  1458		mtree_destroy(mt);
>  1459	
>  1460		/*
>  1461		 * Store NULL at range [0, ULONG_MAX] to a tree with node should
>  1462		 * result in an empty tree
>  1463		 */
>  1464		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>  1465		mas_lock(&mas);
>  1466		mas_set_range(&mas, 1, 3);
>  1467		mas_store_gfp(&mas, &mas, GFP_KERNEL);
>  1468		MT_BUG_ON(mt, !xa_is_node(mt->ma_root));
>  1469		mas_set_range(&mas, 0, ULONG_MAX);
>  1470		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>  1471		MT_BUG_ON(mt, !mtree_empty(mt));
>  1472		mas_unlock(&mas);
>  1473		mtree_destroy(mt);
>  1474	}
>  1475	
>
>-- 
>0-DAY CI Kernel Test Service
>https://github.com/intel/lkp-tests/wiki

-- 
Wei Yang
Help you, Help me

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 5/5] maple_tree: add a test checking storing null
  2024-10-19  2:37 ` [PATCH v4 5/5] maple_tree: add a test checking storing null Wei Yang
  2024-10-22 17:37   ` kernel test robot
@ 2024-10-29 15:17   ` Liam R. Howlett
  2024-10-29 15:22     ` Liam R. Howlett
  1 sibling, 1 reply; 19+ messages in thread
From: Liam R. Howlett @ 2024-10-29 15:17 UTC (permalink / raw)
  To: Wei Yang; +Cc: akpm, maple-tree, linux-mm, Sidhartha Kumar, Lorenzo Stoakes

* Wei Yang <richard.weiyang@gmail.com> [241018 22:37]:
> Add a test to assert that, when storing null to am empty tree or a
> single entry tree it will not result into:
> 
>   * a root node with range [0, ULONG_MAX] set to NULL
>   * a root node with consecutive slot set to NULL
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
> CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

This patch doesn't apply to the tag you specified or I'm using the wrong
git id.  I tried git id e993457df.

> 
> ---
> v3: move test into lib/test_maple_tree.c
> ---
>  lib/test_maple_tree.c | 90 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 90 insertions(+)
> 
> diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c
> index 31561e0e1a0d..2ef72f6c6d1b 100644
> --- a/lib/test_maple_tree.c
> +++ b/lib/test_maple_tree.c
> @@ -1387,6 +1387,92 @@ static noinline void __init check_prev_entry(struct maple_tree *mt)
>  	mas_unlock(&mas);
>  }
>  
> +static noinline void __init check_store_null(struct maple_tree *mt)
> +{
> +	MA_STATE(mas, mt, 0, ULONG_MAX);
> +
> +	/*
> +	 * Store NULL at range [0, ULONG_MAX] to an empty tree should result
> +	 * in an empty tree
> +	 */
> +	mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> +	mas_lock(&mas);
> +	mas_store_gfp(&mas, NULL, GFP_KERNEL);
> +	MT_BUG_ON(mt, !mtree_empty(mt));
> +	mas_unlock(&mas);
> +	mtree_destroy(mt);
> +
> +	/*
> +	 * Store NULL at any range to an empty tree should result in an empty
> +	 * tree
> +	 */
> +	mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> +	mas_lock(&mas);
> +	mas_set_range(&mas, 3, 10);
> +	mas_store_gfp(&mas, NULL, GFP_KERNEL);
> +	MT_BUG_ON(mt, !mtree_empty(mt));
> +	mas_unlock(&mas);
> +	mtree_destroy(mt);
> +
> +	/*
> +	 * Store NULL at range [0, ULONG_MAX] to a single entry tree should
> +	 * result in an empty tree
> +	 */
> +	mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> +	mas_lock(&mas);
> +	mas_set(&mas, 0);
> +	mas_store_gfp(&mas, &mas, GFP_KERNEL);
> +	mas_set_range(&mas, 0, ULONG_MAX);
> +	mas_store_gfp(&mas, NULL, GFP_KERNEL);
> +	MT_BUG_ON(mt, !mtree_empty(mt));
> +	mas_unlock(&mas);
> +	mtree_destroy(mt);
> +
> +	/*
> +	 * Store NULL at range [0, n] to a single entry tree should
> +	 * result in an empty tree
> +	 */
> +	mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> +	mas_lock(&mas);
> +	mas_set(&mas, 0);
> +	mas_store_gfp(&mas, &mas, GFP_KERNEL);
> +	mas_set_range(&mas, 0, 5);
> +	mas_store_gfp(&mas, NULL, GFP_KERNEL);
> +	MT_BUG_ON(mt, !mtree_empty(mt));
> +	mas_unlock(&mas);
> +	mtree_destroy(mt);
> +
> +	/*
> +	 * Store NULL at range [m, n] where m > 0 to a single entry tree
> +	 * should still be a single entry tree
> +	 */
> +	mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> +	mas_lock(&mas);
> +	mas_set(&mas, 0);
> +	mas_store_gfp(&mas, &mas, GFP_KERNEL);
> +	mas_set_range(&mas, 2, 5);
> +	mas_store_gfp(&mas, NULL, GFP_KERNEL);
> +	MT_BUG_ON(mt, mtree_empty(mt));
> +	MT_BUG_ON(mt, xa_is_node(mt->ma_root));
> +	mas_unlock(&mas);
> +	mtree_destroy(mt);
> +
> +	/*
> +	 * Store NULL at range [0, ULONG_MAX] to a tree with node should
> +	 * result in an empty tree
> +	 */
> +	mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> +	mas_lock(&mas);
> +	mas_set_range(&mas, 1, 3);
> +	mas_store_gfp(&mas, &mas, GFP_KERNEL);
> +	MT_BUG_ON(mt, !xa_is_node(mt->ma_root));
> +	mas_set_range(&mas, 0, ULONG_MAX);
> +	mas_store_gfp(&mas, NULL, GFP_KERNEL);
> +	MT_BUG_ON(mt, !mtree_empty(mt));
> +	mas_unlock(&mas);
> +	mtree_destroy(mt);
> +}
> +
>  static noinline void __init check_root_expand(struct maple_tree *mt)
>  {
>  	MA_STATE(mas, mt, 0, 0);
> @@ -3710,6 +3796,10 @@ static int __init maple_tree_seed(void)
>  	goto skip;
>  #endif
>  
> +	mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE);
> +	check_store_null(&tree);
> +	mtree_destroy(&tree);
> +
>  	mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE);
>  	check_root_expand(&tree);
>  	mtree_destroy(&tree);
> -- 
> 2.34.1
> 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 5/5] maple_tree: add a test checking storing null
  2024-10-29 15:17   ` Liam R. Howlett
@ 2024-10-29 15:22     ` Liam R. Howlett
  0 siblings, 0 replies; 19+ messages in thread
From: Liam R. Howlett @ 2024-10-29 15:22 UTC (permalink / raw)
  To: Wei Yang, akpm, maple-tree, linux-mm, Sidhartha Kumar,
	Lorenzo Stoakes

* Liam R. Howlett <Liam.Howlett@oracle.com> [241029 11:17]:
> * Wei Yang <richard.weiyang@gmail.com> [241018 22:37]:
> > Add a test to assert that, when storing null to am empty tree or a
> > single entry tree it will not result into:
> > 
> >   * a root node with range [0, ULONG_MAX] set to NULL
> >   * a root node with consecutive slot set to NULL
> > 
> > Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> > CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
> > CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> > CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> 
> This patch doesn't apply to the tag you specified or I'm using the wrong
> git id.  I tried git id e993457df.

It seems okay and looks good.

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



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 1/5] maple_tree: print empty for an empty tree on mt_dump()
  2024-10-19  2:37 ` [PATCH v4 1/5] maple_tree: print empty for an empty tree on mt_dump() Wei Yang
@ 2024-10-29 15:23   ` Liam R. Howlett
  0 siblings, 0 replies; 19+ messages in thread
From: Liam R. Howlett @ 2024-10-29 15:23 UTC (permalink / raw)
  To: Wei Yang; +Cc: akpm, maple-tree, linux-mm, Sidhartha Kumar, Lorenzo Stoakes

* Wei Yang <richard.weiyang@gmail.com> [241018 22:37]:
> Currently for an empty tree, it would print:
> 
>   maple_tree(0x7ffcd02c6ee0) flags 1, height 0 root (nil)
>   0: (nil)
> 
> This is a little misleading.
> 
> Let's print (empty) for an empty tree.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
> CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

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

> ---
>  lib/maple_tree.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 3619301dda2e..21e6895b7aef 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -7287,10 +7287,12 @@ void mt_dump(const struct maple_tree *mt, enum mt_dump_format format)
>  
>  	pr_info("maple_tree(%p) flags %X, height %u root %p\n",
>  		 mt, mt->ma_flags, mt_height(mt), entry);
> -	if (!xa_is_node(entry))
> -		mt_dump_entry(entry, 0, 0, 0, format);
> -	else if (entry)
> +	if (xa_is_node(entry))
>  		mt_dump_node(mt, entry, 0, mt_node_max(entry), 0, format);
> +	else if (entry)
> +		mt_dump_entry(entry, 0, 0, 0, format);
> +	else
> +		pr_info("(empty)\n");
>  }
>  EXPORT_SYMBOL_GPL(mt_dump);
>  
> -- 
> 2.34.1
> 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 2/5] maple_tree: the return value of mas_root_expand() is not used
  2024-10-19  2:37 ` [PATCH v4 2/5] maple_tree: the return value of mas_root_expand() is not used Wei Yang
@ 2024-10-29 15:23   ` Liam R. Howlett
  0 siblings, 0 replies; 19+ messages in thread
From: Liam R. Howlett @ 2024-10-29 15:23 UTC (permalink / raw)
  To: Wei Yang; +Cc: akpm, maple-tree, linux-mm, Sidhartha Kumar, Lorenzo Stoakes

* Wei Yang <richard.weiyang@gmail.com> [241018 22:37]:
> No user of the return value now, just remove it.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
> CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

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

> ---
>  lib/maple_tree.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 21e6895b7aef..517ddf2950e6 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -3400,7 +3400,7 @@ static noinline_for_kasan void mas_commit_b_node(struct ma_wr_state *wr_mas,
>   * @mas: The maple state
>   * @entry: The entry to store into the tree
>   */
> -static inline int mas_root_expand(struct ma_state *mas, void *entry)
> +static inline void mas_root_expand(struct ma_state *mas, void *entry)
>  {
>  	void *contents = mas_root_locked(mas);
>  	enum maple_type type = maple_leaf_64;
> @@ -3436,7 +3436,7 @@ static inline int mas_root_expand(struct ma_state *mas, void *entry)
>  	ma_set_meta(node, maple_leaf_64, 0, slot);
>  	/* swap the new root into the tree */
>  	rcu_assign_pointer(mas->tree->ma_root, mte_mk_root(mas->node));
> -	return slot;
> +	return;
>  }
>  
>  static inline void mas_store_root(struct ma_state *mas, void *entry)
> -- 
> 2.34.1
> 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 3/5] maple_tree: not necessary to check index/last again
  2024-10-19  2:37 ` [PATCH v4 3/5] maple_tree: not necessary to check index/last again Wei Yang
@ 2024-10-29 15:23   ` Liam R. Howlett
  0 siblings, 0 replies; 19+ messages in thread
From: Liam R. Howlett @ 2024-10-29 15:23 UTC (permalink / raw)
  To: Wei Yang; +Cc: akpm, maple-tree, linux-mm, Sidhartha Kumar, Lorenzo Stoakes

* Wei Yang <richard.weiyang@gmail.com> [241018 22:37]:
> Before calling mas_new_root(), the range has been checked.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
> CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> 

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

> ---
> v4: add WARN_ON_ONCE() to check mis-usage.
> ---
>  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 517ddf2950e6..2226e77c00cb 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -3662,7 +3662,9 @@ static inline void mas_new_root(struct ma_state *mas, void *entry)
>  	void __rcu **slots;
>  	unsigned long *pivots;
>  
> -	if (!entry && !mas->index && mas->last == ULONG_MAX) {
> +	WARN_ON_ONCE(mas->index || mas->last != ULONG_MAX);
> +
> +	if (!entry) {
>  		mas->depth = 0;
>  		mas_set_height(mas);
>  		rcu_assign_pointer(mas->tree->ma_root, entry);
> -- 
> 2.34.1
> 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 4/5] maple_tree: refine mas_store_root() on storing NULL
  2024-10-19  2:37 ` [PATCH v4 4/5] maple_tree: refine mas_store_root() on storing NULL Wei Yang
@ 2024-10-29 15:24   ` Liam R. Howlett
  0 siblings, 0 replies; 19+ messages in thread
From: Liam R. Howlett @ 2024-10-29 15:24 UTC (permalink / raw)
  To: Wei Yang; +Cc: akpm, maple-tree, linux-mm, Sidhartha Kumar, Lorenzo Stoakes

* Wei Yang <richard.weiyang@gmail.com> [241018 22:37]:
> Currently, when storing NULL on mas_store_root(), the behavior could be
> improved.
> 
> For example possible cases are:
> 
>   * store NULL at any range result a new node
>   * store NULL at range [m, n] where m > 0 to a single entry tree result
>     a new node with range [m, n] set to NULL
>   * store NULL at range [m, n] where m > 0 to an empty tree result
>     consecutive NULL slot 
>   * it allows for multiple NULL entries by expanding root to
>     store NULLs to an empty tree
> 
> This patch tries to improve in:
> 
>   * memory efficient by setting to empty tree instead of using a node
>   * remove the possibility of consecutive NULL slot which will prohibit
>     extended null in later operation
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
> CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

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

> 
> ---
> v3: move change into mas_store_root()
> v4: add a comment and simplify the logic a little
>     adjust the change log a little
> ---
>  lib/maple_tree.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 2226e77c00cb..1205a5208cfe 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -3439,9 +3439,20 @@ static inline void mas_root_expand(struct ma_state *mas, void *entry)
>  	return;
>  }
>  
> +/*
> + * mas_store_root() - Storing value into root.
> + * @mas: The maple state
> + * @entry: The entry to store.
> + *
> + * There is no root node now and we are storing a value into the root - this
> + * function either assigns the pointer or expands into a node.
> + */
>  static inline void mas_store_root(struct ma_state *mas, void *entry)
>  {
> -	if (likely((mas->last != 0) || (mas->index != 0)))
> +	if (!entry) {
> +		if (!mas->index)
> +			rcu_assign_pointer(mas->tree->ma_root, NULL);
> +	} else if (likely((mas->last != 0) || (mas->index != 0)))
>  		mas_root_expand(mas, entry);
>  	else if (((unsigned long) (entry) & 3) == 2)
>  		mas_root_expand(mas, entry);
> -- 
> 2.34.1
> 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 5/5] maple_tree: add a test checking storing null
  2024-10-22 23:32     ` Wei Yang
@ 2024-10-29 15:29       ` Liam R. Howlett
  2024-10-31  8:02         ` Wei Yang
  0 siblings, 1 reply; 19+ messages in thread
From: Liam R. Howlett @ 2024-10-29 15:29 UTC (permalink / raw)
  To: Wei Yang
  Cc: kernel test robot, akpm, oe-kbuild-all, maple-tree, linux-mm,
	Sidhartha Kumar, Lorenzo Stoakes

* Wei Yang <richard.weiyang@gmail.com> [241022 19:32]:
> On Wed, Oct 23, 2024 at 01:37:50AM +0800, kernel test robot wrote:
> >Hi Wei,
> >
> >kernel test robot noticed the following build warnings:
> >
> >[auto build test WARNING on akpm-mm/mm-nonmm-unstable]
> >[also build test WARNING on akpm-mm/mm-everything linus/master v6.12-rc4 next-20241022]
> >[If your patch is applied to the wrong git tree, kindly drop us a note.
> >And when submitting patch, we suggest to use '--base' as documented in
> >https://git-scm.com/docs/git-format-patch#_base_tree_information]
> >
> >url:    https://github.com/intel-lab-lkp/linux/commits/Wei-Yang/maple_tree-print-empty-for-an-empty-tree-on-mt_dump/20241019-103832
> >base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable
> >patch link:    https://lore.kernel.org/r/20241019023716.4516-6-richard.weiyang%40gmail.com
> >patch subject: [PATCH v4 5/5] maple_tree: add a test checking storing null
> >config: x86_64-randconfig-123-20241022 (https://download.01.org/0day-ci/archive/20241023/202410230105.UApdwd9S-lkp@intel.com/config)
> >compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
> >reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241023/202410230105.UApdwd9S-lkp@intel.com/reproduce)
> >
> >If you fix the issue in a separate patch/commit (i.e. not just a new version of
> >the same patch/commit), kindly add following tags
> >| Reported-by: kernel test robot <lkp@intel.com>
> >| Closes: https://lore.kernel.org/oe-kbuild-all/202410230105.UApdwd9S-lkp@intel.com/
> >
> >sparse warnings: (new ones prefixed by >>)
> >>> lib/test_maple_tree.c:1456:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
> >   lib/test_maple_tree.c:1456:9: sparse:     expected void const *entry
> >   lib/test_maple_tree.c:1456:9: sparse:     got void [noderef] __rcu *ma_root
> >>> lib/test_maple_tree.c:1456:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
> >   lib/test_maple_tree.c:1456:9: sparse:     expected void const *entry
> >   lib/test_maple_tree.c:1456:9: sparse:     got void [noderef] __rcu *ma_root
> >   lib/test_maple_tree.c:1468:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
> >   lib/test_maple_tree.c:1468:9: sparse:     expected void const *entry
> >   lib/test_maple_tree.c:1468:9: sparse:     got void [noderef] __rcu *ma_root
> >   lib/test_maple_tree.c:1468:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
> >   lib/test_maple_tree.c:1468:9: sparse:     expected void const *entry
> >   lib/test_maple_tree.c:1468:9: sparse:     got void [noderef] __rcu *ma_root
> >
> >vim +1456 lib/test_maple_tree.c
> >
> >  1389	
> >  1390	static noinline void __init check_store_null(struct maple_tree *mt)
> >  1391	{
> >  1392		MA_STATE(mas, mt, 0, ULONG_MAX);
> >  1393	
> >  1394		/*
> >  1395		 * Store NULL at range [0, ULONG_MAX] to an empty tree should result
> >  1396		 * in an empty tree
> >  1397		 */
> >  1398		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> >  1399		mas_lock(&mas);
> >  1400		mas_store_gfp(&mas, NULL, GFP_KERNEL);
> >  1401		MT_BUG_ON(mt, !mtree_empty(mt));
> >  1402		mas_unlock(&mas);
> >  1403		mtree_destroy(mt);
> >  1404	
> >  1405		/*
> >  1406		 * Store NULL at any range to an empty tree should result in an empty
> >  1407		 * tree
> >  1408		 */
> >  1409		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> >  1410		mas_lock(&mas);
> >  1411		mas_set_range(&mas, 3, 10);
> >  1412		mas_store_gfp(&mas, NULL, GFP_KERNEL);
> >  1413		MT_BUG_ON(mt, !mtree_empty(mt));
> >  1414		mas_unlock(&mas);
> >  1415		mtree_destroy(mt);
> >  1416	
> >  1417		/*
> >  1418		 * Store NULL at range [0, ULONG_MAX] to a single entry tree should
> >  1419		 * result in an empty tree
> >  1420		 */
> >  1421		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> >  1422		mas_lock(&mas);
> >  1423		mas_set(&mas, 0);
> >  1424		mas_store_gfp(&mas, &mas, GFP_KERNEL);
> >  1425		mas_set_range(&mas, 0, ULONG_MAX);
> >  1426		mas_store_gfp(&mas, NULL, GFP_KERNEL);
> >  1427		MT_BUG_ON(mt, !mtree_empty(mt));
> >  1428		mas_unlock(&mas);
> >  1429		mtree_destroy(mt);
> >  1430	
> >  1431		/*
> >  1432		 * Store NULL at range [0, n] to a single entry tree should
> >  1433		 * result in an empty tree
> >  1434		 */
> >  1435		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> >  1436		mas_lock(&mas);
> >  1437		mas_set(&mas, 0);
> >  1438		mas_store_gfp(&mas, &mas, GFP_KERNEL);
> >  1439		mas_set_range(&mas, 0, 5);
> >  1440		mas_store_gfp(&mas, NULL, GFP_KERNEL);
> >  1441		MT_BUG_ON(mt, !mtree_empty(mt));
> >  1442		mas_unlock(&mas);
> >  1443		mtree_destroy(mt);
> >  1444	
> >  1445		/*
> >  1446		 * Store NULL at range [m, n] where m > 0 to a single entry tree
> >  1447		 * should still be a single entry tree
> >  1448		 */
> >  1449		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> >  1450		mas_lock(&mas);
> >  1451		mas_set(&mas, 0);
> >  1452		mas_store_gfp(&mas, &mas, GFP_KERNEL);
> >  1453		mas_set_range(&mas, 2, 5);
> >  1454		mas_store_gfp(&mas, NULL, GFP_KERNEL);
> >  1455		MT_BUG_ON(mt, mtree_empty(mt));
> >> 1456		MT_BUG_ON(mt, xa_is_node(mt->ma_root));
> 
> Thanks.
> 
> Will fix it to xa_is_node(mas_root(&mas)) in next version.

By the looks of the bot output, there are quite a lot of existing cases
of this in the test code.

> 
> 
> >  1457		mas_unlock(&mas);
> >  1458		mtree_destroy(mt);
> >  1459	
> >  1460		/*
> >  1461		 * Store NULL at range [0, ULONG_MAX] to a tree with node should
> >  1462		 * result in an empty tree
> >  1463		 */
> >  1464		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> >  1465		mas_lock(&mas);
> >  1466		mas_set_range(&mas, 1, 3);
> >  1467		mas_store_gfp(&mas, &mas, GFP_KERNEL);
> >  1468		MT_BUG_ON(mt, !xa_is_node(mt->ma_root));
> >  1469		mas_set_range(&mas, 0, ULONG_MAX);
> >  1470		mas_store_gfp(&mas, NULL, GFP_KERNEL);
> >  1471		MT_BUG_ON(mt, !mtree_empty(mt));
> >  1472		mas_unlock(&mas);
> >  1473		mtree_destroy(mt);
> >  1474	}
> >  1475	
> >
> >-- 
> >0-DAY CI Kernel Test Service
> >https://github.com/intel/lkp-tests/wiki
> 
> -- 
> Wei Yang
> Help you, Help me

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 5/5] maple_tree: add a test checking storing null
  2024-10-29 15:29       ` Liam R. Howlett
@ 2024-10-31  8:02         ` Wei Yang
  2024-10-31 11:17           ` Liam R. Howlett
  0 siblings, 1 reply; 19+ messages in thread
From: Wei Yang @ 2024-10-31  8:02 UTC (permalink / raw)
  To: Liam R. Howlett, Wei Yang, kernel test robot, akpm, oe-kbuild-all,
	maple-tree, linux-mm, Sidhartha Kumar, Lorenzo Stoakes

On Tue, Oct 29, 2024 at 11:29:39AM -0400, Liam R. Howlett wrote:
>* Wei Yang <richard.weiyang@gmail.com> [241022 19:32]:
>> On Wed, Oct 23, 2024 at 01:37:50AM +0800, kernel test robot wrote:
>> >Hi Wei,
>> >
>> >kernel test robot noticed the following build warnings:
>> >
>> >[auto build test WARNING on akpm-mm/mm-nonmm-unstable]
>> >[also build test WARNING on akpm-mm/mm-everything linus/master v6.12-rc4 next-20241022]
>> >[If your patch is applied to the wrong git tree, kindly drop us a note.
>> >And when submitting patch, we suggest to use '--base' as documented in
>> >https://git-scm.com/docs/git-format-patch#_base_tree_information]
>> >
>> >url:    https://github.com/intel-lab-lkp/linux/commits/Wei-Yang/maple_tree-print-empty-for-an-empty-tree-on-mt_dump/20241019-103832
>> >base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable
>> >patch link:    https://lore.kernel.org/r/20241019023716.4516-6-richard.weiyang%40gmail.com
>> >patch subject: [PATCH v4 5/5] maple_tree: add a test checking storing null
>> >config: x86_64-randconfig-123-20241022 (https://download.01.org/0day-ci/archive/20241023/202410230105.UApdwd9S-lkp@intel.com/config)
>> >compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
>> >reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241023/202410230105.UApdwd9S-lkp@intel.com/reproduce)
>> >
>> >If you fix the issue in a separate patch/commit (i.e. not just a new version of
>> >the same patch/commit), kindly add following tags
>> >| Reported-by: kernel test robot <lkp@intel.com>
>> >| Closes: https://lore.kernel.org/oe-kbuild-all/202410230105.UApdwd9S-lkp@intel.com/
>> >
>> >sparse warnings: (new ones prefixed by >>)
>> >>> lib/test_maple_tree.c:1456:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
>> >   lib/test_maple_tree.c:1456:9: sparse:     expected void const *entry
>> >   lib/test_maple_tree.c:1456:9: sparse:     got void [noderef] __rcu *ma_root
>> >>> lib/test_maple_tree.c:1456:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
>> >   lib/test_maple_tree.c:1456:9: sparse:     expected void const *entry
>> >   lib/test_maple_tree.c:1456:9: sparse:     got void [noderef] __rcu *ma_root
>> >   lib/test_maple_tree.c:1468:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
>> >   lib/test_maple_tree.c:1468:9: sparse:     expected void const *entry
>> >   lib/test_maple_tree.c:1468:9: sparse:     got void [noderef] __rcu *ma_root
>> >   lib/test_maple_tree.c:1468:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
>> >   lib/test_maple_tree.c:1468:9: sparse:     expected void const *entry
>> >   lib/test_maple_tree.c:1468:9: sparse:     got void [noderef] __rcu *ma_root
>> >
>> >vim +1456 lib/test_maple_tree.c
>> >
>> >  1389	
>> >  1390	static noinline void __init check_store_null(struct maple_tree *mt)
>> >  1391	{
>> >  1392		MA_STATE(mas, mt, 0, ULONG_MAX);
>> >  1393	
>> >  1394		/*
>> >  1395		 * Store NULL at range [0, ULONG_MAX] to an empty tree should result
>> >  1396		 * in an empty tree
>> >  1397		 */
>> >  1398		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>> >  1399		mas_lock(&mas);
>> >  1400		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>> >  1401		MT_BUG_ON(mt, !mtree_empty(mt));
>> >  1402		mas_unlock(&mas);
>> >  1403		mtree_destroy(mt);
>> >  1404	
>> >  1405		/*
>> >  1406		 * Store NULL at any range to an empty tree should result in an empty
>> >  1407		 * tree
>> >  1408		 */
>> >  1409		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>> >  1410		mas_lock(&mas);
>> >  1411		mas_set_range(&mas, 3, 10);
>> >  1412		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>> >  1413		MT_BUG_ON(mt, !mtree_empty(mt));
>> >  1414		mas_unlock(&mas);
>> >  1415		mtree_destroy(mt);
>> >  1416	
>> >  1417		/*
>> >  1418		 * Store NULL at range [0, ULONG_MAX] to a single entry tree should
>> >  1419		 * result in an empty tree
>> >  1420		 */
>> >  1421		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>> >  1422		mas_lock(&mas);
>> >  1423		mas_set(&mas, 0);
>> >  1424		mas_store_gfp(&mas, &mas, GFP_KERNEL);
>> >  1425		mas_set_range(&mas, 0, ULONG_MAX);
>> >  1426		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>> >  1427		MT_BUG_ON(mt, !mtree_empty(mt));
>> >  1428		mas_unlock(&mas);
>> >  1429		mtree_destroy(mt);
>> >  1430	
>> >  1431		/*
>> >  1432		 * Store NULL at range [0, n] to a single entry tree should
>> >  1433		 * result in an empty tree
>> >  1434		 */
>> >  1435		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>> >  1436		mas_lock(&mas);
>> >  1437		mas_set(&mas, 0);
>> >  1438		mas_store_gfp(&mas, &mas, GFP_KERNEL);
>> >  1439		mas_set_range(&mas, 0, 5);
>> >  1440		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>> >  1441		MT_BUG_ON(mt, !mtree_empty(mt));
>> >  1442		mas_unlock(&mas);
>> >  1443		mtree_destroy(mt);
>> >  1444	
>> >  1445		/*
>> >  1446		 * Store NULL at range [m, n] where m > 0 to a single entry tree
>> >  1447		 * should still be a single entry tree
>> >  1448		 */
>> >  1449		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>> >  1450		mas_lock(&mas);
>> >  1451		mas_set(&mas, 0);
>> >  1452		mas_store_gfp(&mas, &mas, GFP_KERNEL);
>> >  1453		mas_set_range(&mas, 2, 5);
>> >  1454		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>> >  1455		MT_BUG_ON(mt, mtree_empty(mt));
>> >> 1456		MT_BUG_ON(mt, xa_is_node(mt->ma_root));
>> 
>> Thanks.
>> 
>> Will fix it to xa_is_node(mas_root(&mas)) in next version.
>
>By the looks of the bot output, there are quite a lot of existing cases
>of this in the test code.
>

Hi, Liam

Thanks for your review. I may not follow you.

I saw you add you RB. Do you prefer me to spin a new round with this adjusted
or the current version is fine?

>> 
>> 
>> >  1457		mas_unlock(&mas);
>> >  1458		mtree_destroy(mt);
>> >  1459	
>> >  1460		/*
>> >  1461		 * Store NULL at range [0, ULONG_MAX] to a tree with node should
>> >  1462		 * result in an empty tree
>> >  1463		 */
>> >  1464		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>> >  1465		mas_lock(&mas);
>> >  1466		mas_set_range(&mas, 1, 3);
>> >  1467		mas_store_gfp(&mas, &mas, GFP_KERNEL);
>> >  1468		MT_BUG_ON(mt, !xa_is_node(mt->ma_root));
>> >  1469		mas_set_range(&mas, 0, ULONG_MAX);
>> >  1470		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>> >  1471		MT_BUG_ON(mt, !mtree_empty(mt));
>> >  1472		mas_unlock(&mas);
>> >  1473		mtree_destroy(mt);
>> >  1474	}
>> >  1475	
>> >
>> >-- 
>> >0-DAY CI Kernel Test Service
>> >https://github.com/intel/lkp-tests/wiki
>> 
>> -- 
>> Wei Yang
>> Help you, Help me

-- 
Wei Yang
Help you, Help me

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 5/5] maple_tree: add a test checking storing null
  2024-10-31  8:02         ` Wei Yang
@ 2024-10-31 11:17           ` Liam R. Howlett
  2024-10-31 23:04             ` Wei Yang
  0 siblings, 1 reply; 19+ messages in thread
From: Liam R. Howlett @ 2024-10-31 11:17 UTC (permalink / raw)
  To: Wei Yang
  Cc: kernel test robot, akpm, oe-kbuild-all, maple-tree, linux-mm,
	Sidhartha Kumar, Lorenzo Stoakes

* Wei Yang <richard.weiyang@gmail.com> [241031 04:02]:
> On Tue, Oct 29, 2024 at 11:29:39AM -0400, Liam R. Howlett wrote:
> >* Wei Yang <richard.weiyang@gmail.com> [241022 19:32]:
> >> On Wed, Oct 23, 2024 at 01:37:50AM +0800, kernel test robot wrote:
> >> >Hi Wei,
> >> >
> >> >kernel test robot noticed the following build warnings:
> >> >
> >> >[auto build test WARNING on akpm-mm/mm-nonmm-unstable]
> >> >[also build test WARNING on akpm-mm/mm-everything linus/master v6.12-rc4 next-20241022]
> >> >[If your patch is applied to the wrong git tree, kindly drop us a note.
> >> >And when submitting patch, we suggest to use '--base' as documented in
> >> >https://git-scm.com/docs/git-format-patch#_base_tree_information]
> >> >
> >> >url:    https://github.com/intel-lab-lkp/linux/commits/Wei-Yang/maple_tree-print-empty-for-an-empty-tree-on-mt_dump/20241019-103832
> >> >base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable
> >> >patch link:    https://lore.kernel.org/r/20241019023716.4516-6-richard.weiyang%40gmail.com
> >> >patch subject: [PATCH v4 5/5] maple_tree: add a test checking storing null
> >> >config: x86_64-randconfig-123-20241022 (https://download.01.org/0day-ci/archive/20241023/202410230105.UApdwd9S-lkp@intel.com/config)
> >> >compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
> >> >reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241023/202410230105.UApdwd9S-lkp@intel.com/reproduce)
> >> >
> >> >If you fix the issue in a separate patch/commit (i.e. not just a new version of
> >> >the same patch/commit), kindly add following tags
> >> >| Reported-by: kernel test robot <lkp@intel.com>
> >> >| Closes: https://lore.kernel.org/oe-kbuild-all/202410230105.UApdwd9S-lkp@intel.com/
> >> >
> >> >sparse warnings: (new ones prefixed by >>)
> >> >>> lib/test_maple_tree.c:1456:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
> >> >   lib/test_maple_tree.c:1456:9: sparse:     expected void const *entry
> >> >   lib/test_maple_tree.c:1456:9: sparse:     got void [noderef] __rcu *ma_root
> >> >>> lib/test_maple_tree.c:1456:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
> >> >   lib/test_maple_tree.c:1456:9: sparse:     expected void const *entry
> >> >   lib/test_maple_tree.c:1456:9: sparse:     got void [noderef] __rcu *ma_root
> >> >   lib/test_maple_tree.c:1468:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
> >> >   lib/test_maple_tree.c:1468:9: sparse:     expected void const *entry
> >> >   lib/test_maple_tree.c:1468:9: sparse:     got void [noderef] __rcu *ma_root
> >> >   lib/test_maple_tree.c:1468:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
> >> >   lib/test_maple_tree.c:1468:9: sparse:     expected void const *entry
> >> >   lib/test_maple_tree.c:1468:9: sparse:     got void [noderef] __rcu *ma_root
> >> >
> >> >vim +1456 lib/test_maple_tree.c
> >> >
> >> >  1389	
> >> >  1390	static noinline void __init check_store_null(struct maple_tree *mt)
> >> >  1391	{
> >> >  1392		MA_STATE(mas, mt, 0, ULONG_MAX);
> >> >  1393	
> >> >  1394		/*
> >> >  1395		 * Store NULL at range [0, ULONG_MAX] to an empty tree should result
> >> >  1396		 * in an empty tree
> >> >  1397		 */
> >> >  1398		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> >> >  1399		mas_lock(&mas);
> >> >  1400		mas_store_gfp(&mas, NULL, GFP_KERNEL);
> >> >  1401		MT_BUG_ON(mt, !mtree_empty(mt));
> >> >  1402		mas_unlock(&mas);
> >> >  1403		mtree_destroy(mt);
> >> >  1404	
> >> >  1405		/*
> >> >  1406		 * Store NULL at any range to an empty tree should result in an empty
> >> >  1407		 * tree
> >> >  1408		 */
> >> >  1409		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> >> >  1410		mas_lock(&mas);
> >> >  1411		mas_set_range(&mas, 3, 10);
> >> >  1412		mas_store_gfp(&mas, NULL, GFP_KERNEL);
> >> >  1413		MT_BUG_ON(mt, !mtree_empty(mt));
> >> >  1414		mas_unlock(&mas);
> >> >  1415		mtree_destroy(mt);
> >> >  1416	
> >> >  1417		/*
> >> >  1418		 * Store NULL at range [0, ULONG_MAX] to a single entry tree should
> >> >  1419		 * result in an empty tree
> >> >  1420		 */
> >> >  1421		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> >> >  1422		mas_lock(&mas);
> >> >  1423		mas_set(&mas, 0);
> >> >  1424		mas_store_gfp(&mas, &mas, GFP_KERNEL);
> >> >  1425		mas_set_range(&mas, 0, ULONG_MAX);
> >> >  1426		mas_store_gfp(&mas, NULL, GFP_KERNEL);
> >> >  1427		MT_BUG_ON(mt, !mtree_empty(mt));
> >> >  1428		mas_unlock(&mas);
> >> >  1429		mtree_destroy(mt);
> >> >  1430	
> >> >  1431		/*
> >> >  1432		 * Store NULL at range [0, n] to a single entry tree should
> >> >  1433		 * result in an empty tree
> >> >  1434		 */
> >> >  1435		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> >> >  1436		mas_lock(&mas);
> >> >  1437		mas_set(&mas, 0);
> >> >  1438		mas_store_gfp(&mas, &mas, GFP_KERNEL);
> >> >  1439		mas_set_range(&mas, 0, 5);
> >> >  1440		mas_store_gfp(&mas, NULL, GFP_KERNEL);
> >> >  1441		MT_BUG_ON(mt, !mtree_empty(mt));
> >> >  1442		mas_unlock(&mas);
> >> >  1443		mtree_destroy(mt);
> >> >  1444	
> >> >  1445		/*
> >> >  1446		 * Store NULL at range [m, n] where m > 0 to a single entry tree
> >> >  1447		 * should still be a single entry tree
> >> >  1448		 */
> >> >  1449		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> >> >  1450		mas_lock(&mas);
> >> >  1451		mas_set(&mas, 0);
> >> >  1452		mas_store_gfp(&mas, &mas, GFP_KERNEL);
> >> >  1453		mas_set_range(&mas, 2, 5);
> >> >  1454		mas_store_gfp(&mas, NULL, GFP_KERNEL);
> >> >  1455		MT_BUG_ON(mt, mtree_empty(mt));
> >> >> 1456		MT_BUG_ON(mt, xa_is_node(mt->ma_root));
> >> 
> >> Thanks.
> >> 
> >> Will fix it to xa_is_node(mas_root(&mas)) in next version.
> >
> >By the looks of the bot output, there are quite a lot of existing cases
> >of this in the test code.
> >
> 
> Hi, Liam
> 
> Thanks for your review. I may not follow you.
> 
> I saw you add you RB. Do you prefer me to spin a new round with this adjusted
> or the current version is fine?

Please fix what you added.  The rest will need to eventually be fixed,
but someone can do that later.

> 
> >> 
> >> 
> >> >  1457		mas_unlock(&mas);
> >> >  1458		mtree_destroy(mt);
> >> >  1459	
> >> >  1460		/*
> >> >  1461		 * Store NULL at range [0, ULONG_MAX] to a tree with node should
> >> >  1462		 * result in an empty tree
> >> >  1463		 */
> >> >  1464		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> >> >  1465		mas_lock(&mas);
> >> >  1466		mas_set_range(&mas, 1, 3);
> >> >  1467		mas_store_gfp(&mas, &mas, GFP_KERNEL);
> >> >  1468		MT_BUG_ON(mt, !xa_is_node(mt->ma_root));
> >> >  1469		mas_set_range(&mas, 0, ULONG_MAX);
> >> >  1470		mas_store_gfp(&mas, NULL, GFP_KERNEL);
> >> >  1471		MT_BUG_ON(mt, !mtree_empty(mt));
> >> >  1472		mas_unlock(&mas);
> >> >  1473		mtree_destroy(mt);
> >> >  1474	}
> >> >  1475	
> >> >
> >> >-- 
> >> >0-DAY CI Kernel Test Service
> >> >https://github.com/intel/lkp-tests/wiki
> >> 
> >> -- 
> >> Wei Yang
> >> Help you, Help me
> 
> -- 
> Wei Yang
> Help you, Help me

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 5/5] maple_tree: add a test checking storing null
  2024-10-31 11:17           ` Liam R. Howlett
@ 2024-10-31 23:04             ` Wei Yang
  0 siblings, 0 replies; 19+ messages in thread
From: Wei Yang @ 2024-10-31 23:04 UTC (permalink / raw)
  To: Liam R. Howlett, Wei Yang, kernel test robot, akpm, oe-kbuild-all,
	maple-tree, linux-mm, Sidhartha Kumar, Lorenzo Stoakes

On Thu, Oct 31, 2024 at 07:17:28AM -0400, Liam R. Howlett wrote:
>* Wei Yang <richard.weiyang@gmail.com> [241031 04:02]:
>> On Tue, Oct 29, 2024 at 11:29:39AM -0400, Liam R. Howlett wrote:
>> >* Wei Yang <richard.weiyang@gmail.com> [241022 19:32]:
>> >> On Wed, Oct 23, 2024 at 01:37:50AM +0800, kernel test robot wrote:
>> >> >Hi Wei,
>> >> >
>> >> >kernel test robot noticed the following build warnings:
>> >> >
>> >> >[auto build test WARNING on akpm-mm/mm-nonmm-unstable]
>> >> >[also build test WARNING on akpm-mm/mm-everything linus/master v6.12-rc4 next-20241022]
>> >> >[If your patch is applied to the wrong git tree, kindly drop us a note.
>> >> >And when submitting patch, we suggest to use '--base' as documented in
>> >> >https://git-scm.com/docs/git-format-patch#_base_tree_information]
>> >> >
>> >> >url:    https://github.com/intel-lab-lkp/linux/commits/Wei-Yang/maple_tree-print-empty-for-an-empty-tree-on-mt_dump/20241019-103832
>> >> >base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable
>> >> >patch link:    https://lore.kernel.org/r/20241019023716.4516-6-richard.weiyang%40gmail.com
>> >> >patch subject: [PATCH v4 5/5] maple_tree: add a test checking storing null
>> >> >config: x86_64-randconfig-123-20241022 (https://download.01.org/0day-ci/archive/20241023/202410230105.UApdwd9S-lkp@intel.com/config)
>> >> >compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
>> >> >reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241023/202410230105.UApdwd9S-lkp@intel.com/reproduce)
>> >> >
>> >> >If you fix the issue in a separate patch/commit (i.e. not just a new version of
>> >> >the same patch/commit), kindly add following tags
>> >> >| Reported-by: kernel test robot <lkp@intel.com>
>> >> >| Closes: https://lore.kernel.org/oe-kbuild-all/202410230105.UApdwd9S-lkp@intel.com/
>> >> >
>> >> >sparse warnings: (new ones prefixed by >>)
>> >> >>> lib/test_maple_tree.c:1456:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
>> >> >   lib/test_maple_tree.c:1456:9: sparse:     expected void const *entry
>> >> >   lib/test_maple_tree.c:1456:9: sparse:     got void [noderef] __rcu *ma_root
>> >> >>> lib/test_maple_tree.c:1456:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
>> >> >   lib/test_maple_tree.c:1456:9: sparse:     expected void const *entry
>> >> >   lib/test_maple_tree.c:1456:9: sparse:     got void [noderef] __rcu *ma_root
>> >> >   lib/test_maple_tree.c:1468:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
>> >> >   lib/test_maple_tree.c:1468:9: sparse:     expected void const *entry
>> >> >   lib/test_maple_tree.c:1468:9: sparse:     got void [noderef] __rcu *ma_root
>> >> >   lib/test_maple_tree.c:1468:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *entry @@     got void [noderef] __rcu *ma_root @@
>> >> >   lib/test_maple_tree.c:1468:9: sparse:     expected void const *entry
>> >> >   lib/test_maple_tree.c:1468:9: sparse:     got void [noderef] __rcu *ma_root
>> >> >
>> >> >vim +1456 lib/test_maple_tree.c
>> >> >
>> >> >  1389	
>> >> >  1390	static noinline void __init check_store_null(struct maple_tree *mt)
>> >> >  1391	{
>> >> >  1392		MA_STATE(mas, mt, 0, ULONG_MAX);
>> >> >  1393	
>> >> >  1394		/*
>> >> >  1395		 * Store NULL at range [0, ULONG_MAX] to an empty tree should result
>> >> >  1396		 * in an empty tree
>> >> >  1397		 */
>> >> >  1398		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>> >> >  1399		mas_lock(&mas);
>> >> >  1400		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>> >> >  1401		MT_BUG_ON(mt, !mtree_empty(mt));
>> >> >  1402		mas_unlock(&mas);
>> >> >  1403		mtree_destroy(mt);
>> >> >  1404	
>> >> >  1405		/*
>> >> >  1406		 * Store NULL at any range to an empty tree should result in an empty
>> >> >  1407		 * tree
>> >> >  1408		 */
>> >> >  1409		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>> >> >  1410		mas_lock(&mas);
>> >> >  1411		mas_set_range(&mas, 3, 10);
>> >> >  1412		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>> >> >  1413		MT_BUG_ON(mt, !mtree_empty(mt));
>> >> >  1414		mas_unlock(&mas);
>> >> >  1415		mtree_destroy(mt);
>> >> >  1416	
>> >> >  1417		/*
>> >> >  1418		 * Store NULL at range [0, ULONG_MAX] to a single entry tree should
>> >> >  1419		 * result in an empty tree
>> >> >  1420		 */
>> >> >  1421		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>> >> >  1422		mas_lock(&mas);
>> >> >  1423		mas_set(&mas, 0);
>> >> >  1424		mas_store_gfp(&mas, &mas, GFP_KERNEL);
>> >> >  1425		mas_set_range(&mas, 0, ULONG_MAX);
>> >> >  1426		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>> >> >  1427		MT_BUG_ON(mt, !mtree_empty(mt));
>> >> >  1428		mas_unlock(&mas);
>> >> >  1429		mtree_destroy(mt);
>> >> >  1430	
>> >> >  1431		/*
>> >> >  1432		 * Store NULL at range [0, n] to a single entry tree should
>> >> >  1433		 * result in an empty tree
>> >> >  1434		 */
>> >> >  1435		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>> >> >  1436		mas_lock(&mas);
>> >> >  1437		mas_set(&mas, 0);
>> >> >  1438		mas_store_gfp(&mas, &mas, GFP_KERNEL);
>> >> >  1439		mas_set_range(&mas, 0, 5);
>> >> >  1440		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>> >> >  1441		MT_BUG_ON(mt, !mtree_empty(mt));
>> >> >  1442		mas_unlock(&mas);
>> >> >  1443		mtree_destroy(mt);
>> >> >  1444	
>> >> >  1445		/*
>> >> >  1446		 * Store NULL at range [m, n] where m > 0 to a single entry tree
>> >> >  1447		 * should still be a single entry tree
>> >> >  1448		 */
>> >> >  1449		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>> >> >  1450		mas_lock(&mas);
>> >> >  1451		mas_set(&mas, 0);
>> >> >  1452		mas_store_gfp(&mas, &mas, GFP_KERNEL);
>> >> >  1453		mas_set_range(&mas, 2, 5);
>> >> >  1454		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>> >> >  1455		MT_BUG_ON(mt, mtree_empty(mt));
>> >> >> 1456		MT_BUG_ON(mt, xa_is_node(mt->ma_root));
>> >> 
>> >> Thanks.
>> >> 
>> >> Will fix it to xa_is_node(mas_root(&mas)) in next version.
>> >
>> >By the looks of the bot output, there are quite a lot of existing cases
>> >of this in the test code.
>> >
>> 
>> Hi, Liam
>> 
>> Thanks for your review. I may not follow you.
>> 
>> I saw you add you RB. Do you prefer me to spin a new round with this adjusted
>> or the current version is fine?
>
>Please fix what you added.  The rest will need to eventually be fixed,
>but someone can do that later.
>

Got it, thanks.

>> 
>> >> 
>> >> 
>> >> >  1457		mas_unlock(&mas);
>> >> >  1458		mtree_destroy(mt);
>> >> >  1459	
>> >> >  1460		/*
>> >> >  1461		 * Store NULL at range [0, ULONG_MAX] to a tree with node should
>> >> >  1462		 * result in an empty tree
>> >> >  1463		 */
>> >> >  1464		mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
>> >> >  1465		mas_lock(&mas);
>> >> >  1466		mas_set_range(&mas, 1, 3);
>> >> >  1467		mas_store_gfp(&mas, &mas, GFP_KERNEL);
>> >> >  1468		MT_BUG_ON(mt, !xa_is_node(mt->ma_root));
>> >> >  1469		mas_set_range(&mas, 0, ULONG_MAX);
>> >> >  1470		mas_store_gfp(&mas, NULL, GFP_KERNEL);
>> >> >  1471		MT_BUG_ON(mt, !mtree_empty(mt));
>> >> >  1472		mas_unlock(&mas);
>> >> >  1473		mtree_destroy(mt);
>> >> >  1474	}
>> >> >  1475	
>> >> >
>> >> >-- 
>> >> >0-DAY CI Kernel Test Service
>> >> >https://github.com/intel/lkp-tests/wiki
>> >> 
>> >> -- 
>> >> Wei Yang
>> >> Help you, Help me
>> 
>> -- 
>> Wei Yang
>> Help you, Help me

-- 
Wei Yang
Help you, Help me

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2024-10-31 23:04 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-19  2:37 [PATCH v4 0/5] refine storing NULL Wei Yang
2024-10-19  2:37 ` [PATCH v4 1/5] maple_tree: print empty for an empty tree on mt_dump() Wei Yang
2024-10-29 15:23   ` Liam R. Howlett
2024-10-19  2:37 ` [PATCH v4 2/5] maple_tree: the return value of mas_root_expand() is not used Wei Yang
2024-10-29 15:23   ` Liam R. Howlett
2024-10-19  2:37 ` [PATCH v4 3/5] maple_tree: not necessary to check index/last again Wei Yang
2024-10-29 15:23   ` Liam R. Howlett
2024-10-19  2:37 ` [PATCH v4 4/5] maple_tree: refine mas_store_root() on storing NULL Wei Yang
2024-10-29 15:24   ` Liam R. Howlett
2024-10-19  2:37 ` [PATCH v4 5/5] maple_tree: add a test checking storing null Wei Yang
2024-10-22 17:37   ` kernel test robot
2024-10-22 23:32     ` Wei Yang
2024-10-29 15:29       ` Liam R. Howlett
2024-10-31  8:02         ` Wei Yang
2024-10-31 11:17           ` Liam R. Howlett
2024-10-31 23:04             ` Wei Yang
2024-10-29 15:17   ` Liam R. Howlett
2024-10-29 15:22     ` Liam R. Howlett
2024-10-19  2:42 ` [PATCH v4 0/5] refine storing NULL Wei Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.