linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Following cleanup after introduce mas_wr_store_type()
@ 2024-10-17  1:58 Wei Yang
  2024-10-17  1:58 ` [PATCH v2 1/2] maple_tree: calculate new_end when needed Wei Yang
  2024-10-17  1:58 ` [PATCH v2 2/2] maple_tree: remove sanity check from mas_wr_slot_store() Wei Yang
  0 siblings, 2 replies; 4+ messages in thread
From: Wei Yang @ 2024-10-17  1:58 UTC (permalink / raw)
  To: Liam.Howlett, akpm; +Cc: maple-tree, linux-mm, Wei Yang

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

-- 
2.34.1



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

* [PATCH v2 1/2] maple_tree: calculate new_end when needed
  2024-10-17  1:58 [PATCH v2 0/2] Following cleanup after introduce mas_wr_store_type() Wei Yang
@ 2024-10-17  1:58 ` Wei Yang
  2024-10-17  1:58 ` [PATCH v2 2/2] maple_tree: remove sanity check from mas_wr_slot_store() Wei Yang
  1 sibling, 0 replies; 4+ messages in thread
From: Wei Yang @ 2024-10-17  1:58 UTC (permalink / raw)
  To: Liam.Howlett, akpm
  Cc: maple-tree, linux-mm, Wei Yang, Liam R . Howlett,
	Sidhartha Kumar, Lorenzo Stoakes

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

Let's postpone it until necessary.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
---
 lib/maple_tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 511afb8ad1dc..b26f8df09588 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -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)) {
-- 
2.34.1



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

* [PATCH v2 2/2] maple_tree: remove sanity check from mas_wr_slot_store()
  2024-10-17  1:58 [PATCH v2 0/2] Following cleanup after introduce mas_wr_store_type() Wei Yang
  2024-10-17  1:58 ` [PATCH v2 1/2] maple_tree: calculate new_end when needed Wei Yang
@ 2024-10-17  1:58 ` Wei Yang
  2024-10-17  2:04   ` Liam R. Howlett
  1 sibling, 1 reply; 4+ messages in thread
From: Wei Yang @ 2024-10-17  1:58 UTC (permalink / raw)
  To: Liam.Howlett, akpm
  Cc: maple-tree, linux-mm, Wei Yang, Liam R . Howlett,
	Sidhartha Kumar, Lorenzo Stoakes

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

Let's remove it.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>

---
v2: add a WARN_ON_ONCE() as suggested by Liam
---
 lib/maple_tree.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index b26f8df09588..54dd0e256315 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -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);
-- 
2.34.1



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

* Re: [PATCH v2 2/2] maple_tree: remove sanity check from mas_wr_slot_store()
  2024-10-17  1:58 ` [PATCH v2 2/2] maple_tree: remove sanity check from mas_wr_slot_store() Wei Yang
@ 2024-10-17  2:04   ` Liam R. Howlett
  0 siblings, 0 replies; 4+ messages in thread
From: Liam R. Howlett @ 2024-10-17  2:04 UTC (permalink / raw)
  To: Wei Yang; +Cc: akpm, maple-tree, linux-mm, Sidhartha Kumar, Lorenzo Stoakes

* Wei Yang <richard.weiyang@gmail.com> [241016 21:58]:
> After commit 5d659bbb52a2 ("maple_tree: introduce mas_wr_store_type()"),
> the check here is redundant.
> 
> Let's remove it.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
> CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>

Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>

> 
> ---
> v2: add a WARN_ON_ONCE() as suggested by Liam
> ---
>  lib/maple_tree.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index b26f8df09588..54dd0e256315 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -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);
> -- 
> 2.34.1
> 


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

end of thread, other threads:[~2024-10-17  2:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-17  1:58 [PATCH v2 0/2] Following cleanup after introduce mas_wr_store_type() Wei Yang
2024-10-17  1:58 ` [PATCH v2 1/2] maple_tree: calculate new_end when needed Wei Yang
2024-10-17  1:58 ` [PATCH v2 2/2] maple_tree: remove sanity check from mas_wr_slot_store() Wei Yang
2024-10-17  2:04   ` Liam R. Howlett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox