* Wei Yang <richard.weiyang@xxxxxxxxx> [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@xxxxxxxxx> > CC: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx> Reviewed-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx> > > --- > 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 >