Skip to contentSkip to conversation

Following cleanup after introduce mas_wr_store_type()

PATCH Superseded Wei Yang 3 participants 7 messages Oct 16, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

cover Following cleanup after introduce mas_wr_store_type()

Here is two cleanup after introduction of mas_wr_store_type().

Patch 1 postpone new_end calculation when needed.

Patch 2 remove a unnecessary sanity check in mas_wr_slot_store().

Wei Yang (2):
maple_tree: calculate new_end when needed
maple_tree: remove sanity check from mas_wr_slot_store()

 lib/maple_tree.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/2 maple_tree: calculate new_end when needed

For wr_exact_fit/wr_new_root, we don't need to calculate new_end.

Let's postpone it until necessary.

CC Liam R. Howlett <[email protected]>
CC Sidhartha Kumar <[email protected]>
CC Lorenzo Stoakes <[email protected]>
---
 lib/maple_tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/maple_tree.c +1 -1
index 61de8f1daee8..f2628e3f3efc 100644
@@ -4122,7 +4122,6 @@ static inline void mas_wr_store_type(struct ma_wr_state *wr_mas)
 	if (!wr_mas->entry)
 		mas_wr_extend_null(wr_mas);
 
-	new_end = mas_wr_new_end(wr_mas);
 	if ((wr_mas->r_min == mas->index) && (wr_mas->r_max == mas->last)) {
 		mas->store_type = wr_exact_fit;
 		return;
@@ -4133,6 +4132,7 @@ static inline void mas_wr_store_type(struct ma_wr_state *wr_mas)
 		return;
 	}
 
+	new_end = mas_wr_new_end(wr_mas);
 	/* Potential spanning rebalance collapsing a node */
 	if (new_end < mt_min_slots[wr_mas->type]) {
 		if (!mte_is_root(mas->node)) {
Signature · 1 line
2.34.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] maple_tree: calculate new_end when needed

Quoted 25 lines · Wei Yang

For wr_exact_fit/wr_new_root, we don't need to calculate new_end.

Let's postpone it until necessary.

CC Liam R. Howlett <[email protected]>
CC Sidhartha Kumar <[email protected]>
CC Lorenzo Stoakes <[email protected]>
---
  lib/maple_tree.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/maple_tree.c +0 -1
index 61de8f1daee8..f2628e3f3efc 100644
@@ -4122,7 +4122,6 @@ static inline void mas_wr_store_type(struct ma_wr_state *wr_mas)
  	if (!wr_mas->entry)
  		mas_wr_extend_null(wr_mas);
 
-	new_end = mas_wr_new_end(wr_mas);
  	if ((wr_mas->r_min == mas->index) && (wr_mas->r_max == mas->last)) {
  		mas->store_type = wr_exact_fit;
  		return;

lib/maple_tree.c static inline void mas_wr_store_type(struct ma_wr_state *wr_mas) · line 4138

Quoted 7 lines
lib/maple_tree.c +1 -0
@@ -4133,6 +4132,7 @@ static inline void mas_wr_store_type(struct ma_wr_state *wr_mas)
  		return;
  	}
 
+	new_end = mas_wr_new_end(wr_mas);
  	/* Potential spanning rebalance collapsing a node */
  	if (new_end < mt_min_slots[wr_mas->type]) {
  		if (!mte_is_root(mas->node)) {
Reviewed-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] maple_tree: calculate new_end when needed

In reply to Wei Yang
Quoted 8 lines · Wei Yang

For wr_exact_fit/wr_new_root, we don't need to calculate new_end.

Let's postpone it until necessary.

CC Liam R. Howlett <[email protected]>
CC Sidhartha Kumar <[email protected]>
CC Lorenzo Stoakes <[email protected]>

Too bad these were missed in the review of the patches.

Quoted 27 lines
---
 lib/maple_tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/maple_tree.c +1 -1
index 61de8f1daee8..f2628e3f3efc 100644
@@ -4122,7 +4122,6 @@ static inline void mas_wr_store_type(struct ma_wr_state *wr_mas)
 	if (!wr_mas->entry)
 		mas_wr_extend_null(wr_mas);
 
-	new_end = mas_wr_new_end(wr_mas);
 	if ((wr_mas->r_min == mas->index) && (wr_mas->r_max == mas->last)) {
 		mas->store_type = wr_exact_fit;
 		return;
@@ -4133,6 +4132,7 @@ static inline void mas_wr_store_type(struct ma_wr_state *wr_mas)
 		return;
 	}
 
+	new_end = mas_wr_new_end(wr_mas);
 	/* Potential spanning rebalance collapsing a node */
 	if (new_end < mt_min_slots[wr_mas->type]) {
 		if (!mte_is_root(mas->node)) {
Signature · 1 line
2.34.1
author
#4 lore raw

PATCH 2/2 maple_tree: remove sanity check from mas_wr_slot_store()

In reply to Wei Yang

After commit 5d659bbb52a2 ("maple_tree: introduce mas_wr_store_type()"), the check here is redundant.

Let's remove it.

CC Liam R. Howlett <[email protected]>
CC Sidhartha Kumar <[email protected]>
CC Lorenzo Stoakes <[email protected]>
---
 lib/maple_tree.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
lib/maple_tree.c +1 -3
index f2628e3f3efc..5dfc589a8cde 100644
@@ -3810,7 +3810,7 @@ static inline void mas_wr_slot_store(struct ma_wr_state *wr_mas)
 			wr_mas->pivots[offset] = mas->index - 1;
 			mas->offset++; /* Keep mas accurate. */
 		}
-	} else if (!mt_in_rcu(mas->tree)) {
+	} else {
 		/*
 		 * Expand the range, only partially overwriting the previous and
 		 * next ranges
@@ -3820,8 +3820,6 @@ static inline void mas_wr_slot_store(struct ma_wr_state *wr_mas)
 		wr_mas->pivots[offset] = mas->index - 1;
 		wr_mas->pivots[offset + 1] = mas->last;
 		mas->offset++; /* Keep mas accurate. */
-	} else {
-		return;
 	}
 
 	trace_ma_write(__func__, mas, 0, wr_mas->entry);
Signature · 1 line
2.34.1
Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] maple_tree: remove sanity check from mas_wr_slot_store()

Quoted 18 lines · Wei Yang

After commit 5d659bbb52a2 ("maple_tree: introduce mas_wr_store_type()"), the check here is redundant.

Let's remove it.

CC Liam R. Howlett <[email protected]>
CC Sidhartha Kumar <[email protected]>
CC Lorenzo Stoakes <[email protected]>
---
  lib/maple_tree.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
lib/maple_tree.c +0 -0
index f2628e3f3efc..5dfc589a8cde 100644

lib/maple_tree.c static inline void mas_wr_slot_store(struct ma_wr_state *wr_mas) · line 3813

Quoted 4 lines
lib/maple_tree.c +0 -1
@@ -3810,7 +3810,7 @@ static inline void mas_wr_slot_store(struct ma_wr_state *wr_mas)
  			wr_mas->pivots[offset] = mas->index - 1;
  			mas->offset++; /* Keep mas accurate. */
  		}
-	} else if (!mt_in_rcu(mas->tree)) {

This means ((new_end == mas->end) && (!mt_in_rcu(mas->tree)) must be true so we know we are not in rcu mode at this point. So this makes sense

lib/maple_tree.c static inline void mas_wr_slot_store(struct ma_wr_state *wr_mas) · line 3825

Quoted 13 lines
lib/maple_tree.c +1 -2
+	} else {
  		/*
  		 * Expand the range, only partially overwriting the previous and
  		 * next ranges
@@ -3820,8 +3820,6 @@ static inline void mas_wr_slot_store(struct ma_wr_state *wr_mas)
  		wr_mas->pivots[offset] = mas->index - 1;
  		wr_mas->pivots[offset + 1] = mas->last;
  		mas->offset++; /* Keep mas accurate. */
-	} else {
-		return;
  	}
 
  	trace_ma_write(__func__, mas, 0, wr_mas->entry);
#6 lore raw

Re: [PATCH 2/2] maple_tree: remove sanity check from mas_wr_slot_store()

In reply to Wei Yang
Quoted 18 lines · Wei Yang

After commit 5d659bbb52a2 ("maple_tree: introduce mas_wr_store_type()"), the check here is redundant.

Let's remove it.

CC Liam R. Howlett <[email protected]>
CC Sidhartha Kumar <[email protected]>
CC Lorenzo Stoakes <[email protected]>
---
 lib/maple_tree.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
lib/maple_tree.c +0 -0
index f2628e3f3efc..5dfc589a8cde 100644

lib/maple_tree.c static inline void mas_wr_slot_store(struct ma_wr_state *wr_mas) · line 3813

Quoted 5 lines
lib/maple_tree.c +1 -1
@@ -3810,7 +3810,7 @@ static inline void mas_wr_slot_store(struct ma_wr_state *wr_mas)
 			wr_mas->pivots[offset] = mas->index - 1;
 			mas->offset++; /* Keep mas accurate. */
 		}
-	} else if (!mt_in_rcu(mas->tree)) {
+	} else {

It would be worth adding a WARN_ON_ONCE() in here in case something changes in the code paths.

Quoted 15 lines
lib/maple_tree.c +0 -2
 		/*
 		 * Expand the range, only partially overwriting the previous and
 		 * next ranges
@@ -3820,8 +3820,6 @@ static inline void mas_wr_slot_store(struct ma_wr_state *wr_mas)
 		wr_mas->pivots[offset] = mas->index - 1;
 		wr_mas->pivots[offset + 1] = mas->last;
 		mas->offset++; /* Keep mas accurate. */
-	} else {
-		return;
 	}
 
 	trace_ma_write(__func__, mas, 0, wr_mas->entry);
Signature · 1 line
2.34.1