All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] align maple tree write paths
@ 2023-10-09 20:16 Sidhartha Kumar
  2023-10-09 20:16 ` [PATCH 1/3] maple_tree: introduce mas_prealloc_calc() Sidhartha Kumar
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Sidhartha Kumar @ 2023-10-09 20:16 UTC (permalink / raw)
  To: linux-kernel, linux-mm, maple-tree
  Cc: akpm, willy, liam.howlett, zhangpeng.00, Sidhartha Kumar

This series modifies the store paths in mas_store_gfp() and mas_erase() to
use the newly refined preallocation calculation before their calls to 
mas_wr_store_entry(). This will avoid having to do worst case calculations.

Patch 1 abstracts the calculation outside of mas_preallocate() so it can
be used externally.

Patch 2 modifies the write path in mas_store_gfp() to use preallocations
and patch 3 does this in mas_erase().

The motivation for this series is part of the Maple Tree work list[1].


========== TESTING ==============
Testing was done with the maple tree test suite.
maple_tree: 570172962 of 570172962 tests passed

rebased on mm-unstable 10/09/23

[1]: https://lore.kernel.org/linux-mm/20230912172845.o54szwf33hc6p7ee@revolver/T/

Sidhartha Kumar (3):
  maple_tree: introduce mas_prealloc_calc()
  maple_tree: use preallocations in mas_store_gfp()
  maple_tree: use preallocations in mas_erase()

 lib/maple_tree.c | 128 ++++++++++++++++++++++++++++++++---------------
 1 file changed, 88 insertions(+), 40 deletions(-)

-- 
2.41.0


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

* [PATCH 1/3] maple_tree: introduce mas_prealloc_calc()
  2023-10-09 20:16 [PATCH 0/3] align maple tree write paths Sidhartha Kumar
@ 2023-10-09 20:16 ` Sidhartha Kumar
  2023-10-09 22:25   ` kernel test robot
                     ` (2 more replies)
  2023-10-09 20:16 ` [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp() Sidhartha Kumar
  2023-10-09 20:16 ` [PATCH 3/3] maple_tree: use preallocations in mas_erase() Sidhartha Kumar
  2 siblings, 3 replies; 17+ messages in thread
From: Sidhartha Kumar @ 2023-10-09 20:16 UTC (permalink / raw)
  To: linux-kernel, linux-mm, maple-tree
  Cc: akpm, willy, liam.howlett, zhangpeng.00, Sidhartha Kumar

Abstract the calculation used to determine the number of nodes needed for
a store operation into a separate function: mas_prealloc_calc().

Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
 lib/maple_tree.c | 85 ++++++++++++++++++++++++++++--------------------
 1 file changed, 50 insertions(+), 35 deletions(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 0e00a84e8e8f..e239197a57fc 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -5418,6 +5418,54 @@ void *mas_store(struct ma_state *mas, void *entry)
 }
 EXPORT_SYMBOL_GPL(mas_store);
 
+/**
+ * mas_prealloc_calc() - Calculate number of nodes needed for a
+ * store operation.
+ * @wr_mas: The maple write state
+ *
+ * Return: Number of nodes required for preallocation.
+ */
+int mas_prealloc_calc(struct ma_wr_state *wr_mas)
+{
+	struct ma_state *mas = wr_mas->mas;
+	unsigned char node_size;
+
+	if (unlikely(!mas->index && mas->last == ULONG_MAX))
+		return 1;
+
+	/* Root expand */
+	if (unlikely(mas_is_none(mas) || mas_is_ptr(mas)))
+		return 1;
+
+	if (unlikely(!mas_wr_walk(wr_mas))) {
+		/* Spanning store, use worst case for now */
+		return 1 + mas_mt_height(mas) * 3;
+	}
+
+	/* At this point, we are at the leaf node that needs to be altered. */
+	/* Exact fit, no nodes needed. */
+	if (wr_mas->r_min == mas->index && wr_mas->r_max == mas->last)
+		return 0;
+
+	mas_wr_end_piv(wr_mas);
+	node_size = mas_wr_new_end(wr_mas);
+	if (node_size >= mt_slots[wr_mas->type]) {
+		/* Split, worst case for now. */
+		return 1 + mas_mt_height(mas) * 2;
+	}
+
+	/* New root needs a singe node */
+	if (unlikely(mte_is_root(mas->node)))
+		return 1;
+
+	/* Potential spanning rebalance collapsing a node, use worst-case */
+	if (node_size  - 1 <= mt_min_slots[wr_mas->type])
+		return mas_mt_height(mas) * 2 - 1;
+
+	/* node store, slot store needs one node */
+	return 1;
+}
+
 /**
  * mas_store_gfp() - Store a value into the tree.
  * @mas: The maple state
@@ -5474,49 +5522,16 @@ EXPORT_SYMBOL_GPL(mas_store_prealloc);
 int mas_preallocate(struct ma_state *mas, void *entry, gfp_t gfp)
 {
 	MA_WR_STATE(wr_mas, mas, entry);
-	unsigned char node_size;
 	int request = 1;
 	int ret;
 
-
-	if (unlikely(!mas->index && mas->last == ULONG_MAX))
-		goto ask_now;
-
 	mas_wr_store_setup(&wr_mas);
 	wr_mas.content = mas_start(mas);
-	/* Root expand */
-	if (unlikely(mas_is_none(mas) || mas_is_ptr(mas)))
-		goto ask_now;
 
-	if (unlikely(!mas_wr_walk(&wr_mas))) {
-		/* Spanning store, use worst case for now */
-		request = 1 + mas_mt_height(mas) * 3;
-		goto ask_now;
-	}
-
-	/* At this point, we are at the leaf node that needs to be altered. */
-	/* Exact fit, no nodes needed. */
-	if (wr_mas.r_min == mas->index && wr_mas.r_max == mas->last)
+	request = mas_prealloc_calc(&wr_mas);
+	if (!request)
 		return 0;
 
-	mas_wr_end_piv(&wr_mas);
-	node_size = mas_wr_new_end(&wr_mas);
-	if (node_size >= mt_slots[wr_mas.type]) {
-		/* Split, worst case for now. */
-		request = 1 + mas_mt_height(mas) * 2;
-		goto ask_now;
-	}
-
-	/* New root needs a singe node */
-	if (unlikely(mte_is_root(mas->node)))
-		goto ask_now;
-
-	/* Potential spanning rebalance collapsing a node, use worst-case */
-	if (node_size  - 1 <= mt_min_slots[wr_mas.type])
-		request = mas_mt_height(mas) * 2 - 1;
-
-	/* node store, slot store needs one node */
-ask_now:
 	mas_node_count_gfp(mas, request, gfp);
 	mas->mas_flags |= MA_STATE_PREALLOC;
 	if (likely(!mas_is_err(mas)))
-- 
2.41.0


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

