diff mbox series

[11/18] maple_tree: use store type in mas_wr_store_entry()

Message ID 20240604174145.563900-12-sidhartha.kumar@oracle.com (mailing list archive)
State New
Headers show
Series Introduce a store type enum for the Maple tree | expand

Commit Message

Sid Kumar June 4, 2024, 5:41 p.m. UTC
When storing an entry, we can read the store type that was set from a
previous partial walk of the tree. Now that the type of store is known,
select the correct write helper function to use to complete the store.

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

Comments

kernel test robot June 4, 2024, 10:02 p.m. UTC | #1
Hi Sidhartha,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-nonmm-unstable]
[also build test WARNING on linus/master v6.10-rc2 next-20240604]
[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-store_type-enum/20240605-014633
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable
patch link:    https://lore.kernel.org/r/20240604174145.563900-12-sidhartha.kumar%40oracle.com
patch subject: [PATCH 11/18] maple_tree: use store type in mas_wr_store_entry()
config: um-allnoconfig (https://download.01.org/0day-ci/archive/20240605/202406050515.BP3o0Meg-lkp@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240605/202406050515.BP3o0Meg-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/202406050515.BP3o0Meg-lkp@intel.com/

All warnings (new ones prefixed by >>):

   lib/maple_tree.c:351:21: warning: unused function 'mte_set_full' [-Wunused-function]
     351 | static inline void *mte_set_full(const struct maple_enode *node)
         |                     ^~~~~~~~~~~~
   lib/maple_tree.c:356:21: warning: unused function 'mte_clear_full' [-Wunused-function]
     356 | static inline void *mte_clear_full(const struct maple_enode *node)
         |                     ^~~~~~~~~~~~~~
   lib/maple_tree.c:361:20: warning: unused function 'mte_has_null' [-Wunused-function]
     361 | static inline bool mte_has_null(const struct maple_enode *node)
         |                    ^~~~~~~~~~~~
>> lib/maple_tree.c:4206:21: warning: stack frame size (1032) exceeds limit (1024) in 'mas_wr_store_entry' [-Wframe-larger-than]
    4206 | static inline void *mas_wr_store_entry(struct ma_wr_state *wr_mas)
         |                     ^
   lib/maple_tree.c:4151:13: warning: stack frame size (1048) exceeds limit (1024) in 'mas_wr_bnode' [-Wframe-larger-than]
    4151 | static void mas_wr_bnode(struct ma_wr_state *wr_mas)
         |             ^
   5 warnings generated.


vim +/mas_wr_store_entry +4206 lib/maple_tree.c

54a611b605901c Liam R. Howlett 2022-09-06  4198  
54a611b605901c Liam R. Howlett 2022-09-06  4199  /*
54a611b605901c Liam R. Howlett 2022-09-06  4200   * mas_wr_store_entry() - Internal call to store a value
54a611b605901c Liam R. Howlett 2022-09-06  4201   * @mas: The maple state
54a611b605901c Liam R. Howlett 2022-09-06  4202   * @entry: The entry to store.
54a611b605901c Liam R. Howlett 2022-09-06  4203   *
54a611b605901c Liam R. Howlett 2022-09-06  4204   * Return: The contents that was stored at the index.
54a611b605901c Liam R. Howlett 2022-09-06  4205   */
54a611b605901c Liam R. Howlett 2022-09-06 @4206  static inline void *mas_wr_store_entry(struct ma_wr_state *wr_mas)
54a611b605901c Liam R. Howlett 2022-09-06  4207  {
54a611b605901c Liam R. Howlett 2022-09-06  4208  	struct ma_state *mas = wr_mas->mas;
7ad45cca258711 Sidhartha Kumar 2024-06-04  4209  	unsigned char new_end = mas_wr_new_end(wr_mas);
54a611b605901c Liam R. Howlett 2022-09-06  4210  
7ad45cca258711 Sidhartha Kumar 2024-06-04  4211  	switch (mas->store_type) {
7ad45cca258711 Sidhartha Kumar 2024-06-04  4212  	case wr_invalid:
7ad45cca258711 Sidhartha Kumar 2024-06-04  4213  		MT_BUG_ON(mas->tree, 1);
7ad45cca258711 Sidhartha Kumar 2024-06-04  4214  		return NULL;
7ad45cca258711 Sidhartha Kumar 2024-06-04  4215  	case wr_new_root:
7ad45cca258711 Sidhartha Kumar 2024-06-04  4216  		mas_new_root(mas, wr_mas->entry);
7ad45cca258711 Sidhartha Kumar 2024-06-04  4217  		break;
7ad45cca258711 Sidhartha Kumar 2024-06-04  4218  	case wr_store_root:
54a611b605901c Liam R. Howlett 2022-09-06  4219  		mas_store_root(mas, wr_mas->entry);
7ad45cca258711 Sidhartha Kumar 2024-06-04  4220  		break;
7ad45cca258711 Sidhartha Kumar 2024-06-04  4221  	case wr_exact_fit:
7ad45cca258711 Sidhartha Kumar 2024-06-04  4222  		rcu_assign_pointer(wr_mas->slots[mas->offset], wr_mas->entry);
7ad45cca258711 Sidhartha Kumar 2024-06-04  4223  		if (!!wr_mas->entry ^ !!wr_mas->content)
7ad45cca258711 Sidhartha Kumar 2024-06-04  4224  			mas_update_gap(mas);
7ad45cca258711 Sidhartha Kumar 2024-06-04  4225  		break;
7ad45cca258711 Sidhartha Kumar 2024-06-04  4226  	case wr_append:
7ad45cca258711 Sidhartha Kumar 2024-06-04  4227  		mas_wr_append(wr_mas, new_end);
7ad45cca258711 Sidhartha Kumar 2024-06-04  4228  		break;
7ad45cca258711 Sidhartha Kumar 2024-06-04  4229  	case wr_slot_store:
7ad45cca258711 Sidhartha Kumar 2024-06-04  4230  		mas_wr_slot_store(wr_mas);
7ad45cca258711 Sidhartha Kumar 2024-06-04  4231  		break;
7ad45cca258711 Sidhartha Kumar 2024-06-04  4232  	case wr_node_store:
7ad45cca258711 Sidhartha Kumar 2024-06-04  4233  		mas_wr_node_store(wr_mas, new_end);
7ad45cca258711 Sidhartha Kumar 2024-06-04  4234  		break;
7ad45cca258711 Sidhartha Kumar 2024-06-04  4235  	case wr_spanning_store:
54a611b605901c Liam R. Howlett 2022-09-06  4236  		mas_wr_spanning_store(wr_mas);
7ad45cca258711 Sidhartha Kumar 2024-06-04  4237  		break;
7ad45cca258711 Sidhartha Kumar 2024-06-04  4238  	case wr_split_store:
7ad45cca258711 Sidhartha Kumar 2024-06-04  4239  	case wr_rebalance:
7ad45cca258711 Sidhartha Kumar 2024-06-04  4240  	case wr_bnode:
7ad45cca258711 Sidhartha Kumar 2024-06-04  4241  		mas_wr_bnode(wr_mas);
7ad45cca258711 Sidhartha Kumar 2024-06-04  4242  		break;
54a611b605901c Liam R. Howlett 2022-09-06  4243  	}
54a611b605901c Liam R. Howlett 2022-09-06  4244  
54a611b605901c Liam R. Howlett 2022-09-06  4245  	return wr_mas->content;
54a611b605901c Liam R. Howlett 2022-09-06  4246  }
54a611b605901c Liam R. Howlett 2022-09-06  4247
diff mbox series

Patch

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index abd2f396bb1e..20e9d13c2980 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -4206,27 +4206,42 @@  static inline void mas_wr_modify(struct ma_wr_state *wr_mas)
 static inline void *mas_wr_store_entry(struct ma_wr_state *wr_mas)
 {
 	struct ma_state *mas = wr_mas->mas;
+	unsigned char new_end = mas_wr_new_end(wr_mas);
 
-	wr_mas->content = mas_start(mas);
-	if (mas_is_none(mas) || mas_is_ptr(mas)) {
+	switch (mas->store_type) {
+	case wr_invalid:
+		MT_BUG_ON(mas->tree, 1);
+		return NULL;
+	case wr_new_root:
+		mas_new_root(mas, wr_mas->entry);
+		break;
+	case wr_store_root:
 		mas_store_root(mas, wr_mas->entry);
-		return wr_mas->content;
-	}
-
-	if (unlikely(!mas_wr_walk(wr_mas))) {
+		break;
+	case wr_exact_fit:
+		rcu_assign_pointer(wr_mas->slots[mas->offset], wr_mas->entry);
+		if (!!wr_mas->entry ^ !!wr_mas->content)
+			mas_update_gap(mas);
+		break;
+	case wr_append:
+		mas_wr_append(wr_mas, new_end);
+		break;
+	case wr_slot_store:
+		mas_wr_slot_store(wr_mas);
+		break;
+	case wr_node_store:
+		mas_wr_node_store(wr_mas, new_end);
+		break;
+	case wr_spanning_store:
 		mas_wr_spanning_store(wr_mas);
-		return wr_mas->content;
-	}
-
-	/* At this point, we are at the leaf node that needs to be altered. */
-	mas_wr_end_piv(wr_mas);
-	/* New root for a single pointer */
-	if (unlikely(!mas->index && mas->last == ULONG_MAX)) {
-		mas_new_root(mas, wr_mas->entry);
-		return wr_mas->content;
+		break;
+	case wr_split_store:
+	case wr_rebalance:
+	case wr_bnode:
+		mas_wr_bnode(wr_mas);
+		break;
 	}
 
-	mas_wr_modify(wr_mas);
 	return wr_mas->content;
 }