* [PATCH 0/2] Following cleanup after introduce mas_wr_store_type()
@ 2024-10-16 0:22 Wei Yang
2024-10-16 0:22 ` [PATCH 1/2] maple_tree: calculate new_end when needed Wei Yang
2024-10-16 0:22 ` [PATCH 2/2] maple_tree: remove sanity check from mas_wr_slot_store() Wei Yang
0 siblings, 2 replies; 7+ messages in thread
From: Wei Yang @ 2024-10-16 0:22 UTC (permalink / raw)
To: akpm, Liam.Howlett; +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().
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(-)
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] maple_tree: calculate new_end when needed
2024-10-16 0:22 [PATCH 0/2] Following cleanup after introduce mas_wr_store_type() Wei Yang
@ 2024-10-16 0:22 ` Wei Yang
2024-10-16 14:28 ` Sid Kumar
2024-10-16 15:04 ` Liam R. Howlett
2024-10-16 0:22 ` [PATCH 2/2] maple_tree: remove sanity check from mas_wr_slot_store() Wei Yang
1 sibling, 2 replies; 7+ messages in thread
From: Wei Yang @ 2024-10-16 0:22 UTC (permalink / raw)
To: akpm, Liam.Howlett
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>
---
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 61de8f1daee8..f2628e3f3efc 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -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)) {
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] maple_tree: remove sanity check from mas_wr_slot_store()
2024-10-16 0:22 [PATCH 0/2] Following cleanup after introduce mas_wr_store_type() Wei Yang
2024-10-16 0:22 ` [PATCH 1/2] maple_tree: calculate new_end when needed Wei Yang
@ 2024-10-16 0:22 ` Wei Yang
2024-10-16 14:41 ` Sid Kumar
2024-10-16 15:06 ` Liam R. Howlett
1 sibling, 2 replies; 7+ messages in thread
From: Wei Yang @ 2024-10-16 0:22 UTC (permalink / raw)
To: akpm, Liam.Howlett
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>
---
lib/maple_tree.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index f2628e3f3efc..5dfc589a8cde 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -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);
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] maple_tree: calculate new_end when needed
2024-10-16 0:22 ` [PATCH 1/2] maple_tree: calculate new_end when needed Wei Yang
@ 2024-10-16 14:28 ` Sid Kumar
2024-10-16 15:04 ` Liam R. Howlett
1 sibling, 0 replies; 7+ messages in thread
From: Sid Kumar @ 2024-10-16 14:28 UTC (permalink / raw)
To: Wei Yang, akpm, Liam.Howlett; +Cc: maple-tree, linux-mm, Lorenzo Stoakes
On 10/15/24 8:22 PM, Wei Yang wrote:
> 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>
> ---
> 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 61de8f1daee8..f2628e3f3efc 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -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)) {
Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] maple_tree: remove sanity check from mas_wr_slot_store()
2024-10-16 0:22 ` [PATCH 2/2] maple_tree: remove sanity check from mas_wr_slot_store() Wei Yang
@ 2024-10-16 14:41 ` Sid Kumar
2024-10-16 15:06 ` Liam R. Howlett
1 sibling, 0 replies; 7+ messages in thread
From: Sid Kumar @ 2024-10-16 14:41 UTC (permalink / raw)
To: Wei Yang, akpm, Liam.Howlett; +Cc: maple-tree, linux-mm, Lorenzo Stoakes
On 10/15/24 8:22 PM, Wei Yang wrote:
> 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>
> ---
> lib/maple_tree.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index f2628e3f3efc..5dfc589a8cde 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -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
> + } 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);
Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] maple_tree: calculate new_end when needed
2024-10-16 0:22 ` [PATCH 1/2] maple_tree: calculate new_end when needed Wei Yang
2024-10-16 14:28 ` Sid Kumar
@ 2024-10-16 15:04 ` Liam R. Howlett
1 sibling, 0 replies; 7+ messages in thread
From: Liam R. Howlett @ 2024-10-16 15:04 UTC (permalink / raw)
To: Wei Yang; +Cc: akpm, maple-tree, linux-mm, Sidhartha Kumar, Lorenzo Stoakes
* Wei Yang <richard.weiyang@gmail.com> [241015 20:22]:
> 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>
Too bad these were missed in the review of the patches.
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 61de8f1daee8..f2628e3f3efc 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -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)) {
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] maple_tree: remove sanity check from mas_wr_slot_store()
2024-10-16 0:22 ` [PATCH 2/2] maple_tree: remove sanity check from mas_wr_slot_store() Wei Yang
2024-10-16 14:41 ` Sid Kumar
@ 2024-10-16 15:06 ` Liam R. Howlett
1 sibling, 0 replies; 7+ messages in thread
From: Liam R. Howlett @ 2024-10-16 15:06 UTC (permalink / raw)
To: Wei Yang; +Cc: akpm, maple-tree, linux-mm, Sidhartha Kumar, Lorenzo Stoakes
* Wei Yang <richard.weiyang@gmail.com> [241015 20:22]:
> 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>
> ---
> lib/maple_tree.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index f2628e3f3efc..5dfc589a8cde 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -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.
> /*
> * 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);
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-10-16 15:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-16 0:22 [PATCH 0/2] Following cleanup after introduce mas_wr_store_type() Wei Yang
2024-10-16 0:22 ` [PATCH 1/2] maple_tree: calculate new_end when needed Wei Yang
2024-10-16 14:28 ` Sid Kumar
2024-10-16 15:04 ` Liam R. Howlett
2024-10-16 0:22 ` [PATCH 2/2] maple_tree: remove sanity check from mas_wr_slot_store() Wei Yang
2024-10-16 14:41 ` Sid Kumar
2024-10-16 15:06 ` 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