Skip to contentSkip to conversation

Following cleanup after introduce mas_wr_store_type()

PATCH Applied Wei Yang 2 participants 4 messages Oct 17, 2024

Subsystems (3)
lore
Share & tools
lore

Wei Yang

author
#0 lore raw

v2 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().

v2: add a WARN_ON_ONCE() as suggested by Liam in patch 2

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

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

PATCH v2 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.

---
 lib/maple_tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/maple_tree.c +1 -1
index 511afb8ad1dc..b26f8df09588 100644
@@ -4117,7 +4117,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;
@@ -4128,6 +4127,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
#2 lore raw

PATCH v2 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]>

---
v2: add a WARN_ON_ONCE() as suggested by Liam

---
 lib/maple_tree.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
lib/maple_tree.c +2 -3
index b26f8df09588..54dd0e256315 100644
@@ -3805,7 +3805,8 @@ 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 {
+		WARN_ON_ONCE(mt_in_rcu(mas->tree));
 		/*
 		 * Expand the range, only partially overwriting the previous and
 		 * next ranges
@@ -3815,8 +3816,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 v2 2/2
#3 lore raw

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

Quoted 10 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]>
Quoted 33 lines

---
v2: add a WARN_ON_ONCE() as suggested by Liam

---
 lib/maple_tree.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
lib/maple_tree.c +2 -3
index b26f8df09588..54dd0e256315 100644
@@ -3805,7 +3805,8 @@ 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 {
+		WARN_ON_ONCE(mt_in_rcu(mas->tree));
 		/*
 		 * Expand the range, only partially overwriting the previous and
 		 * next ranges
@@ -3815,8 +3816,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