summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Yang <richard.weiyang@gmail.com>2024-09-08 16:05:54 +0200
committerAndrew Morton <akpm@linux-foundation.org>2024-11-06 01:56:24 +0100
commit5059aa6334fcf4b7ddd672255aec5835aecd32b6 (patch)
treeb7faa9d6059ec223855cbd063cea5e0ef15aec26
parentmaple_tree: remove maple_big_node.parent (diff)
downloadlinux-5059aa6334fcf4b7ddd672255aec5835aecd32b6.tar.xz
linux-5059aa6334fcf4b7ddd672255aec5835aecd32b6.zip
maple_tree: memset maple_big_node as a whole
In 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. Link: https://lkml.kernel.org/r/20240908140554.20378-3-richard.weiyang@gmail.com Signed-off-by: Wei Yang <richard.weiyang@gmail.com> Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r--lib/maple_tree.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 04cd5ce2a33c..c5987244ff63 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -3157,10 +3157,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;