refine storing NULL
Subsystems (3)
v4 cover refine storing NULL
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/[email protected]
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(-)
Signature · 1 line
2.34.1
PATCH v4 1/5 maple_tree: print empty for an empty tree on mt_dump()
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.
--- lib/maple_tree.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
lib/maple_tree.c +5 -3
@@ -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);
Signature · 1 line
2.34.1
Re: [PATCH v4 1/5] maple_tree: print empty for an empty tree on mt_dump()
Quoted 5 lines · Wei Yang
Currently for an empty tree, it would print:
maple_tree(0x7ffcd02c6ee0)flags 1, height 0 root (nil) 0: (nil)
Quoted 8 lines
This is a little misleading.
Let's print (empty) for an empty tree.
Signed-off-by Wei Yang <[email protected]>CC Liam R. Howlett <[email protected]>CC Sidhartha Kumar <[email protected]>CC Lorenzo Stoakes <[email protected]>
Quoted 27 lines
--- lib/maple_tree.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)lib/maple_tree.c +5
-3@@ -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);Signature · 1 line
2.34.1
PATCH v4 2/5 maple_tree: the return value of mas_root_expand() is not used
In reply to Wei YangNo user of the return value now, just remove it.
--- lib/maple_tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/maple_tree.c +2 -2
@@ -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)
Signature · 1 line
2.34.1
Re: [PATCH v4 2/5] maple_tree: the return value of mas_root_expand() is not used
Quoted 6 lines · Wei Yang
No user of the return value now, just remove it.
Signed-off-by Wei Yang <[email protected]>CC Liam R. Howlett <[email protected]>CC Sidhartha Kumar <[email protected]>CC Lorenzo Stoakes <[email protected]>
Quoted 29 lines
--- lib/maple_tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/maple_tree.c +2
-2@@ -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)Signature · 1 line
2.34.1
PATCH v4 3/5 maple_tree: not necessary to check index/last again
In reply to Wei YangBefore calling mas_new_root(), the range has been checked.
---
v4: add WARN_ON_ONCE() to check mis-usage.
--- lib/maple_tree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/maple_tree.c +3 -1
@@ -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);
Signature · 1 line
2.34.1
Re: [PATCH v4 3/5] maple_tree: not necessary to check index/last again
Quoted 7 lines · Wei Yang
Before calling
mas_new_root(), the range has been checked.Signed-off-by Wei Yang <[email protected]>CC Liam R. Howlett <[email protected]>CC Sidhartha Kumar <[email protected]>CC Lorenzo Stoakes <[email protected]>
Quoted 24 lines
---
v4: addWARN_ON_ONCE()to check mis-usage.--- lib/maple_tree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)lib/maple_tree.c +3
-1@@ -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);Signature · 1 line
2.34.1
PATCH v4 4/5 maple_tree: refine mas_store_root() on storing NULL
In reply to Wei YangCurrently, 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
---
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(-)
lib/maple_tree.c +12 -1
@@ -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);
Signature · 1 line
2.34.1
Re: [PATCH v4 4/5] maple_tree: refine mas_store_root() on storing NULL
Quoted 15 lines · Wei Yang
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 treeThis patch tries to improve in:
Quoted 8 lines
* 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 operationSigned-off-by Wei Yang <[email protected]>CC Liam R. Howlett <[email protected]>CC Sidhartha Kumar <[email protected]>CC Lorenzo Stoakes <[email protected]>
Quoted 38 lines
---
v3: move change intomas_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(-)lib/maple_tree.c +12
-1@@ -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);Signature · 1 line
2.34.1
PATCH v4 5/5 maple_tree: add a test checking storing null
In reply to Wei YangAdd 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
---
v3: move test into lib/test_maple_tree.c
--- lib/test_maple_tree.c | 90 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+)
lib/test_maple_tree.c +90 -0
@@ -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);
Signature · 1 line
2.34.1
kernel test robot
build botRe: [PATCH v4 5/5] maple_tree: add a test checking storing null
kernel test robot noticed the following build warnings:
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/[email protected]/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/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
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
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v4 5/5] maple_tree: add a test checking storing null
Quoted 98 lines · kernel test robot
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/[email protected]/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/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/sparse warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
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_rootQuoted 1 line
Quoted 1 line
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_rootvim +1456
lib/test_maple_tree.c1389
1390 static noinline void__initcheck_store_null(struct maple_tree *mt)
1391 {
1392MA_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 */
1398mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1399mas_lock(&mas);
1400mas_store_gfp(&mas, NULL, GFP_KERNEL);
1401MT_BUG_ON(mt, !mtree_empty(mt));
1402mas_unlock(&mas);
1403mtree_destroy(mt);
1404
1405 /*
1406 * Store NULL at any range to an empty tree should result in an empty
1407 * tree
1408 */
1409mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1410mas_lock(&mas);
1411mas_set_range(&mas, 3, 10);
1412mas_store_gfp(&mas, NULL, GFP_KERNEL);
1413MT_BUG_ON(mt, !mtree_empty(mt));
1414mas_unlock(&mas);
1415mtree_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 */
1421mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1422mas_lock(&mas);
1423mas_set(&mas, 0);
1424mas_store_gfp(&mas, &mas, GFP_KERNEL);
1425mas_set_range(&mas, 0, ULONG_MAX);
1426mas_store_gfp(&mas, NULL, GFP_KERNEL);
1427MT_BUG_ON(mt, !mtree_empty(mt));
1428mas_unlock(&mas);
1429mtree_destroy(mt);
1430
1431 /*
1432 * Store NULL at range [0, n] to a single entry tree should
1433 * result in an empty tree
1434 */
1435mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1436mas_lock(&mas);
1437mas_set(&mas, 0);
1438mas_store_gfp(&mas, &mas, GFP_KERNEL);
1439mas_set_range(&mas, 0, 5);
1440mas_store_gfp(&mas, NULL, GFP_KERNEL);
1441MT_BUG_ON(mt, !mtree_empty(mt));
1442mas_unlock(&mas);
1443mtree_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
Quoted 9 lines
1448 */
1449mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1450mas_lock(&mas);
1451mas_set(&mas, 0);
1452mas_store_gfp(&mas, &mas, GFP_KERNEL);
1453mas_set_range(&mas, 2, 5);
1454mas_store_gfp(&mas, NULL, GFP_KERNEL);
1455MT_BUG_ON(mt, mtree_empty(mt));Quoted 1 line
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.
Quoted 23 lines
1457
mas_unlock(&mas);
1458mtree_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 */
1464mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1465mas_lock(&mas);
1466mas_set_range(&mas, 1, 3);
1467mas_store_gfp(&mas, &mas, GFP_KERNEL);
1468MT_BUG_ON(mt, !xa_is_node(mt->ma_root));
1469mas_set_range(&mas, 0, ULONG_MAX);
1470mas_store_gfp(&mas, NULL, GFP_KERNEL);
1471MT_BUG_ON(mt, !mtree_empty(mt));
1472mas_unlock(&mas);
1473mtree_destroy(mt);
1474 }
1475Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Signature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH v4 5/5] maple_tree: add a test checking storing null
Quoted 107 lines · Wei Yang
Quoted 106 lines · kernel test robot
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/[email protected]/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/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/sparse warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
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_rootQuoted 1 line
Quoted 1 line
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_rootvim +1456
lib/test_maple_tree.c1389
1390 static noinline void__initcheck_store_null(struct maple_tree *mt)
1391 {
1392MA_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 */
1398mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1399mas_lock(&mas);
1400mas_store_gfp(&mas, NULL, GFP_KERNEL);
1401MT_BUG_ON(mt, !mtree_empty(mt));
1402mas_unlock(&mas);
1403mtree_destroy(mt);
1404
1405 /*
1406 * Store NULL at any range to an empty tree should result in an empty
1407 * tree
1408 */
1409mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1410mas_lock(&mas);
1411mas_set_range(&mas, 3, 10);
1412mas_store_gfp(&mas, NULL, GFP_KERNEL);
1413MT_BUG_ON(mt, !mtree_empty(mt));
1414mas_unlock(&mas);
1415mtree_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 */
1421mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1422mas_lock(&mas);
1423mas_set(&mas, 0);
1424mas_store_gfp(&mas, &mas, GFP_KERNEL);
1425mas_set_range(&mas, 0, ULONG_MAX);
1426mas_store_gfp(&mas, NULL, GFP_KERNEL);
1427MT_BUG_ON(mt, !mtree_empty(mt));
1428mas_unlock(&mas);
1429mtree_destroy(mt);
1430
1431 /*
1432 * Store NULL at range [0, n] to a single entry tree should
1433 * result in an empty tree
1434 */
1435mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1436mas_lock(&mas);
1437mas_set(&mas, 0);
1438mas_store_gfp(&mas, &mas, GFP_KERNEL);
1439mas_set_range(&mas, 0, 5);
1440mas_store_gfp(&mas, NULL, GFP_KERNEL);
1441MT_BUG_ON(mt, !mtree_empty(mt));
1442mas_unlock(&mas);
1443mtree_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 */
1449mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1450mas_lock(&mas);
1451mas_set(&mas, 0);
1452mas_store_gfp(&mas, &mas, GFP_KERNEL);
1453mas_set_range(&mas, 2, 5);
1454mas_store_gfp(&mas, NULL, GFP_KERNEL);
1455MT_BUG_ON(mt, mtree_empty(mt));
Quoted 5 lines
Quoted 1 line
Quoted 1 line
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.
Quoted 29 lines
Quoted 25 lines
1457
mas_unlock(&mas);
1458mtree_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 */
1464mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1465mas_lock(&mas);
1466mas_set_range(&mas, 1, 3);
1467mas_store_gfp(&mas, &mas, GFP_KERNEL);
1468MT_BUG_ON(mt, !xa_is_node(mt->ma_root));
1469mas_set_range(&mas, 0, ULONG_MAX);
1470mas_store_gfp(&mas, NULL, GFP_KERNEL);
1471MT_BUG_ON(mt, !mtree_empty(mt));
1472mas_unlock(&mas);
1473mtree_destroy(mt);
1474 }
1475Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wikiSignature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH v4 5/5] maple_tree: add a test checking storing null
Quoted 108 lines · Liam R. Howlett
Quoted 107 lines · Wei Yang
Quoted 106 lines · kernel test robot
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/[email protected]/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/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/sparse warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
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_rootQuoted 1 line
Quoted 1 line
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_rootvim +1456
lib/test_maple_tree.c1389
1390 static noinline void__initcheck_store_null(struct maple_tree *mt)
1391 {
1392MA_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 */
1398mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1399mas_lock(&mas);
1400mas_store_gfp(&mas, NULL, GFP_KERNEL);
1401MT_BUG_ON(mt, !mtree_empty(mt));
1402mas_unlock(&mas);
1403mtree_destroy(mt);
1404
1405 /*
1406 * Store NULL at any range to an empty tree should result in an empty
1407 * tree
1408 */
1409mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1410mas_lock(&mas);
1411mas_set_range(&mas, 3, 10);
1412mas_store_gfp(&mas, NULL, GFP_KERNEL);
1413MT_BUG_ON(mt, !mtree_empty(mt));
1414mas_unlock(&mas);
1415mtree_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 */
1421mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1422mas_lock(&mas);
1423mas_set(&mas, 0);
1424mas_store_gfp(&mas, &mas, GFP_KERNEL);
1425mas_set_range(&mas, 0, ULONG_MAX);
1426mas_store_gfp(&mas, NULL, GFP_KERNEL);
1427MT_BUG_ON(mt, !mtree_empty(mt));
1428mas_unlock(&mas);
1429mtree_destroy(mt);
1430
1431 /*
1432 * Store NULL at range [0, n] to a single entry tree should
1433 * result in an empty tree
1434 */
1435mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1436mas_lock(&mas);
1437mas_set(&mas, 0);
1438mas_store_gfp(&mas, &mas, GFP_KERNEL);
1439mas_set_range(&mas, 0, 5);
1440mas_store_gfp(&mas, NULL, GFP_KERNEL);
1441MT_BUG_ON(mt, !mtree_empty(mt));
1442mas_unlock(&mas);
1443mtree_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 */
1449mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1450mas_lock(&mas);
1451mas_set(&mas, 0);
1452mas_store_gfp(&mas, &mas, GFP_KERNEL);
1453mas_set_range(&mas, 2, 5);
1454mas_store_gfp(&mas, NULL, GFP_KERNEL);
1455MT_BUG_ON(mt, mtree_empty(mt));
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
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?
Quoted 29 lines
Quoted 29 lines
Quoted 25 lines
1457
mas_unlock(&mas);
1458mtree_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 */
1464mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1465mas_lock(&mas);
1466mas_set_range(&mas, 1, 3);
1467mas_store_gfp(&mas, &mas, GFP_KERNEL);
1468MT_BUG_ON(mt, !xa_is_node(mt->ma_root));
1469mas_set_range(&mas, 0, ULONG_MAX);
1470mas_store_gfp(&mas, NULL, GFP_KERNEL);
1471MT_BUG_ON(mt, !mtree_empty(mt));
1472mas_unlock(&mas);
1473mtree_destroy(mt);
1474 }
1475Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wikiSignature · 2 lines
Wei Yang Help you, Help me
Signature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH v4 5/5] maple_tree: add a test checking storing null
Quoted 119 lines · Wei Yang
Quoted 108 lines · Liam R. Howlett
Quoted 107 lines · Wei Yang
Quoted 106 lines · kernel test robot
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/[email protected]/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/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/sparse warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
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_rootQuoted 1 line
Quoted 1 line
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_rootvim +1456
lib/test_maple_tree.c1389
1390 static noinline void__initcheck_store_null(struct maple_tree *mt)
1391 {
1392MA_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 */
1398mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1399mas_lock(&mas);
1400mas_store_gfp(&mas, NULL, GFP_KERNEL);
1401MT_BUG_ON(mt, !mtree_empty(mt));
1402mas_unlock(&mas);
1403mtree_destroy(mt);
1404
1405 /*
1406 * Store NULL at any range to an empty tree should result in an empty
1407 * tree
1408 */
1409mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1410mas_lock(&mas);
1411mas_set_range(&mas, 3, 10);
1412mas_store_gfp(&mas, NULL, GFP_KERNEL);
1413MT_BUG_ON(mt, !mtree_empty(mt));
1414mas_unlock(&mas);
1415mtree_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 */
1421mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1422mas_lock(&mas);
1423mas_set(&mas, 0);
1424mas_store_gfp(&mas, &mas, GFP_KERNEL);
1425mas_set_range(&mas, 0, ULONG_MAX);
1426mas_store_gfp(&mas, NULL, GFP_KERNEL);
1427MT_BUG_ON(mt, !mtree_empty(mt));
1428mas_unlock(&mas);
1429mtree_destroy(mt);
1430
1431 /*
1432 * Store NULL at range [0, n] to a single entry tree should
1433 * result in an empty tree
1434 */
1435mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1436mas_lock(&mas);
1437mas_set(&mas, 0);
1438mas_store_gfp(&mas, &mas, GFP_KERNEL);
1439mas_set_range(&mas, 0, 5);
1440mas_store_gfp(&mas, NULL, GFP_KERNEL);
1441MT_BUG_ON(mt, !mtree_empty(mt));
1442mas_unlock(&mas);
1443mtree_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 */
1449mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1450mas_lock(&mas);
1451mas_set(&mas, 0);
1452mas_store_gfp(&mas, &mas, GFP_KERNEL);
1453mas_set_range(&mas, 2, 5);
1454mas_store_gfp(&mas, NULL, GFP_KERNEL);
1455MT_BUG_ON(mt, mtree_empty(mt));Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
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.
Quoted 6 lines
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.
Quoted 34 lines
Quoted 30 lines
Quoted 30 lines
Quoted 26 lines
1457
mas_unlock(&mas);
1458mtree_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 */
1464mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1465mas_lock(&mas);
1466mas_set_range(&mas, 1, 3);
1467mas_store_gfp(&mas, &mas, GFP_KERNEL);
1468MT_BUG_ON(mt, !xa_is_node(mt->ma_root));
1469mas_set_range(&mas, 0, ULONG_MAX);
1470mas_store_gfp(&mas, NULL, GFP_KERNEL);
1471MT_BUG_ON(mt, !mtree_empty(mt));
1472mas_unlock(&mas);
1473mtree_destroy(mt);
1474 }
1475Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wikiSignature · 2 lines
Wei Yang Help you, Help meSignature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH v4 5/5] maple_tree: add a test checking storing null
Quoted 122 lines · Liam R. Howlett
Quoted 121 lines · Wei Yang
Quoted 108 lines · Liam R. Howlett
Quoted 107 lines · Wei Yang
Quoted 106 lines · kernel test robot
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/[email protected]/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/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/sparse warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
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_rootQuoted 1 line
Quoted 1 line
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_rootvim +1456
lib/test_maple_tree.c1389
1390 static noinline void__initcheck_store_null(struct maple_tree *mt)
1391 {
1392MA_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 */
1398mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1399mas_lock(&mas);
1400mas_store_gfp(&mas, NULL, GFP_KERNEL);
1401MT_BUG_ON(mt, !mtree_empty(mt));
1402mas_unlock(&mas);
1403mtree_destroy(mt);
1404
1405 /*
1406 * Store NULL at any range to an empty tree should result in an empty
1407 * tree
1408 */
1409mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1410mas_lock(&mas);
1411mas_set_range(&mas, 3, 10);
1412mas_store_gfp(&mas, NULL, GFP_KERNEL);
1413MT_BUG_ON(mt, !mtree_empty(mt));
1414mas_unlock(&mas);
1415mtree_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 */
1421mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1422mas_lock(&mas);
1423mas_set(&mas, 0);
1424mas_store_gfp(&mas, &mas, GFP_KERNEL);
1425mas_set_range(&mas, 0, ULONG_MAX);
1426mas_store_gfp(&mas, NULL, GFP_KERNEL);
1427MT_BUG_ON(mt, !mtree_empty(mt));
1428mas_unlock(&mas);
1429mtree_destroy(mt);
1430
1431 /*
1432 * Store NULL at range [0, n] to a single entry tree should
1433 * result in an empty tree
1434 */
1435mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1436mas_lock(&mas);
1437mas_set(&mas, 0);
1438mas_store_gfp(&mas, &mas, GFP_KERNEL);
1439mas_set_range(&mas, 0, 5);
1440mas_store_gfp(&mas, NULL, GFP_KERNEL);
1441MT_BUG_ON(mt, !mtree_empty(mt));
1442mas_unlock(&mas);
1443mtree_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 */
1449mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1450mas_lock(&mas);
1451mas_set(&mas, 0);
1452mas_store_gfp(&mas, &mas, GFP_KERNEL);
1453mas_set_range(&mas, 2, 5);
1454mas_store_gfp(&mas, NULL, GFP_KERNEL);
1455MT_BUG_ON(mt, mtree_empty(mt));Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
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
Quoted 8 lines
Quoted 4 lines
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.
Quoted 34 lines
Quoted 34 lines
Quoted 30 lines
Quoted 30 lines
Quoted 26 lines
1457
mas_unlock(&mas);
1458mtree_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 */
1464mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
1465mas_lock(&mas);
1466mas_set_range(&mas, 1, 3);
1467mas_store_gfp(&mas, &mas, GFP_KERNEL);
1468MT_BUG_ON(mt, !xa_is_node(mt->ma_root));
1469mas_set_range(&mas, 0, ULONG_MAX);
1470mas_store_gfp(&mas, NULL, GFP_KERNEL);
1471MT_BUG_ON(mt, !mtree_empty(mt));
1472mas_unlock(&mas);
1473mtree_destroy(mt);
1474 }
1475Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wikiSignature · 2 lines
Wei Yang Help you, Help meSignature · 2 lines
Wei Yang Help you, Help me
Signature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH v4 5/5] maple_tree: add a test checking storing null
In reply to Wei YangQuoted 10 lines · Wei Yang
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 NULLSigned-off-by Wei Yang <[email protected]>CC Liam R. Howlett <[email protected]>CC Sidhartha Kumar <[email protected]>CC Lorenzo Stoakes <[email protected]>
This patch doesn't apply to the tag you specified or I'm using the wrong git id. I tried git id e993457df.
Quoted 118 lines
---
v3: move test intolib/test_maple_tree.c--- lib/test_maple_tree.c | 90 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+)lib/test_maple_tree.c +90
-0@@ -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);Signature · 1 line
2.34.1
Liam R. Howlett
Reviewed-byRe: [PATCH v4 5/5] maple_tree: add a test checking storing null
Quoted 7 lines · Liam R. Howlett
Quoted 6 lines · Wei Yang
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
Quoted 7 lines
Quoted 4 lines
Signed-off-by Wei Yang <[email protected]>CC Liam R. Howlett <[email protected]>CC Sidhartha Kumar <[email protected]>CC Lorenzo Stoakes <[email protected]>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.
Quoted 11 lines · 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.
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
Quoted 24 lines
[1]: https://lkml.kernel.org/r/[email protected]
v4:
patch 3 add aWARN_ON_ONCE()
patch 4 add a comment and simplify the logic a littlev3:
patch 4 move the change intomas_store_root()
patch 5 move test intolib/test_maple_tree.cWei Yang (5):
maple_tree: print empty for an empty tree onmt_dump()
maple_tree: the return value ofmas_root_expand()is not used
maple_tree: not necessary to check index/last again
maple_tree: refinemas_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(-)Signature · 1 line
2.34.1
Signature · 2 lines
Wei Yang Help you, Help me