* [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp()
  2023-10-09 20:16 [PATCH 0/3] align maple tree write paths Sidhartha Kumar
  2023-10-09 20:16 ` [PATCH 1/3] maple_tree: introduce mas_prealloc_calc() Sidhartha Kumar
@ 2023-10-09 20:16 ` Sidhartha Kumar
  2023-10-10  3:03   ` Peng Zhang
                     ` (2 more replies)
  2023-10-09 20:16 ` [PATCH 3/3] maple_tree: use preallocations in mas_erase() Sidhartha Kumar
  2 siblings, 3 replies; 17+ messages in thread
From: Sidhartha Kumar @ 2023-10-09 20:16 UTC (permalink / raw)
  To: linux-kernel, linux-mm, maple-tree
  Cc: akpm, willy, liam.howlett, zhangpeng.00, Sidhartha Kumar

Preallocate maple nodes before call to mas_wr_store_entry(). If a new
node is not needed, go directly to mas_wr_store_entry(), otherwise
allocate the needed nodes and set the MA_STATE_PREALLOC flag.

Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
 lib/maple_tree.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index e239197a57fc..25ae66e585f4 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -5478,17 +5478,33 @@ int mas_prealloc_calc(struct ma_wr_state *wr_mas)
 int mas_store_gfp(struct ma_state *mas, void *entry, gfp_t gfp)
 {
 	MA_WR_STATE(wr_mas, mas, entry);
+	int request;
 
 	mas_wr_store_setup(&wr_mas);
-	trace_ma_write(__func__, mas, 0, entry);
-retry:
+	wr_mas.content = mas_start(mas);
+
+	request = mas_prealloc_calc(&wr_mas);
+	if (!request)
+		goto store_entry;
+
+	mas_node_count_gfp(mas, request, gfp);
+	if (unlikely(mas_is_err(mas))) {
+		mas_set_alloc_req(mas, 0);
+		mas_destroy(mas);
+		mas_reset(mas);
+		return xa_err(mas->node);
+	}
+	mas->mas_flags |= MA_STATE_PREALLOC;
+
+store_entry:
 	mas_wr_store_entry(&wr_mas);
 	if (unlikely(mas_nomem(mas, gfp)))
-		goto retry;
+		goto store_entry;
 
 	if (unlikely(mas_is_err(mas)))
 		return xa_err(mas->node);
 
+	trace_ma_write(__func__, mas, 0, entry);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(mas_store_gfp);
-- 
2.41.0


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

* [PATCH 3/3] maple_tree: use preallocations in mas_erase()
  2023-10-09 20:16 [PATCH 0/3] align maple tree write paths Sidhartha Kumar
  2023-10-09 20:16 ` [PATCH 1/3] maple_tree: introduce mas_prealloc_calc() Sidhartha Kumar
  2023-10-09 20:16 ` [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp() Sidhartha Kumar
@ 2023-10-09 20:16 ` Sidhartha Kumar
  2 siblings, 0 replies; 17+ messages in thread
From: Sidhartha Kumar @ 2023-10-09 20:16 UTC (permalink / raw)
  To: linux-kernel, linux-mm, maple-tree
  Cc: akpm, willy, liam.howlett, zhangpeng.00, Sidhartha Kumar

Preallocate the number of needed nodes before mas_wr_store_entry().

Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
 lib/maple_tree.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 25ae66e585f4..ef8d4b6b4456 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -6191,6 +6191,7 @@ void *mas_erase(struct ma_state *mas)
 {
 	void *entry;
 	MA_WR_STATE(wr_mas, mas, NULL);
+	int request;
 
 	if (mas_is_none(mas) || mas_is_paused(mas))
 		mas->node = MAS_START;
@@ -6200,14 +6201,30 @@ void *mas_erase(struct ma_state *mas)
 	if (!entry)
 		return NULL;
 
-write_retry:
 	/* Must reset to ensure spanning writes of last slot are detected */
 	mas_reset(mas);
 	mas_wr_store_setup(&wr_mas);
+	wr_mas.content = mas_start(mas);
+
+	request = mas_prealloc_calc(&wr_mas);
+	if (!request)
+		goto store_entry;
+
+	mas_node_count_gfp(mas, request, GFP_KERNEL);
+	if (unlikely(mas_is_err(mas))) {
+		mas_set_alloc_req(mas, 0);
+		mas_destroy(mas);
+		mas_reset(mas);
+		return NULL;
+	}
+	mas->mas_flags |= MA_STATE_PREALLOC;
+
+store_entry:
 	mas_wr_store_entry(&wr_mas);
 	if (mas_nomem(mas, GFP_KERNEL))
-		goto write_retry;
+		goto store_entry;
 
+	trace_ma_write(__func__, mas, 0, entry);
 	return entry;
 }
 EXPORT_SYMBOL_GPL(mas_erase);
-- 
2.41.0


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

* Re: [PATCH 1/3] maple_tree: introduce mas_prealloc_calc()
  2023-10-09 20:16 ` [PATCH 1/3] maple_tree: introduce mas_prealloc_calc() Sidhartha Kumar
@ 2023-10-09 22:25   ` kernel test robot
  2023-10-10 22:13     ` Sidhartha Kumar
  2023-10-10 11:06   ` kernel test robot
  2023-10-18  2:53   ` kernel test robot
  2 siblings, 1 reply; 17+ messages in thread
From: kernel test robot @ 2023-10-09 22:25 UTC (permalink / raw)
  To: Sidhartha Kumar, linux-kernel, linux-mm, maple-tree
  Cc: oe-kbuild-all, akpm, willy, liam.howlett, zhangpeng.00, Sidhartha Kumar

Hi Sidhartha,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on linus/master v6.6-rc5 next-20231009]
[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/Sidhartha-Kumar/maple_tree-introduce-mas_prealloc_calc/20231010-041859
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20231009201639.920512-2-sidhartha.kumar%40oracle.com
patch subject: [PATCH 1/3] maple_tree: introduce mas_prealloc_calc()
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20231010/202310100603.qsn3ruBx-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231010/202310100603.qsn3ruBx-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/202310100603.qsn3ruBx-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> lib/maple_tree.c:5428:5: warning: no previous prototype for 'mas_prealloc_calc' [-Wmissing-prototypes]
    5428 | int mas_prealloc_calc(struct ma_wr_state *wr_mas)
         |     ^~~~~~~~~~~~~~~~~


vim +/mas_prealloc_calc +5428 lib/maple_tree.c

  5420	
  5421	/**
  5422	 * mas_prealloc_calc() - Calculate number of nodes needed for a
  5423	 * store operation.
  5424	 * @wr_mas: The maple write state
  5425	 *
  5426	 * Return: Number of nodes required for preallocation.
  5427	 */
> 5428	int mas_prealloc_calc(struct ma_wr_state *wr_mas)
  5429	{
  5430		struct ma_state *mas = wr_mas->mas;
  5431		unsigned char node_size;
  5432	
  5433		if (unlikely(!mas->index && mas->last == ULONG_MAX))
  5434			return 1;
  5435	
  5436		/* Root expand */
  5437		if (unlikely(mas_is_none(mas) || mas_is_ptr(mas)))
  5438			return 1;
  5439	
  5440		if (unlikely(!mas_wr_walk(wr_mas))) {
  5441			/* Spanning store, use worst case for now */
  5442			return 1 + mas_mt_height(mas) * 3;
  5443		}
  5444	
  5445		/* At this point, we are at the leaf node that needs to be altered. */
  5446		/* Exact fit, no nodes needed. */
  5447		if (wr_mas->r_min == mas->index && wr_mas->r_max == mas->last)
  5448			return 0;
  5449	
  5450		mas_wr_end_piv(wr_mas);
  5451		node_size = mas_wr_new_end(wr_mas);
  5452		if (node_size >= mt_slots[wr_mas->type]) {
  5453			/* Split, worst case for now. */
  5454			return 1 + mas_mt_height(mas) * 2;
  5455		}
  5456	
  5457		/* New root needs a singe node */
  5458		if (unlikely(mte_is_root(mas->node)))
  5459			return 1;
  5460	
  5461		/* Potential spanning rebalance collapsing a node, use worst-case */
  5462		if (node_size  - 1 <= mt_min_slots[wr_mas->type])
  5463			return mas_mt_height(mas) * 2 - 1;
  5464	
  5465		/* node store, slot store needs one node */
  5466		return 1;
  5467	}
  5468	

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

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

* Re: [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp()
  2023-10-09 20:16 ` [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp() Sidhartha Kumar
@ 2023-10-10  3:03   ` Peng Zhang
  2023-10-11  0:17     ` Sidhartha Kumar
  2023-10-10 18:15   ` Liam R. Howlett
  2023-10-25  9:52   ` kernel test robot
  2 siblings, 1 reply; 17+ messages in thread
From: Peng Zhang @ 2023-10-10  3:03 UTC (permalink / raw)
  To: Sidhartha Kumar
  Cc: akpm, willy, liam.howlett, zhangpeng.00, linux-kernel,
	maple-tree, linux-mm

Hi,

在 2023/10/10 04:16, Sidhartha Kumar 写道:
> Preallocate maple nodes before call to mas_wr_store_entry(). If a new
> node is not needed, go directly to mas_wr_store_entry(), otherwise
> allocate the needed nodes and set the MA_STATE_PREALLOC flag.
> 
> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> ---
>   lib/maple_tree.c | 22 +++++++++++++++++++---
>   1 file changed, 19 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index e239197a57fc..25ae66e585f4 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -5478,17 +5478,33 @@ int mas_prealloc_calc(struct ma_wr_state *wr_mas)
>   int mas_store_gfp(struct ma_state *mas, void *entry, gfp_t gfp)
>   {
>   	MA_WR_STATE(wr_mas, mas, entry);
> +	int request;
>   
>   	mas_wr_store_setup(&wr_mas);
> -	trace_ma_write(__func__, mas, 0, entry);
> -retry:
> +	wr_mas.content = mas_start(mas);
> +
> +	request = mas_prealloc_calc(&wr_mas);
mas_wr_store_entry() does something similar to mas_prealloc_calc().
Now, making it do it twice would incur additional overhead.
We encountered this issue while optimizing preallocation, but it
hasn't been resolved yet. Previously, this problem only occurred
when using mas_preallocate(). Now, this change would bring this
impact to all write operations on maple tree. What do you think
about it?

Thanks,
Peng
> +	if (!request)
> +		goto store_entry;
> +
> +	mas_node_count_gfp(mas, request, gfp);
> +	if (unlikely(mas_is_err(mas))) {
> +		mas_set_alloc_req(mas, 0);
> +		mas_destroy(mas);
> +		mas_reset(mas);
> +		return xa_err(mas->node);
> +	}
> +	mas->mas_flags |= MA_STATE_PREALLOC;
> +
> +store_entry:
>   	mas_wr_store_entry(&wr_mas);
>   	if (unlikely(mas_nomem(mas, gfp)))
> -		goto retry;
> +		goto store_entry;
>   
>   	if (unlikely(mas_is_err(mas)))
>   		return xa_err(mas->node);
>   
> +	trace_ma_write(__func__, mas, 0, entry);
>   	return 0;
>   }
>   EXPORT_SYMBOL_GPL(mas_store_gfp);

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

* Re: [PATCH 1/3] maple_tree: introduce mas_prealloc_calc()
  2023-10-09 20:16 ` [PATCH 1/3] maple_tree: introduce mas_prealloc_calc() Sidhartha Kumar
  2023-10-09 22:25   ` kernel test robot
@ 2023-10-10 11:06   ` kernel test robot
  2023-10-18  2:53   ` kernel test robot
  2 siblings, 0 replies; 17+ messages in thread
From: kernel test robot @ 2023-10-10 11:06 UTC (permalink / raw)
  To: Sidhartha Kumar, linux-kernel, linux-mm, maple-tree
  Cc: llvm, oe-kbuild-all, akpm, willy, liam.howlett, zhangpeng.00,
	Sidhartha Kumar

Hi Sidhartha,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on linus/master v6.6-rc5 next-20231010]
[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/Sidhartha-Kumar/maple_tree-introduce-mas_prealloc_calc/20231010-041859
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20231009201639.920512-2-sidhartha.kumar%40oracle.com
patch subject: [PATCH 1/3] maple_tree: introduce mas_prealloc_calc()
config: um-allnoconfig (https://download.01.org/0day-ci/archive/20231010/202310101854.kMSUyzOr-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231010/202310101854.kMSUyzOr-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/202310101854.kMSUyzOr-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> lib/maple_tree.c:5428:5: warning: no previous prototype for function 'mas_prealloc_calc' [-Wmissing-prototypes]
    5428 | int mas_prealloc_calc(struct ma_wr_state *wr_mas)
         |     ^
   lib/maple_tree.c:5428:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
    5428 | int mas_prealloc_calc(struct ma_wr_state *wr_mas)
         | ^
         | static 
   lib/maple_tree.c:348:21: warning: unused function 'mte_set_full' [-Wunused-function]
     348 | static inline void *mte_set_full(const struct maple_enode *node)
         |                     ^
   lib/maple_tree.c:353:21: warning: unused function 'mte_clear_full' [-Wunused-function]
     353 | static inline void *mte_clear_full(const struct maple_enode *node)
         |                     ^
   lib/maple_tree.c:358:20: warning: unused function 'mte_has_null' [-Wunused-function]
     358 | static inline bool mte_has_null(const struct maple_enode *node)
         |                    ^
   lib/maple_tree.c:689:29: warning: unused function 'mas_pivot' [-Wunused-function]
     689 | static inline unsigned long mas_pivot(struct ma_state *mas, unsigned char piv)
         |                             ^
   lib/maple_tree.c:4201:20: warning: stack frame size (1032) exceeds limit (1024) in 'mas_wr_modify' [-Wframe-larger-than]
    4201 | static inline void mas_wr_modify(struct ma_wr_state *wr_mas)
         |                    ^
   6 warnings generated.


vim +/mas_prealloc_calc +5428 lib/maple_tree.c

  5420	
  5421	/**
  5422	 * mas_prealloc_calc() - Calculate number of nodes needed for a
  5423	 * store operation.
  5424	 * @wr_mas: The maple write state
  5425	 *
  5426	 * Return: Number of nodes required for preallocation.
  5427	 */
> 5428	int mas_prealloc_calc(struct ma_wr_state *wr_mas)
  5429	{
  5430		struct ma_state *mas = wr_mas->mas;
  5431		unsigned char node_size;
  5432	
  5433		if (unlikely(!mas->index && mas->last == ULONG_MAX))
  5434			return 1;
  5435	
  5436		/* Root expand */
  5437		if (unlikely(mas_is_none(mas) || mas_is_ptr(mas)))
  5438			return 1;
  5439	
  5440		if (unlikely(!mas_wr_walk(wr_mas))) {
  5441			/* Spanning store, use worst case for now */
  5442			return 1 + mas_mt_height(mas) * 3;
  5443		}
  5444	
  5445		/* At this point, we are at the leaf node that needs to be altered. */
  5446		/* Exact fit, no nodes needed. */
  5447		if (wr_mas->r_min == mas->index && wr_mas->r_max == mas->last)
  5448			return 0;
  5449	
  5450		mas_wr_end_piv(wr_mas);
  5451		node_size = mas_wr_new_end(wr_mas);
  5452		if (node_size >= mt_slots[wr_mas->type]) {
  5453			/* Split, worst case for now. */
  5454			return 1 + mas_mt_height(mas) * 2;
  5455		}
  5456	
  5457		/* New root needs a singe node */
  5458		if (unlikely(mte_is_root(mas->node)))
  5459			return 1;
  5460	
  5461		/* Potential spanning rebalance collapsing a node, use worst-case */
  5462		if (node_size  - 1 <= mt_min_slots[wr_mas->type])
  5463			return mas_mt_height(mas) * 2 - 1;
  5464	
  5465		/* node store, slot store needs one node */
  5466		return 1;
  5467	}
  5468	

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

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

* Re: [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp()
  2023-10-09 20:16 ` [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp() Sidhartha Kumar
  2023-10-10  3:03   ` Peng Zhang
@ 2023-10-10 18:15   ` Liam R. Howlett
  2023-10-25  9:52   ` kernel test robot
  2 siblings, 0 replies; 17+ messages in thread
From: Liam R. Howlett @ 2023-10-10 18:15 UTC (permalink / raw)
  To: Sidhartha Kumar
  Cc: linux-kernel, linux-mm, maple-tree, akpm, willy, zhangpeng.00

* Sidhartha Kumar <sidhartha.kumar@oracle.com> [231009 16:16]:
> Preallocate maple nodes before call to mas_wr_store_entry(). If a new
> node is not needed, go directly to mas_wr_store_entry(), otherwise
> allocate the needed nodes and set the MA_STATE_PREALLOC flag.


The way I'd like to see this working is to preallocate nodes prior to
writing, but also to end in a state where we can call the store
operation to continue the operation.  Both of these parts need to be
together in a patch set if they cannot be in the same patch.

Thanks,
Liam

> 
> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> ---
>  lib/maple_tree.c | 22 +++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index e239197a57fc..25ae66e585f4 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -5478,17 +5478,33 @@ int mas_prealloc_calc(struct ma_wr_state *wr_mas)
>  int mas_store_gfp(struct ma_state *mas, void *entry, gfp_t gfp)
>  {
>  	MA_WR_STATE(wr_mas, mas, entry);
> +	int request;
>  
>  	mas_wr_store_setup(&wr_mas);
> -	trace_ma_write(__func__, mas, 0, entry);
> -retry:
> +	wr_mas.content = mas_start(mas);
> +
> +	request = mas_prealloc_calc(&wr_mas);
> +	if (!request)
> +		goto store_entry;
> +
> +	mas_node_count_gfp(mas, request, gfp);
> +	if (unlikely(mas_is_err(mas))) {
> +		mas_set_alloc_req(mas, 0);
> +		mas_destroy(mas);
> +		mas_reset(mas);
> +		return xa_err(mas->node);
> +	}
> +	mas->mas_flags |= MA_STATE_PREALLOC;
> +
> +store_entry:
>  	mas_wr_store_entry(&wr_mas);
>  	if (unlikely(mas_nomem(mas, gfp)))
> -		goto retry;
> +		goto store_entry;
>  
>  	if (unlikely(mas_is_err(mas)))
>  		return xa_err(mas->node);
>  
> +	trace_ma_write(__func__, mas, 0, entry);
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(mas_store_gfp);
> -- 
> 2.41.0
> 

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

* Re: [PATCH 1/3] maple_tree: introduce mas_prealloc_calc()
  2023-10-09 22:25   ` kernel test robot
@ 2023-10-10 22:13     ` Sidhartha Kumar
  0 siblings, 0 replies; 17+ messages in thread
From: Sidhartha Kumar @ 2023-10-10 22:13 UTC (permalink / raw)
  To: kernel test robot, linux-kernel, linux-mm, maple-tree
  Cc: oe-kbuild-all, akpm, willy, liam.howlett, zhangpeng.00

On 10/9/23 3:25 PM, kernel test robot wrote:
> Hi Sidhartha,
> 
> kernel test robot noticed the following build warnings:
> 
> [auto build test WARNING on akpm-mm/mm-everything]
> [also build test WARNING on linus/master v6.6-rc5 next-20231009]
> [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/Sidhartha-Kumar/maple_tree-introduce-mas_prealloc_calc/20231010-041859
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> patch link:    https://lore.kernel.org/r/20231009201639.920512-2-sidhartha.kumar%40oracle.com
> patch subject: [PATCH 1/3] maple_tree: introduce mas_prealloc_calc()
> config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20231010/202310100603.qsn3ruBx-lkp@intel.com/config)
> compiler: m68k-linux-gcc (GCC) 13.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231010/202310100603.qsn3ruBx-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/202310100603.qsn3ruBx-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
>>> lib/maple_tree.c:5428:5: warning: no previous prototype for 'mas_prealloc_calc' [-Wmissing-prototypes]
>      5428 | int mas_prealloc_calc(struct ma_wr_state *wr_mas)
>           |     ^~~~~~~~~~~~~~~~~
> 
> 
> vim +/mas_prealloc_calc +5428 lib/maple_tree.c
> 
>    5420	
>    5421	/**
>    5422	 * mas_prealloc_calc() - Calculate number of nodes needed for a
>    5423	 * store operation.
>    5424	 * @wr_mas: The maple write state
>    5425	 *
>    5426	 * Return: Number of nodes required for preallocation.
>    5427	 */
>> 5428	int mas_prealloc_calc(struct ma_wr_state *wr_mas)

Adding static inline should fix this compilation error.

>    5429	{
>    5430		struct ma_state *mas = wr_mas->mas;
>    5431		unsigned char node_size;
>    5432	
>    5433		if (unlikely(!mas->index && mas->last == ULONG_MAX))
>    5434			return 1;
>    5435	
>    5436		/* Root expand */
>    5437		if (unlikely(mas_is_none(mas) || mas_is_ptr(mas)))
>    5438			return 1;
>    5439	
>    5440		if (unlikely(!mas_wr_walk(wr_mas))) {
>    5441			/* Spanning store, use worst case for now */
>    5442			return 1 + mas_mt_height(mas) * 3;
>    5443		}
>    5444	
>    5445		/* At this point, we are at the leaf node that needs to be altered. */
>    5446		/* Exact fit, no nodes needed. */
>    5447		if (wr_mas->r_min == mas->index && wr_mas->r_max == mas->last)
>    5448			return 0;
>    5449	
>    5450		mas_wr_end_piv(wr_mas);
>    5451		node_size = mas_wr_new_end(wr_mas);
>    5452		if (node_size >= mt_slots[wr_mas->type]) {
>    5453			/* Split, worst case for now. */
>    5454			return 1 + mas_mt_height(mas) * 2;
>    5455		}
>    5456	
>    5457		/* New root needs a singe node */
>    5458		if (unlikely(mte_is_root(mas->node)))
>    5459			return 1;
>    5460	
>    5461		/* Potential spanning rebalance collapsing a node, use worst-case */
>    5462		if (node_size  - 1 <= mt_min_slots[wr_mas->type])
>    5463			return mas_mt_height(mas) * 2 - 1;
>    5464	
>    5465		/* node store, slot store needs one node */
>    5466		return 1;
>    5467	}
>    5468	
> 


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

* Re: [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp()
  2023-10-10  3:03   ` Peng Zhang
@ 2023-10-11  0:17     ` Sidhartha Kumar
  2023-10-11  7:40       ` Peng Zhang
  0 siblings, 1 reply; 17+ messages in thread
From: Sidhartha Kumar @ 2023-10-11  0:17 UTC (permalink / raw)
  To: Peng Zhang; +Cc: akpm, willy, liam.howlett, linux-kernel, maple-tree, linux-mm

On 10/9/23 8:03 PM, Peng Zhang wrote:
> Hi,
> 
> 在 2023/10/10 04:16, Sidhartha Kumar 写道:
>> Preallocate maple nodes before call to mas_wr_store_entry(). If a new
>> node is not needed, go directly to mas_wr_store_entry(), otherwise
>> allocate the needed nodes and set the MA_STATE_PREALLOC flag.
>>
>> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
>> ---
>>   lib/maple_tree.c | 22 +++++++++++++++++++---
>>   1 file changed, 19 insertions(+), 3 deletions(-)
>>
>> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
>> index e239197a57fc..25ae66e585f4 100644
>> --- a/lib/maple_tree.c
>> +++ b/lib/maple_tree.c
>> @@ -5478,17 +5478,33 @@ int mas_prealloc_calc(struct ma_wr_state *wr_mas)
>>   int mas_store_gfp(struct ma_state *mas, void *entry, gfp_t gfp)
>>   {
>>       MA_WR_STATE(wr_mas, mas, entry);
>> +    int request;
>>       mas_wr_store_setup(&wr_mas);
>> -    trace_ma_write(__func__, mas, 0, entry);
>> -retry:
>> +    wr_mas.content = mas_start(mas);
>> +
>> +    request = mas_prealloc_calc(&wr_mas);
> mas_wr_store_entry() does something similar to mas_prealloc_calc().
> Now, making it do it twice would incur additional overhead.
> We encountered this issue while optimizing preallocation, but it
> hasn't been resolved yet. Previously, this problem only occurred
> when using mas_preallocate(). Now, this change would bring this
> impact to all write operations on maple tree. What do you think
> about it?
> 

After talking to Liam, I will have to implement the store type enum 
feature on the Maple Tree Work list so that mas_prealloc_calc() can 
start a partial walk and write that information to the enum. 
mas_wr_store_entry() can then read that enum to continue the walk that 
was already started rather than having to redo the whole walk. This 
could also be used in mas_preallocate(). Do you have any suggestions for 
the implementation of this enum?

Thanks,
Sid

> Thanks,
> Peng
>> +    if (!request)
>> +        goto store_entry;
>> +
>> +    mas_node_count_gfp(mas, request, gfp);
>> +    if (unlikely(mas_is_err(mas))) {
>> +        mas_set_alloc_req(mas, 0);
>> +        mas_destroy(mas);
>> +        mas_reset(mas);
>> +        return xa_err(mas->node);
>> +    }
>> +    mas->mas_flags |= MA_STATE_PREALLOC;
>> +
>> +store_entry:
>>       mas_wr_store_entry(&wr_mas);
>>       if (unlikely(mas_nomem(mas, gfp)))
>> -        goto retry;
>> +        goto store_entry;
>>       if (unlikely(mas_is_err(mas)))
>>           return xa_err(mas->node);
>> +    trace_ma_write(__func__, mas, 0, entry);
>>       return 0;
>>   }
>>   EXPORT_SYMBOL_GPL(mas_store_gfp);
> 


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

* Re: [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp()
  2023-10-11  0:17     ` Sidhartha Kumar
@ 2023-10-11  7:40       ` Peng Zhang
  0 siblings, 0 replies; 17+ messages in thread
From: Peng Zhang @ 2023-10-11  7:40 UTC (permalink / raw)
  To: Sidhartha Kumar
  Cc: akpm, willy, liam.howlett, linux-kernel, maple-tree, linux-mm,
	Peng Zhang



在 2023/10/11 08:17, Sidhartha Kumar 写道:
> On 10/9/23 8:03 PM, Peng Zhang wrote:
>> Hi,
>>
>> 在 2023/10/10 04:16, Sidhartha Kumar 写道:
>>> Preallocate maple nodes before call to mas_wr_store_entry(). If a new
>>> node is not needed, go directly to mas_wr_store_entry(), otherwise
>>> allocate the needed nodes and set the MA_STATE_PREALLOC flag.
>>>
>>> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
>>> ---
>>>   lib/maple_tree.c | 22 +++++++++++++++++++---
>>>   1 file changed, 19 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
>>> index e239197a57fc..25ae66e585f4 100644
>>> --- a/lib/maple_tree.c
>>> +++ b/lib/maple_tree.c
>>> @@ -5478,17 +5478,33 @@ int mas_prealloc_calc(struct ma_wr_state *wr_mas)
>>>   int mas_store_gfp(struct ma_state *mas, void *entry, gfp_t gfp)
>>>   {
>>>       MA_WR_STATE(wr_mas, mas, entry);
>>> +    int request;
>>>       mas_wr_store_setup(&wr_mas);
>>> -    trace_ma_write(__func__, mas, 0, entry);
>>> -retry:
>>> +    wr_mas.content = mas_start(mas);
>>> +
>>> +    request = mas_prealloc_calc(&wr_mas);
>> mas_wr_store_entry() does something similar to mas_prealloc_calc().
>> Now, making it do it twice would incur additional overhead.
>> We encountered this issue while optimizing preallocation, but it
>> hasn't been resolved yet. Previously, this problem only occurred
>> when using mas_preallocate(). Now, this change would bring this
>> impact to all write operations on maple tree. What do you think
>> about it?
>>
> 
> After talking to Liam, I will have to implement the store type enum feature on the Maple Tree Work list so that mas_prealloc_calc() can start a partial walk and write that information to the enum. mas_wr_store_entry() can then read that enum to continue the walk that was already started rather than having to redo the whole walk. This could also be used in mas_preallocate(). Do you have any suggestions for the implementation of this enum?
There is another scenario where this enum can be useful,
as seen in the implementation of mas_replace_entry() in [1].
It is a faster alternative to mas_store(), but it is not safe.
If we can determine through the enum while writing the maple
tree that a faster write operation can be performed, it would
be beneficial. Some performance improvements can also be
observed in [1].

[1] https://lore.kernel.org/lkml/49f0181a-55a4-41aa-8596-877560c8b802@bytedance.com/
> 
> Thanks,
> Sid
> 
>> Thanks,
>> Peng
>>> +    if (!request)
>>> +        goto store_entry;
>>> +
>>> +    mas_node_count_gfp(mas, request, gfp);
>>> +    if (unlikely(mas_is_err(mas))) {
>>> +        mas_set_alloc_req(mas, 0);
>>> +        mas_destroy(mas);
>>> +        mas_reset(mas);
>>> +        return xa_err(mas->node);
>>> +    }
>>> +    mas->mas_flags |= MA_STATE_PREALLOC;
>>> +
>>> +store_entry:
>>>       mas_wr_store_entry(&wr_mas);
>>>       if (unlikely(mas_nomem(mas, gfp)))
>>> -        goto retry;
>>> +        goto store_entry;
>>>       if (unlikely(mas_is_err(mas)))
>>>           return xa_err(mas->node);
>>> +    trace_ma_write(__func__, mas, 0, entry);
>>>       return 0;
>>>   }
>>>   EXPORT_SYMBOL_GPL(mas_store_gfp);
>>
> 
> 

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

* Re: [PATCH 1/3] maple_tree: introduce mas_prealloc_calc()
  2023-10-09 20:16 ` [PATCH 1/3] maple_tree: introduce mas_prealloc_calc() Sidhartha Kumar
  2023-10-09 22:25   ` kernel test robot
  2023-10-10 11:06   ` kernel test robot
@ 2023-10-18  2:53   ` kernel test robot
  2 siblings, 0 replies; 17+ messages in thread
From: kernel test robot @ 2023-10-18  2:53 UTC (permalink / raw)
  To: Sidhartha Kumar, linux-kernel, linux-mm, maple-tree
  Cc: oe-kbuild-all, akpm, willy, liam.howlett, zhangpeng.00, Sidhartha Kumar

Hi Sidhartha,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on linus/master v6.6-rc6 next-20231017]
[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/Sidhartha-Kumar/maple_tree-introduce-mas_prealloc_calc/20231010-041859
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20231009201639.920512-2-sidhartha.kumar%40oracle.com
patch subject: [PATCH 1/3] maple_tree: introduce mas_prealloc_calc()
config: i386-randconfig-061-20231018 (https://download.01.org/0day-ci/archive/20231018/202310181030.sYP91twn-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231018/202310181030.sYP91twn-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/202310181030.sYP91twn-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> lib/maple_tree.c:5428:5: sparse: sparse: symbol 'mas_prealloc_calc' was not declared. Should it be static?

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

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

* Re: [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp()
  2023-10-09 20:16 ` [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp() Sidhartha Kumar
  2023-10-10  3:03   ` Peng Zhang
  2023-10-10 18:15   ` Liam R. Howlett
@ 2023-10-25  9:52   ` kernel test robot
  2023-10-26 17:16     ` Liam R. Howlett
  2 siblings, 1 reply; 17+ messages in thread
From: kernel test robot @ 2023-10-25  9:52 UTC (permalink / raw)
  To: Sidhartha Kumar
  Cc: oe-lkp, lkp, maple-tree, linux-mm, linux-kernel, akpm, willy,
	liam.howlett, zhangpeng.00, Sidhartha Kumar, oliver.sang



Hello,

kernel test robot noticed "BUG:sleeping_function_called_from_invalid_context_at_include/linux/sched/mm.h" on:

commit: 9116baa49536116f013d691d2178c520959f46c2 ("[PATCH 2/3] maple_tree: use preallocations in mas_store_gfp()")
url: https://github.com/intel-lab-lkp/linux/commits/Sidhartha-Kumar/maple_tree-introduce-mas_prealloc_calc/20231010-041859
base: https://git.kernel.org/cgit/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/all/20231009201639.920512-3-sidhartha.kumar@oracle.com/
patch subject: [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp()

in testcase: boot

compiler: gcc-11
test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 16G

(please refer to attached dmesg/kmsg for entire log/backtrace)


+------------------------------------------------------------------------------------+------------+------------+
|                                                                                    | 9cbebad6db | 9116baa495 |
+------------------------------------------------------------------------------------+------------+------------+
| BUG:sleeping_function_called_from_invalid_context_at_include/linux/sched/mm.h      | 0          | 7          |
| WARNING:suspicious_RCU_usage                                                       | 0          | 7          |
| include/linux/rcupdate.h:#Illegal_context_switch_in_RCU_read-side_critical_section | 0          | 7          |
+------------------------------------------------------------------------------------+------------+------------+


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 <oliver.sang@intel.com>
| Closes: https://lore.kernel.org/oe-lkp/202310251706.6e6f6c4a-oliver.sang@intel.com


[   12.322393][    T1] BUG: sleeping function called from invalid context at include/linux/sched/mm.h:306
[   12.324008][    T1] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper
[   12.325486][    T1] preempt_count: 1, expected: 0
[   12.326345][    T1] 1 lock held by swapper/1:
[ 12.327164][ T1] #0: c2b52570 (&mt->ma_lock){+.+.}-{2:2}, at: check_root_expand+0x46/0xac0 
[   12.328850][    T1] CPU: 0 PID: 1 Comm: swapper Tainted: G                T  6.6.0-rc4-00400-g9116baa49536 #1
[   12.329034][    T1] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
[   12.329034][    T1] Call Trace:
[ 12.329034][ T1] dump_stack_lvl (lib/dump_stack.c:107 (discriminator 1)) 
[ 12.329034][ T1] dump_stack (lib/dump_stack.c:114) 
[ 12.329034][ T1] __might_resched (kernel/sched/core.c:10188) 
[ 12.329034][ T1] __might_sleep (kernel/sched/core.c:10117 (discriminator 17)) 
[ 12.329034][ T1] kmem_cache_alloc (include/linux/sched/mm.h:306 mm/slab.h:705 mm/slub.c:3460 mm/slub.c:3486 mm/slub.c:3493 mm/slub.c:3502) 
[ 12.329034][ T1] ? mas_alloc_nodes (lib/maple_tree.c:160 lib/maple_tree.c:1265) 
[ 12.329034][ T1] mas_alloc_nodes (lib/maple_tree.c:160 lib/maple_tree.c:1265) 
[ 12.329034][ T1] mas_node_count_gfp (lib/maple_tree.c:1347) 
[ 12.329034][ T1] mas_store_gfp (lib/maple_tree.c:256 lib/maple_tree.c:5491) 
[ 12.329034][ T1] ? check_empty_area_fill+0x3d0/0x3d0 
[ 12.329034][ T1] check_root_expand+0x162/0xac0 
[ 12.329034][ T1] maple_tree_seed (lib/test_maple_tree.c:3577) 
[ 12.329034][ T1] ? check_gap_combining+0xdf8/0xdf8 
[ 12.329034][ T1] do_one_initcall (init/main.c:1232) 
[ 12.329034][ T1] do_initcalls (init/main.c:1293 init/main.c:1310) 
[ 12.329034][ T1] kernel_init_freeable (init/main.c:1551) 
[ 12.329034][ T1] ? rest_init (init/main.c:1429) 
[ 12.329034][ T1] kernel_init (init/main.c:1439) 
[ 12.329034][ T1] ret_from_fork (arch/x86/kernel/process.c:153) 
[ 12.329034][ T1] ? rest_init (init/main.c:1429) 
[ 12.329034][ T1] ret_from_fork_asm (arch/x86/entry/entry_32.S:741) 
[ 12.329034][ T1] entry_INT80_32 (arch/x86/entry/entry_32.S:944) 
[   12.353802][    T1]
[   12.354345][    T1] =============================
[   12.355188][    T1] WARNING: suspicious RCU usage
[   12.356056][    T1] 6.6.0-rc4-00400-g9116baa49536 #1 Tainted: G        W       T
[   12.357413][    T1] -----------------------------
[   12.358272][    T1] include/linux/rcupdate.h:375 Illegal context switch in RCU read-side critical section!
[   12.359905][    T1]
[   12.359905][    T1] other info that might help us debug this:
[   12.359905][    T1]
[   12.361711][    T1]
[   12.361711][    T1] rcu_scheduler_active = 2, debug_locks = 1
[   12.363058][    T1] 2 locks held by swapper/1:
[ 12.363877][ T1] #0: c2ad5938 (rcu_read_lock){....}-{1:2}, at: check_mas_store_gfp+0xa9/0x1b0 
[ 12.365646][ T1] #1: c3965e84 (&mt->ma_lock){+.+.}-{2:2}, at: check_mas_store_gfp+0x104/0x1b0 
[   12.367338][    T1]
[   12.367338][    T1] stack backtrace:
[   12.368430][    T1] CPU: 0 PID: 1 Comm: swapper Tainted: G        W       T  6.6.0-rc4-00400-g9116baa49536 #1
[   12.369129][    T1] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
[   12.369129][    T1] Call Trace:
[ 12.369129][ T1] dump_stack_lvl (lib/dump_stack.c:107 (discriminator 1)) 
[ 12.369129][ T1] dump_stack (lib/dump_stack.c:114) 
[ 12.369129][ T1] lockdep_rcu_suspicious (kernel/locking/lockdep.c:6713) 
[ 12.369129][ T1] __might_resched (include/linux/rcupdate.h:375 kernel/sched/core.c:10149) 
[ 12.369129][ T1] __might_sleep (kernel/sched/core.c:10117 (discriminator 17)) 
[ 12.369129][ T1] kmem_cache_alloc (include/linux/sched/mm.h:306 mm/slab.h:705 mm/slub.c:3460 mm/slub.c:3486 mm/slub.c:3493 mm/slub.c:3502) 
[ 12.369129][ T1] ? mas_alloc_nodes (lib/maple_tree.c:160 lib/maple_tree.c:1265) 
[ 12.369129][ T1] mas_alloc_nodes (lib/maple_tree.c:160 lib/maple_tree.c:1265) 
[ 12.369129][ T1] mas_node_count_gfp (lib/maple_tree.c:1347) 
[ 12.369129][ T1] mas_store_gfp (lib/maple_tree.c:256 lib/maple_tree.c:5491) 
[ 12.369129][ T1] check_mas_store_gfp+0x14b/0x1b0 
[ 12.369129][ T1] maple_tree_seed (lib/test_maple_tree.c:3646) 
[ 12.369129][ T1] ? check_gap_combining+0xdf8/0xdf8 
[ 12.369129][ T1] do_one_initcall (init/main.c:1232) 
[ 12.369129][ T1] do_initcalls (init/main.c:1293 init/main.c:1310) 
[ 12.369129][ T1] kernel_init_freeable (init/main.c:1551) 
[ 12.369129][ T1] ? rest_init (init/main.c:1429) 
[ 12.369129][ T1] kernel_init (init/main.c:1439) 
[ 12.369129][ T1] ret_from_fork (arch/x86/kernel/process.c:153) 
[ 12.369129][ T1] ? rest_init (init/main.c:1429) 
[ 12.369129][ T1] ret_from_fork_asm (arch/x86/entry/entry_32.S:741) 
[ 12.369129][ T1] entry_INT80_32 (arch/x86/entry/entry_32.S:944) 
[   15.220029][   T34] torture_spin_lock_write_delay: delay = 25 jiffies.
[   16.033920][   T35] torture_spin_lock_write_delay: delay = 25 jiffies.
[   17.655206][   T35] torture_spin_lock_write_delay: delay = 25 jiffies.
[   19.245918][   T35] torture_spin_lock_write_delay: delay = 25 jiffies.
[   36.522020][   T34] torture_spin_lock_write_delay: delay = 25 jiffies.
[   37.994914][   T34] torture_spin_lock_write_delay: delay = 25 jiffies.
[   38.766533][   T35] torture_spin_lock_write_delay: delay = 25 jiffies.
[   41.775652][   T34] torture_spin_lock_write_delay: delay = 25 jiffies.
[   43.236341][   T35] torture_spin_lock_write_delay: delay = 24 jiffies.
[   44.106914][   T34] torture_spin_lock_write_delay: delay = 25 jiffies.
[   46.776934][   T34] torture_spin_lock_write_delay: delay = 25 jiffies.
[   47.165604][   T35] torture_spin_lock_write_delay: delay = 25 jiffies.
[   49.209209][   T34] torture_spin_lock_write_delay: delay = 25 jiffies.
[   50.316931][   T35] torture_spin_lock_write_delay: delay = 25 jiffies.
[   51.511048][   T34] torture_spin_lock_write_delay: delay = 25 jiffies.
[   54.564928][   T35] torture_spin_lock_write_delay: delay = 25 jiffies.
[   59.372367][    T1] BUG: sleeping function called from invalid context at include/linux/sched/mm.h:306
[   59.374045][    T1] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper
[   59.375483][    T1] preempt_count: 1, expected: 0
[   59.376310][    T1] 1 lock held by swapper/1:
[ 59.377090][ T1] #0: c2b52570 (&mt->ma_lock){+.+.}-{2:2}, at: check_empty_area_fill+0xe5/0x3d0 
[   59.378744][    T1] CPU: 0 PID: 1 Comm: swapper Tainted: G        W       T  6.6.0-rc4-00400-g9116baa49536 #1
[   59.380409][    T1] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
[   59.381080][    T1] Call Trace:
[ 59.381080][ T1] dump_stack_lvl (lib/dump_stack.c:107 (discriminator 1)) 
[ 59.381080][ T1] dump_stack (lib/dump_stack.c:114) 
[ 59.381080][ T1] __might_resched (kernel/sched/core.c:10188) 
[ 59.381080][ T1] __might_sleep (kernel/sched/core.c:10117 (discriminator 17)) 
[ 59.381080][ T1] kmem_cache_alloc (include/linux/sched/mm.h:306 mm/slab.h:705 mm/slub.c:3460 mm/slub.c:3486 mm/slub.c:3493 mm/slub.c:3502) 
[ 59.381080][ T1] ? mas_alloc_nodes (lib/maple_tree.c:160 lib/maple_tree.c:1265) 
[ 59.381080][ T1] mas_alloc_nodes (lib/maple_tree.c:160 lib/maple_tree.c:1265) 
[ 59.381080][ T1] mas_node_count_gfp (lib/maple_tree.c:1347) 
[ 59.381080][ T1] mas_store_gfp (lib/maple_tree.c:256 lib/maple_tree.c:5491) 
[ 59.381080][ T1] check_empty_area_fill+0xab/0x3d0 
[ 59.381080][ T1] maple_tree_seed (lib/test_maple_tree.c:3837) 
[ 59.381080][ T1] ? check_gap_combining+0xdf8/0xdf8 
[ 59.381080][ T1] do_one_initcall (init/main.c:1232) 
[ 59.381080][ T1] do_initcalls (init/main.c:1293 init/main.c:1310) 
[ 59.381080][ T1] kernel_init_freeable (init/main.c:1551) 
[ 59.381080][ T1] ? rest_init (init/main.c:1429) 
[ 59.381080][ T1] kernel_init (init/main.c:1439) 
[ 59.381080][ T1] ret_from_fork (arch/x86/kernel/process.c:153) 
[ 59.381080][ T1] ? rest_init (init/main.c:1429) 
[ 59.381080][ T1] ret_from_fork_asm (arch/x86/entry/entry_32.S:741) 
[ 59.381080][ T1] entry_INT80_32 (arch/x86/entry/entry_32.S:944) 
[   59.571154][    T1] maple_tree: 3807933 of 3807933 tests passed
[   59.572831][    T1] test_memcat_p: test passed
[   59.590510][    T1] test_meminit: all 11 tests in test_pages passed
[   59.621976][    T1] test_meminit: all 40 tests in test_kvmalloc passed
[   60.207905][    T1] test_meminit: all 70 tests in test_kmemcache passed
[   60.217750][    T1] test_meminit: all 10 tests in test_rcu_persistent passed
[   60.219088][    T1] test_meminit: all 131 tests passed!
[   60.220126][    T1] ref_tracker: reference already released.
[   60.220912][    T1] ref_tracker: allocated in:



The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20231025/202310251706.6e6f6c4a-oliver.sang@intel.com



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


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

* Re: [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp()
  2023-10-25  9:52   ` kernel test robot
@ 2023-10-26 17:16     ` Liam R. Howlett
  2023-10-27  5:59       ` Oliver Sang
  0 siblings, 1 reply; 17+ messages in thread
From: Liam R. Howlett @ 2023-10-26 17:16 UTC (permalink / raw)
  To: kernel test robot; +Cc: oe-lkp, lkp, maple-tree, linux-mm, linux-kernel


... Dropping direct Cc's in attempt to avoid even more noise.

* kernel test robot <oliver.sang@intel.com> [231025 05:52]:
> 
> 
> Hello,
> 
> kernel test robot noticed "BUG:sleeping_function_called_from_invalid_context_at_include/linux/sched/mm.h" on:
...

This patch set is being revised and discussed on how to make it a more
complete solution.

In the mean time, is there any way to stop the bot from emailing
everyone and burning more power?

Thank you,
Liam

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

* Re: [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp()
  2023-10-26 17:16     ` Liam R. Howlett
@ 2023-10-27  5:59       ` Oliver Sang
  2023-11-01 16:59         ` Liam R. Howlett
  0 siblings, 1 reply; 17+ messages in thread
From: Oliver Sang @ 2023-10-27  5:59 UTC (permalink / raw)
  To: Liam R. Howlett, oe-lkp, lkp; +Cc: oliver.sang

hi, Liam,

On Thu, Oct 26, 2023 at 01:16:35PM -0400, Liam R. Howlett wrote:
> 
> ... Dropping direct Cc's in attempt to avoid even more noise.
> 
> * kernel test robot <oliver.sang@intel.com> [231025 05:52]:
> > 
> > 
> > Hello,
> > 
> > kernel test robot noticed "BUG:sleeping_function_called_from_invalid_context_at_include/linux/sched/mm.h" on:
> ...
> 
> This patch set is being revised and discussed on how to make it a more
> complete solution.

got it. we'll stop reporting for this v1 series if any further findings.

BTW, 'kernel test robot' intends to supply extra data while a patch set is
under review and discussion, unless it's already explicitly dropped or NACKed.

> 
> In the mean time, is there any way to stop the bot from emailing
> everyone and burning more power?

want to consult if it's ok to send to the mailing list but not cc any
individual mail in case we find regression for future version?

> 
> Thank you,
> Liam

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

* Re: [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp()
  2023-10-27  5:59       ` Oliver Sang
@ 2023-11-01 16:59         ` Liam R. Howlett
  2023-11-03  2:37           ` Oliver Sang
  0 siblings, 1 reply; 17+ messages in thread
From: Liam R. Howlett @ 2023-11-01 16:59 UTC (permalink / raw)
  To: Oliver Sang; +Cc: oe-lkp, lkp

* Oliver Sang <oliver.sang@intel.com> [231027 01:59]:
> hi, Liam,
> 
> On Thu, Oct 26, 2023 at 01:16:35PM -0400, Liam R. Howlett wrote:
> > 
> > ... Dropping direct Cc's in attempt to avoid even more noise.
> > 
> > * kernel test robot <oliver.sang@intel.com> [231025 05:52]:
> > > 
> > > 
> > > Hello,
> > > 
> > > kernel test robot noticed "BUG:sleeping_function_called_from_invalid_context_at_include/linux/sched/mm.h" on:
> > ...
> > 
> > This patch set is being revised and discussed on how to make it a more
> > complete solution.
> 
> got it. we'll stop reporting for this v1 series if any further findings.
> 
> BTW, 'kernel test robot' intends to supply extra data while a patch set is
> under review and discussion, unless it's already explicitly dropped or NACKed.
> 
> > 
> > In the mean time, is there any way to stop the bot from emailing
> > everyone and burning more power?
> 
> want to consult if it's ok to send to the mailing list but not cc any
> individual mail in case we find regression for future version?

No, no change needed.  I can NACK in the future.

Would it stop if I replied:

NACK - Stopping the bot from testing this further.

Thanks,
Liam

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

* Re: [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp()
  2023-11-01 16:59         ` Liam R. Howlett
@ 2023-11-03  2:37           ` Oliver Sang
  0 siblings, 0 replies; 17+ messages in thread
From: Oliver Sang @ 2023-11-03  2:37 UTC (permalink / raw)
  To: Liam R. Howlett; +Cc: oe-lkp, lkp, oliver.sang

hi, Liam,

On Wed, Nov 01, 2023 at 12:59:14PM -0400, Liam R. Howlett wrote:
> * Oliver Sang <oliver.sang@intel.com> [231027 01:59]:
> > hi, Liam,

...

> > want to consult if it's ok to send to the mailing list but not cc any
> > individual mail in case we find regression for future version?
> 
> No, no change needed.  I can NACK in the future.
> 
> Would it stop if I replied:
> 
> NACK - Stopping the bot from testing this further.

got it. Thanks!

> 
> Thanks,
> Liam

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

end of thread, other threads:[~2023-11-03  2:37 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-09 20:16 [PATCH 0/3] align maple tree write paths Sidhartha Kumar
2023-10-09 20:16 ` [PATCH 1/3] maple_tree: introduce mas_prealloc_calc() Sidhartha Kumar
2023-10-09 22:25   ` kernel test robot
2023-10-10 22:13     ` Sidhartha Kumar
2023-10-10 11:06   ` kernel test robot
2023-10-18  2:53   ` kernel test robot
2023-10-09 20:16 ` [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp() Sidhartha Kumar
2023-10-10  3:03   ` Peng Zhang
2023-10-11  0:17     ` Sidhartha Kumar
2023-10-11  7:40       ` Peng Zhang
2023-10-10 18:15   ` Liam R. Howlett
2023-10-25  9:52   ` kernel test robot
2023-10-26 17:16     ` Liam R. Howlett
2023-10-27  5:59       ` Oliver Sang
2023-11-01 16:59         ` Liam R. Howlett
2023-11-03  2:37           ` Oliver Sang
2023-10-09 20:16 ` [PATCH 3/3] maple_tree: use preallocations in mas_erase() Sidhartha Kumar

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.