Reduce the space to be cleared for maple_big_node
Subsystems (3)
v2 cover Reduce the space to be cleared for maple_big_node
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(-)
Signature · 1 line
2.34.1
PATCH v2 1/2 maple_tree: remove maple_big_node.parent
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.
--- lib/maple_tree.c | 1 - 1 file changed, 1 deletion(-)
lib/maple_tree.c +0 -1
@@ -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 ];
Signature · 1 line
2.34.1
Re: [PATCH v2 1/2] maple_tree: remove maple_big_node.parent
Quoted 7 lines · Wei Yang
The member parent of
maple_big_nodeis never used.Let's remove it which could reduce the number of space to be cleared on memset.
Signed-off-by Wei Yang <[email protected]>CC Liam R. Howlett <[email protected]>
Quoted 19 lines
--- lib/maple_tree.c | 1 - 1 file changed, 1 deletion(-)lib/maple_tree.c +0
-1@@ -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 ];Signature · 1 line
2.34.1
PATCH v2 2/2 maple_tree: memset maple_big_node as a whole
In reply to Wei YangIn 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.
---
v2: correct the change log on clearing all maple_big_node currently
--- lib/maple_tree.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
lib/maple_tree.c +1 -4
@@ -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;
Signature · 1 line
2.34.1
Re: [PATCH v2 2/2] maple_tree: memset maple_big_node as a whole
Quoted 11 lines · Wei Yang
In function
mast_fill_bnode(), we first clear some fields ofmaple_big_nodeand set the 'type' unconditionally before return. This means we won't leverage any information inmaple_big_nodeand 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:
Quoted 8 lines
MAPLE_BIG_NODE_SLOTis 34
MAPLE_BIG_NODE_GAPis 21With 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 <[email protected]>CC Liam R. Howlett <[email protected]>
Quoted 3 lines
---
v2: correct the change log on clearing allmaple_big_nodecurrently
Thanks!
Quoted 23 lines
--- lib/maple_tree.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)lib/maple_tree.c +1
-4@@ -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;Signature · 1 line
2.34.1
Hi, Andrew,
I don't see the notification on picking this in unstable/stable.
May I ask would it be picked up?
Quoted 17 lines · Wei Yang
Found current code may clear
maple_big_noderedundantly.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_bnodeclear 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: memsetmaple_big_nodeas a whole
lib/maple_tree.c| 6 +-----1 file changed, 1 insertion(+), 5 deletions(-)Signature · 1 line
2.34.1
Signature · 2 lines
Wei Yang Help you, Help me