Skip to contentSkip to conversation

cleanup mast_split_data()

PATCH In review Wei Yang 2 participants 5 messages Sep 15, 2024 – Dec 5, 2024

Subsystems (3)
lore
Share & tools
lore

Wei Yang

author
#0 lore raw

cover cleanup mast_split_data()

There are two possible redundant code:

1. the left subtree's mas is set in mab_mas_cp()
2. the right subtree's pivot 0 would be set again in mab_mas_cp()

We can remove them.

Wei Yang (2):
maple_tree: the new max of left side subtree has been set
maple_tree: not necessary to set pivot 0 before mab_mas_cp()

 lib/maple_tree.c | 2 --
 1 file changed, 2 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/2 maple_tree: the new max of left side subtree has been set

The max value has been updated in mab_mas_cp() on copying the left part.

Not necessary to update it again.

---
 lib/maple_tree.c | 1 -
 1 file changed, 1 deletion(-)
lib/maple_tree.c +0 -1
index 75e294d97e51..31964c5c677a 100644
@@ -3177,7 +3177,6 @@ static inline void mast_split_data(struct maple_subtree_state *mast,
 	mte_set_pivot(mast->r->node, 0, mast->r->max);
 	mab_mas_cp(mast->bn, split + 1, mast->bn->b_end, mast->r, false);
 	mast->l->offset = mte_parent_slot(mas->node);
-	mast->l->max = mast->bn->pivot[split];
 	mast->r->min = mast->l->max + 1;
 	if (mte_is_leaf(mas->node))
 		return;
Signature · 1 line
2.34.1
#2 lore raw
In reply to Wei Yang
Quoted 6 lines · Wei Yang

There are two possible redundant code:

1. the left subtree's mas is set in mab_mas_cp()
2. the right subtree's pivot 0 would be set again in mab_mas_cp()

We can remove them.

Is there any measurable difference with these changes?

Quoted 11 lines

Wei Yang (2):
maple_tree: the new max of left side subtree has been set
maple_tree: not necessary to set pivot 0 before mab_mas_cp()

 lib/maple_tree.c | 2 --
 1 file changed, 2 deletions(-)
Signature · 1 line
2.34.1
author
#3 lore raw
Quoted 10 lines · Liam R. Howlett
Quoted 6 lines · Wei Yang

There are two possible redundant code:

1. the left subtree's mas is set in mab_mas_cp()
2. the right subtree's pivot 0 would be set again in mab_mas_cp()

We can remove them.

Is there any measurable difference with these changes?

I guess no.

Signature · 2 lines
Wei Yang
Help you, Help me
author
#4 lore raw

PATCH 2/2 maple_tree: not necessary to set pivot 0 before mab_mas_cp()

In reply to Wei Yang

mab_mas_cp() at least copy one pivot, which is pivot 0. This means the pivot 0 set by mte_set_pivot() will be overwritten.

Just remote this redundant code.

---
 lib/maple_tree.c | 1 -
 1 file changed, 1 deletion(-)
lib/maple_tree.c +0 -1
index 31964c5c677a..b02d812e1489 100644
@@ -3174,7 +3174,6 @@ static inline void mast_split_data(struct maple_subtree_state *mast,
 	unsigned char p_slot;
 
 	mab_mas_cp(mast->bn, 0, split, mast->l, true);
-	mte_set_pivot(mast->r->node, 0, mast->r->max);
 	mab_mas_cp(mast->bn, split + 1, mast->bn->b_end, mast->r, false);
 	mast->l->offset = mte_parent_slot(mas->node);
 	mast->r->min = mast->l->max + 1;
Signature · 1 line
2.34.1