]> www.infradead.org Git - users/dwmw2/linux.git/commit
maple_tree: memset maple_big_node as a whole
authorWei Yang <richard.weiyang@gmail.com>
Sun, 8 Sep 2024 14:05:54 +0000 (14:05 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 6 Nov 2024 00:56:24 +0000 (16:56 -0800)
commit5059aa6334fcf4b7ddd672255aec5835aecd32b6
treeb7faa9d6059ec223855cbd063cea5e0ef15aec26
parentf36ba810816182953af74d176e0644e38979b723
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>
lib/maple_tree.c