* [PATCH] maple_tree: remove conditionals to detect wr_node_store
@ 2024-10-09 15:20 Sidhartha Kumar
2024-10-10 0:02 ` Liam R. Howlett
2024-10-10 6:28 ` Wei Yang
0 siblings, 2 replies; 5+ messages in thread
From: Sidhartha Kumar @ 2024-10-09 15:20 UTC (permalink / raw)
To: linux-kernel, maple-tree
Cc: linux-mm, akpm, liam.howlett, willy, richard.weiyang, Sidhartha
From: Sidhartha <sidhartha.kumar@oracle.com>
In mas_wr_store_type(), we check if new_end < mt_slots[wr_mas->type]. If
this check fails, we know that ,after this, new_end is >= mt_min_slots.
Checking this again when we detect a wr_node_store later in the function
is reduntant. Because this check is part of an OR statement, the statement
will always evaluate to true, therefore we can just get rid of it.
Suggested-by; Wei Yang <richard.weiyang@gmail.com>
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
lib/maple_tree.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 4b423330d83c..f5a12d37b352 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -4252,14 +4252,7 @@ static inline void mas_wr_store_type(struct ma_wr_state *wr_mas)
return;
}
- if (mte_is_root(mas->node) || (new_end >= mt_min_slots[wr_mas->type]) ||
- (mas->mas_flags & MA_STATE_BULK)) {
- mas->store_type = wr_node_store;
- return;
- }
-
- mas->store_type = wr_invalid;
- MAS_WARN_ON(mas, 1);
+ mas->store_type = wr_node_store;
}
/**
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] maple_tree: remove conditionals to detect wr_node_store
2024-10-09 15:20 [PATCH] maple_tree: remove conditionals to detect wr_node_store Sidhartha Kumar
@ 2024-10-10 0:02 ` Liam R. Howlett
2024-10-10 1:29 ` Liam R. Howlett
2024-10-10 6:28 ` Wei Yang
1 sibling, 1 reply; 5+ messages in thread
From: Liam R. Howlett @ 2024-10-10 0:02 UTC (permalink / raw)
To: Sidhartha Kumar
Cc: linux-kernel, maple-tree, linux-mm, akpm, willy, richard.weiyang
* Sidhartha Kumar <sidhartha.kumar@oracle.com> [241009 11:20]:
> From: Sidhartha <sidhartha.kumar@oracle.com>
>
> In mas_wr_store_type(), we check if new_end < mt_slots[wr_mas->type]. If
> this check fails, we know that ,after this, new_end is >= mt_min_slots.
> Checking this again when we detect a wr_node_store later in the function
> is reduntant. Because this check is part of an OR statement, the statement
> will always evaluate to true, therefore we can just get rid of it.
>
> Suggested-by; Wei Yang <richard.weiyang@gmail.com>
> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> ---
> lib/maple_tree.c | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 4b423330d83c..f5a12d37b352 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -4252,14 +4252,7 @@ static inline void mas_wr_store_type(struct ma_wr_state *wr_mas)
> return;
> }
>
> - if (mte_is_root(mas->node) || (new_end >= mt_min_slots[wr_mas->type]) ||
> - (mas->mas_flags & MA_STATE_BULK)) {
Although this will be evaluated as true due to the new_end having at
least the minimum data, it points out that MA_STATE_BULK is not being
evaluated correctly in the new_end < min case.
That is, we will rebalance if we are in MA_STATE_BULK mode without
meeting the sufficient data mark - which is not correct.
> - mas->store_type = wr_node_store;
> - return;
> - }
> -
> - mas->store_type = wr_invalid;
> - MAS_WARN_ON(mas, 1);
> + mas->store_type = wr_node_store;
> }
>
> /**
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] maple_tree: remove conditionals to detect wr_node_store
2024-10-10 0:02 ` Liam R. Howlett
@ 2024-10-10 1:29 ` Liam R. Howlett
0 siblings, 0 replies; 5+ messages in thread
From: Liam R. Howlett @ 2024-10-10 1:29 UTC (permalink / raw)
To: Sidhartha Kumar, linux-kernel, maple-tree, linux-mm, akpm, willy,
richard.weiyang
* Liam R. Howlett <Liam.Howlett@oracle.com> [241009 20:02]:
> * Sidhartha Kumar <sidhartha.kumar@oracle.com> [241009 11:20]:
> > From: Sidhartha <sidhartha.kumar@oracle.com>
> >
> > In mas_wr_store_type(), we check if new_end < mt_slots[wr_mas->type]. If
> > this check fails, we know that ,after this, new_end is >= mt_min_slots.
> > Checking this again when we detect a wr_node_store later in the function
> > is reduntant. Because this check is part of an OR statement, the statement
> > will always evaluate to true, therefore we can just get rid of it.
> >
> > Suggested-by; Wei Yang <richard.weiyang@gmail.com>
> > Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> > ---
> > lib/maple_tree.c | 9 +--------
> > 1 file changed, 1 insertion(+), 8 deletions(-)
> >
> > diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> > index 4b423330d83c..f5a12d37b352 100644
> > --- a/lib/maple_tree.c
> > +++ b/lib/maple_tree.c
> > @@ -4252,14 +4252,7 @@ static inline void mas_wr_store_type(struct ma_wr_state *wr_mas)
> > return;
> > }
> >
> > - if (mte_is_root(mas->node) || (new_end >= mt_min_slots[wr_mas->type]) ||
> > - (mas->mas_flags & MA_STATE_BULK)) {
>
> Although this will be evaluated as true due to the new_end having at
> least the minimum data, it points out that MA_STATE_BULK is not being
> evaluated correctly in the new_end < min case.
>
> That is, we will rebalance if we are in MA_STATE_BULK mode without
> meeting the sufficient data mark - which is not correct.
Reading through this function, it would be much cleaner to return the
enum from the function and assign it in the caller.
>
> > - mas->store_type = wr_node_store;
> > - return;
> > - }
> > -
> > - mas->store_type = wr_invalid;
> > - MAS_WARN_ON(mas, 1);
> > + mas->store_type = wr_node_store;
> > }
> >
> > /**
> > --
> > 2.43.0
> >
>
> --
> maple-tree mailing list
> maple-tree@lists.infradead.org
> https://lists.infradead.org/mailman/listinfo/maple-tree
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] maple_tree: remove conditionals to detect wr_node_store
2024-10-09 15:20 [PATCH] maple_tree: remove conditionals to detect wr_node_store Sidhartha Kumar
2024-10-10 0:02 ` Liam R. Howlett
@ 2024-10-10 6:28 ` Wei Yang
2024-10-10 17:16 ` Liam R. Howlett
1 sibling, 1 reply; 5+ messages in thread
From: Wei Yang @ 2024-10-10 6:28 UTC (permalink / raw)
To: Sidhartha Kumar
Cc: linux-kernel, maple-tree, linux-mm, akpm, liam.howlett, willy,
richard.weiyang
On Wed, Oct 09, 2024 at 11:20:07AM -0400, Sidhartha Kumar wrote:
>From: Sidhartha <sidhartha.kumar@oracle.com>
>
>In mas_wr_store_type(), we check if new_end < mt_slots[wr_mas->type]. If
>this check fails, we know that ,after this, new_end is >= mt_min_slots.
>Checking this again when we detect a wr_node_store later in the function
>is reduntant. Because this check is part of an OR statement, the statement
>will always evaluate to true, therefore we can just get rid of it.
>
>Suggested-by; Wei Yang <richard.weiyang@gmail.com>
>Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
>---
> lib/maple_tree.c | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
>diff --git a/lib/maple_tree.c b/lib/maple_tree.c
>index 4b423330d83c..f5a12d37b352 100644
>--- a/lib/maple_tree.c
>+++ b/lib/maple_tree.c
>@@ -4252,14 +4252,7 @@ static inline void mas_wr_store_type(struct ma_wr_state *wr_mas)
> return;
> }
>
>- if (mte_is_root(mas->node) || (new_end >= mt_min_slots[wr_mas->type]) ||
>- (mas->mas_flags & MA_STATE_BULK)) {
>- mas->store_type = wr_node_store;
>- return;
>- }
>-
>- mas->store_type = wr_invalid;
>- MAS_WARN_ON(mas, 1);
If my understanding is correct, here is the only place we assign wr_invalid.
So maybe we can remove this definition?
>+ mas->store_type = wr_node_store;
> }
>
> /**
>--
>2.43.0
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] maple_tree: remove conditionals to detect wr_node_store
2024-10-10 6:28 ` Wei Yang
@ 2024-10-10 17:16 ` Liam R. Howlett
0 siblings, 0 replies; 5+ messages in thread
From: Liam R. Howlett @ 2024-10-10 17:16 UTC (permalink / raw)
To: Wei Yang; +Cc: Sidhartha Kumar, linux-kernel, maple-tree, linux-mm, akpm, willy
* Wei Yang <richard.weiyang@gmail.com> [241010 02:28]:
> On Wed, Oct 09, 2024 at 11:20:07AM -0400, Sidhartha Kumar wrote:
> >From: Sidhartha <sidhartha.kumar@oracle.com>
> >
> >In mas_wr_store_type(), we check if new_end < mt_slots[wr_mas->type]. If
> >this check fails, we know that ,after this, new_end is >= mt_min_slots.
> >Checking this again when we detect a wr_node_store later in the function
> >is reduntant. Because this check is part of an OR statement, the statement
> >will always evaluate to true, therefore we can just get rid of it.
> >
> >Suggested-by; Wei Yang <richard.weiyang@gmail.com>
> >Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> >---
> > lib/maple_tree.c | 9 +--------
> > 1 file changed, 1 insertion(+), 8 deletions(-)
> >
> >diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> >index 4b423330d83c..f5a12d37b352 100644
> >--- a/lib/maple_tree.c
> >+++ b/lib/maple_tree.c
> >@@ -4252,14 +4252,7 @@ static inline void mas_wr_store_type(struct ma_wr_state *wr_mas)
> > return;
> > }
> >
> >- if (mte_is_root(mas->node) || (new_end >= mt_min_slots[wr_mas->type]) ||
> >- (mas->mas_flags & MA_STATE_BULK)) {
> >- mas->store_type = wr_node_store;
> >- return;
> >- }
> >-
> >- mas->store_type = wr_invalid;
> >- MAS_WARN_ON(mas, 1);
>
> If my understanding is correct, here is the only place we assign wr_invalid.
>
> So maybe we can remove this definition?
No. This needs to exist to catch incorrect uses of the API, at the very
least. I am not pleased that we aren't able to fall through to setting
this to catch missed settings with this code today.
We are now just assuming we got things right. Any mistakes will show up
as an out-of-memory issues with writes to the tree. It will be much
harder to track down what went wrong.
Currently it is set in the header as the default store type and should
remain for that use, at the very least.
>
> >+ mas->store_type = wr_node_store;
> > }
> >
> > /**
> >--
> >2.43.0
>
> --
> Wei Yang
> Help you, Help me
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-10-10 17:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-09 15:20 [PATCH] maple_tree: remove conditionals to detect wr_node_store Sidhartha Kumar
2024-10-10 0:02 ` Liam R. Howlett
2024-10-10 1:29 ` Liam R. Howlett
2024-10-10 6:28 ` Wei Yang
2024-10-10 17:16 ` 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