* [PATCH v2 0/2] Reduce the space to be cleared for maple_big_node
@ 2024-09-08 14:05 Wei Yang
2024-09-08 14:05 ` [PATCH v2 1/2] maple_tree: remove maple_big_node.parent Wei Yang
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Wei Yang @ 2024-09-08 14:05 UTC (permalink / raw)
To: akpm, Liam.Howlett; +Cc: maple-tree, linux-mm, Wei Yang
Found current code may clear maple_big_node redundantly.
First we define a filed parent, which is never used. After removing this, we
reduce the size of memory to be clear on memset.
Then mast_fill_bnode clear part of the structure twice, since slot and gap
shares some space. By clearing the whole structure, we can avoid it.
Wei Yang (2):
maple_tree: remove maple_big_node.parent
maple_tree: memset maple_big_node as a whole
lib/maple_tree.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] maple_tree: remove maple_big_node.parent
2024-09-08 14:05 [PATCH v2 0/2] Reduce the space to be cleared for maple_big_node Wei Yang
@ 2024-09-08 14:05 ` Wei Yang
2024-09-11 0:35 ` Liam R. Howlett
2024-09-08 14:05 ` [PATCH v2 2/2] maple_tree: memset maple_big_node as a whole Wei Yang
2024-09-25 2:45 ` [PATCH v2 0/2] Reduce the space to be cleared for maple_big_node Wei Yang
2 siblings, 1 reply; 6+ messages in thread
From: Wei Yang @ 2024-09-08 14:05 UTC (permalink / raw)
To: akpm, Liam.Howlett; +Cc: maple-tree, linux-mm, Wei Yang, Liam R . Howlett
The member parent of maple_big_node is never used.
Let's remove it which could reduce the number of space to be cleared on
memset.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
---
lib/maple_tree.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 4e08dd5e391b..c3370c7449c2 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -120,7 +120,6 @@ static const unsigned char mt_min_slots[] = {
#define MAPLE_BIG_NODE_GAPS (MAPLE_ARANGE64_SLOTS * 2 + 1)
struct maple_big_node {
- struct maple_pnode *parent;
unsigned long pivot[MAPLE_BIG_NODE_SLOTS - 1];
union {
struct maple_enode *slot[MAPLE_BIG_NODE_SLOTS];
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] maple_tree: memset maple_big_node as a whole
2024-09-08 14:05 [PATCH v2 0/2] Reduce the space to be cleared for maple_big_node Wei Yang
2024-09-08 14:05 ` [PATCH v2 1/2] maple_tree: remove maple_big_node.parent Wei Yang
@ 2024-09-08 14:05 ` Wei Yang
2024-09-11 0:36 ` Liam R. Howlett
2024-09-25 2:45 ` [PATCH v2 0/2] Reduce the space to be cleared for maple_big_node Wei Yang
2 siblings, 1 reply; 6+ messages in thread
From: Wei Yang @ 2024-09-08 14:05 UTC (permalink / raw)
To: akpm, Liam.Howlett; +Cc: maple-tree, linux-mm, Wei Yang, Liam R . Howlett
In function mast_fill_bnode(), we first clear some fields of
maple_big_node and set the 'type' unconditionally before return. This
means we won't leverage any information in maple_big_node and it is safe
to clear the whole structure.
In maple_big_node, we define slot and padding/gap in a union. And based
on current definition of MAPLE_BIG_NODE_SLOTS/GAPS, padding is always
less than slot and part of the gap is overlapped by slot.
For example on 64bit system:
MAPLE_BIG_NODE_SLOT is 34
MAPLE_BIG_NODE_GAP is 21
With this knowledge, current code may clear some space by twice. And
this could be avoid by clearing the structure as a whole.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
---
v2: correct the change log on clearing all maple_big_node currently
---
lib/maple_tree.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index c3370c7449c2..b459fe1a3ebe 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -3134,10 +3134,7 @@ static inline void mast_fill_bnode(struct maple_subtree_state *mast,
bool cp = true;
unsigned char split;
- memset(mast->bn->gap, 0, sizeof(unsigned long) * ARRAY_SIZE(mast->bn->gap));
- memset(mast->bn->slot, 0, sizeof(unsigned long) * ARRAY_SIZE(mast->bn->slot));
- memset(mast->bn->pivot, 0, sizeof(unsigned long) * ARRAY_SIZE(mast->bn->pivot));
- mast->bn->b_end = 0;
+ memset(mast->bn, 0, sizeof(struct maple_big_node));
if (mte_is_root(mas->node)) {
cp = false;
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] maple_tree: remove maple_big_node.parent
2024-09-08 14:05 ` [PATCH v2 1/2] maple_tree: remove maple_big_node.parent Wei Yang
@ 2024-09-11 0:35 ` Liam R. Howlett
0 siblings, 0 replies; 6+ messages in thread
From: Liam R. Howlett @ 2024-09-11 0:35 UTC (permalink / raw)
To: Wei Yang; +Cc: akpm, maple-tree, linux-mm
* Wei Yang <richard.weiyang@gmail.com> [240908 10:06]:
> The member parent of maple_big_node is never used.
>
> Let's remove it which could reduce the number of space to be cleared on
> memset.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
> ---
> lib/maple_tree.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 4e08dd5e391b..c3370c7449c2 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -120,7 +120,6 @@ static const unsigned char mt_min_slots[] = {
> #define MAPLE_BIG_NODE_GAPS (MAPLE_ARANGE64_SLOTS * 2 + 1)
>
> struct maple_big_node {
> - struct maple_pnode *parent;
> unsigned long pivot[MAPLE_BIG_NODE_SLOTS - 1];
> union {
> struct maple_enode *slot[MAPLE_BIG_NODE_SLOTS];
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] maple_tree: memset maple_big_node as a whole
2024-09-08 14:05 ` [PATCH v2 2/2] maple_tree: memset maple_big_node as a whole Wei Yang
@ 2024-09-11 0:36 ` Liam R. Howlett
0 siblings, 0 replies; 6+ messages in thread
From: Liam R. Howlett @ 2024-09-11 0:36 UTC (permalink / raw)
To: Wei Yang; +Cc: akpm, maple-tree, linux-mm
* Wei Yang <richard.weiyang@gmail.com> [240908 10:06]:
> In function mast_fill_bnode(), we first clear some fields of
> maple_big_node and set the 'type' unconditionally before return. This
> means we won't leverage any information in maple_big_node and it is safe
> to clear the whole structure.
>
> In maple_big_node, we define slot and padding/gap in a union. And based
> on current definition of MAPLE_BIG_NODE_SLOTS/GAPS, padding is always
> less than slot and part of the gap is overlapped by slot.
>
> For example on 64bit system:
>
> MAPLE_BIG_NODE_SLOT is 34
> MAPLE_BIG_NODE_GAP is 21
>
> With this knowledge, current code may clear some space by twice. And
> this could be avoid by clearing the structure as a whole.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
>
> ---
> v2: correct the change log on clearing all maple_big_node currently
Thanks!
> ---
> lib/maple_tree.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index c3370c7449c2..b459fe1a3ebe 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -3134,10 +3134,7 @@ static inline void mast_fill_bnode(struct maple_subtree_state *mast,
> bool cp = true;
> unsigned char split;
>
> - memset(mast->bn->gap, 0, sizeof(unsigned long) * ARRAY_SIZE(mast->bn->gap));
> - memset(mast->bn->slot, 0, sizeof(unsigned long) * ARRAY_SIZE(mast->bn->slot));
> - memset(mast->bn->pivot, 0, sizeof(unsigned long) * ARRAY_SIZE(mast->bn->pivot));
> - mast->bn->b_end = 0;
> + memset(mast->bn, 0, sizeof(struct maple_big_node));
>
> if (mte_is_root(mas->node)) {
> cp = false;
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/2] Reduce the space to be cleared for maple_big_node
2024-09-08 14:05 [PATCH v2 0/2] Reduce the space to be cleared for maple_big_node Wei Yang
2024-09-08 14:05 ` [PATCH v2 1/2] maple_tree: remove maple_big_node.parent Wei Yang
2024-09-08 14:05 ` [PATCH v2 2/2] maple_tree: memset maple_big_node as a whole Wei Yang
@ 2024-09-25 2:45 ` Wei Yang
2 siblings, 0 replies; 6+ messages in thread
From: Wei Yang @ 2024-09-25 2:45 UTC (permalink / raw)
To: akpm; +Cc: Wei Yang, Liam.Howlett, maple-tree, linux-mm
Hi, Andrew,
I don't see the notification on picking this in unstable/stable.
May I ask would it be picked up?
On Sun, Sep 08, 2024 at 02:05:52PM +0000, Wei Yang wrote:
>Found current code may clear maple_big_node redundantly.
>
>First we define a filed parent, which is never used. After removing this, we
>reduce the size of memory to be clear on memset.
>
>Then mast_fill_bnode clear part of the structure twice, since slot and gap
>shares some space. By clearing the whole structure, we can avoid it.
>
>Wei Yang (2):
> maple_tree: remove maple_big_node.parent
> maple_tree: memset maple_big_node as a whole
>
> lib/maple_tree.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
>--
>2.34.1
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-09-25 2:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-08 14:05 [PATCH v2 0/2] Reduce the space to be cleared for maple_big_node Wei Yang
2024-09-08 14:05 ` [PATCH v2 1/2] maple_tree: remove maple_big_node.parent Wei Yang
2024-09-11 0:35 ` Liam R. Howlett
2024-09-08 14:05 ` [PATCH v2 2/2] maple_tree: memset maple_big_node as a whole Wei Yang
2024-09-11 0:36 ` Liam R. Howlett
2024-09-25 2:45 ` [PATCH v2 0/2] Reduce the space to be cleared for maple_big_node Wei Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox