From: Liam R. Howlett <Liam.Howlett@Oracle.com> Date: Mon, 7 Dec 2020 21:02:08 +0000 (-0500) Subject: maple_tree: Use memset in mas_reuse_node on arrays X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=8f9f48ac4637628d8aedd343bd806b7d002953dd;p=users%2Fjedix%2Flinux-maple.git maple_tree: Use memset in mas_reuse_node on arrays Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com> --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 073815614dc3..74645b54f571 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -2824,26 +2824,25 @@ static inline bool mas_reuse_node(struct ma_state *mas, struct maple_big_node *bn, unsigned char end) { - int i; - unsigned long max = mas->max; + unsigned long max; if (mt_in_rcu(mas->tree)) return false; // Need to be rcu safe. + max = mas->max; mab_mas_cp(bn, 0, bn->b_end, mas); mas->max = max; // Zero end of node. if (end > bn->b_end) { - for (i = bn->b_end + 1; i < mt_pivots[bn->type]; i++) { - mte_set_slot(mas->node, i, NULL); - mte_set_pivot(mas->node, i, 0); - - // if (!mte_is_leaf(mas->node) && mt_is_alloc(mas->tree)) - // mte_set_gap(mas->node, i, 0); - } - mte_set_slot(mas->node, mt_slots[bn->type] - 1, NULL); - + enum maple_type mt = mte_node_type(mas->node); + struct maple_node *mn = mas_mn(mas); + unsigned long *pivots = ma_pivots(mn, mt); + void **slots = ma_slots(mn, mt); + char zero = mt_slots[mt] - bn->b_end - 1; + + memset(slots + bn->b_end + 1, 0, sizeof(void *) * zero--); + memset(pivots + bn->b_end + 1, 0, sizeof(unsigned long *) * zero); } return true;