public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: akpm@linux-foundation.org, Liam.Howlett@oracle.com
Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org,
	Wei Yang <richard.weiyang@gmail.com>,
	"Liam R . Howlett" <Liam.Howlett@Oracle.com>
Subject: [PATCH v2 2/2] maple_tree: memset maple_big_node as a whole
Date: Sun,  8 Sep 2024 14:05:54 +0000	[thread overview]
Message-ID: <20240908140554.20378-3-richard.weiyang@gmail.com> (raw)
In-Reply-To: <20240908140554.20378-1-richard.weiyang@gmail.com>

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@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>

---
v2: correct the change log on clearing all maple_big_node currently
---
 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



  parent reply	other threads:[~2024-09-08 14:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-08 14:05 [PATCH v2 0/2] Reduce the space to be cleared for maple_big_node Wei Yang
2024-09-08 14:05 ` [PATCH v2 1/2] maple_tree: remove maple_big_node.parent Wei Yang
2024-09-11  0:35   ` Liam R. Howlett
2024-09-08 14:05 ` Wei Yang [this message]
2024-09-11  0:36   ` [PATCH v2 2/2] maple_tree: memset maple_big_node as a whole Liam R. Howlett
2024-09-25  2:45 ` [PATCH v2 0/2] Reduce the space to be cleared for maple_big_node Wei Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240908140554.20378-3-richard.weiyang@gmail.com \
    --to=richard.weiyang@gmail.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=maple-tree@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox