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>,
Sidhartha Kumar <sidhartha.kumar@oracle.com>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Subject: [PATCH 1/4] maple_tree: current split may result in deficient node
Date: Sun, 20 Oct 2024 02:46:25 +0000 [thread overview]
Message-ID: <20241020024628.22469-2-richard.weiyang@gmail.com> (raw)
In-Reply-To: <20241020024628.22469-1-richard.weiyang@gmail.com>
Current split would result in deficient node in rare case.
For example:
mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE)
for (count = 0; count < 10; count++) {
mas_set(&mas, count);
mas_store(&mas, xa_mk_value(count));
}
for (count = 20; count < 39; count++) {
mas_set(&mas, count);
mas_store(&mas, xa_mk_value(count));
}
for (count = 10; count < 12; count++) {
mas_set(&mas, count);
mas_store(&mas, xa_mk_value(count));
}
mt_validate(mt);
The validation would report deficient node.
The reason is we don't leave enough room for the right node.
The deficient check is (end < mt_min_slot[]), which means a node must
have at least (mt_min_slot[] + 1) number of data. The right node's index
range is [split + 1, b_end], which means the number of data in right
node is (b_end - (split + 1) + 1) = (b_end - split).
Then the check between the number of data and (mt_min_slot[] + 1) is
(b_end - split) > (mt_min_slot[] + 1), which leads to
(b_end - split - 1) > (mt_min_slot[]).
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
---
lib/maple_tree.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 1205a5208cfe..894dc5e9436e 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -1831,7 +1831,7 @@ static inline int mab_no_null_split(struct maple_big_node *b_node,
* still be sufficient, then increment the split on NULL.
*/
if ((split < slot_count - 1) &&
- (b_node->b_end - split) > (mt_min_slots[b_node->type]))
+ (b_node->b_end - split - 1) > (mt_min_slots[b_node->type]))
split++;
else
split--;
@@ -1896,7 +1896,7 @@ static inline int mab_calc_split(struct ma_state *mas,
*/
while ((split < slot_count - 1) &&
((bn->pivot[split] - min) < slot_count - 1) &&
- (b_end - split > slot_min))
+ (b_end - split - 1 > slot_min))
split++;
}
--
2.34.1
next prev parent reply other threads:[~2024-10-20 2:46 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-20 2:46 [PATCH 0/4] " Wei Yang
2024-10-20 2:46 ` Wei Yang [this message]
2024-10-20 21:55 ` [PATCH 1/4] " Liam R. Howlett
2024-11-03 23:47 ` Wei Yang
2024-11-08 2:30 ` Wei Yang
2024-11-08 2:49 ` Liam R. Howlett
2024-10-20 2:46 ` [PATCH 2/4] maple_tree: add a test check " Wei Yang
2024-10-20 2:46 ` [PATCH 3/4] maple_tree: use the correct min to calculate split Wei Yang
2024-10-20 22:00 ` Liam R. Howlett
2024-10-29 17:49 ` Liam R. Howlett
2024-11-08 3:02 ` Wei Yang
2024-11-09 1:24 ` Wei Yang
2024-11-08 2:55 ` Wei Yang
2024-11-08 3:19 ` Liam R. Howlett
2024-11-09 1:40 ` Wei Yang
2024-11-09 4:01 ` Liam R. Howlett
2024-11-09 12:22 ` Wei Yang
2024-10-20 2:46 ` [PATCH 4/4] maple_tree: only root node could be deficient Wei Yang
2024-10-20 21:56 ` Liam R. Howlett
2024-11-03 23:15 ` Wei Yang
2024-10-20 20:34 ` [PATCH 0/4] maple_tree: current split may result in deficient node Liam R. Howlett
2024-10-21 1:30 ` 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=20241020024628.22469-2-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=lorenzo.stoakes@oracle.com \
--cc=maple-tree@lists.infradead.org \
--cc=sidhartha.kumar@oracle.com \
/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