From: Wei Yang <richard.weiyang@gmail.com>
To: "Liam R. Howlett" <Liam.Howlett@oracle.com>,
Wei Yang <richard.weiyang@gmail.com>,
akpm@linux-foundation.org, maple-tree@lists.infradead.org,
linux-mm@kvack.org, Sidhartha Kumar <sidhartha.kumar@oracle.com>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Subject: Re: [PATCH 3/4] maple_tree: use the correct min to calculate split
Date: Sat, 9 Nov 2024 01:24:29 +0000 [thread overview]
Message-ID: <20241109012429.x7rkol5qtr3ilab6@master> (raw)
In-Reply-To: <diegb4ug4ltjb6pvuzo2xwxnge3k6aiptsfintl3kvlrbovmz4@pip7vafx74xq>
On Tue, Oct 29, 2024 at 01:49:28PM -0400, Liam R. Howlett wrote:
>* Liam R. Howlett <Liam.Howlett@oracle.com> [241020 18:00]:
>> * Wei Yang <richard.weiyang@gmail.com> [241019 22:46]:
>> > The check in mab_calc_split() is to make sure the gap between
>> > [0, split] won't be too small. But we don't pass the correct min.
>> >
>> > First we may encounter a pivot[split] smaller than min. For example:
>> >
>> > mt_init_flags(mt, 0);
>> > for (count = 0; count <= 240; count++) {
>> > mas_set(&mas, count);
>> > mas_store(&mas, xa_mk_value(count));
>> > }
>> >
>> > On splitting root for storing 240, the pivot[split] is smaller than min.
>> > This result a huge (pivot[split] - min).
>>
>> This is fine.
>>
>> There is an open work item to make it more accurate at higher levels,
>> but it's not a problem as it is.
>>
>> Each level upwards needs a better 'minimum span', meaning that the node
>> should have at least mas.min - mas.min + level * something.
>>
>> It works today for leaves, somewhat.
>>
>> >
>> > Second prev_l_mas.min is not initialized for the first iteration. This
>> > means on splitting leaf node, this value is mostly taking no effect.
>>
>> No, it is set to 0. Not initialized would cause random data loss.
>>
>> See MA_STATE() in the header.
>>
>> >
>> > Since we are now calculating the split of mas->node, we should use the
>> > mas->min instead of prev_l_mas.min.
>>
>> This sounds reasonable, but considering what this number is used for, I
>> don't see how it is working as well as it is today. I will need to look
>> deeper into this.
>
>
>On examination of what is happening here, the only way this makes a
>difference during the testcases is if we have a node with 16 entries,
>we'll put 8 in the left today and 9 in the left after this change.
>
>This only matters if the range is less than the slot count, so the real
>world implications of the change will be negligible, if anything.
>
Yes, maybe it only effect when there are all singleton.
>I honestly think I'm trying to be too smart here, especially at the
>leaves. We should just set mid_split = 0; in that complex statement and
>drop the min argument all together. It hasn't made a difference besides
>the number of instructions executed.
>
I have tried to remove those lines, so we got split = b_end / 2 and
mid_split = 0. Tests all passed and kernel runs. (I guess in the real world,
it behaves the same, since (bn->pivot[split] - min) is always bigger than 15.)
Since we call mab_calc_split() when b_end >= slot_count == 16, it means we
get split == 16/2 == 8. So the new left|right node has data 9|8, this is
friendly to jitter problem.
>>
>> >
>> > 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 | 2 +-
>> > 1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/lib/maple_tree.c b/lib/maple_tree.c
>> > index 894dc5e9436e..c2d4b188646c 100644
>> > --- a/lib/maple_tree.c
>> > +++ b/lib/maple_tree.c
>> > @@ -3357,7 +3357,7 @@ static void mas_split(struct ma_state *mas, struct maple_big_node *b_node)
>> > if (mas_push_data(mas, height, &mast, false))
>> > break;
>> >
>> > - split = mab_calc_split(mas, b_node, &mid_split, prev_l_mas.min);
>> > + split = mab_calc_split(mas, b_node, &mid_split, mas->min);
>> > mast_split_data(&mast, mas, split);
>> > /*
>> > * Usually correct, mab_mas_cp in the above call overwrites
>> > --
>> > 2.34.1
>> >
--
Wei Yang
Help you, Help me
next prev parent reply other threads:[~2024-11-09 1:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-20 2:46 [PATCH 0/4] maple_tree: current split may result in deficient node Wei Yang
2024-10-20 2:46 ` [PATCH 1/4] " Wei Yang
2024-10-20 21:55 ` 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 [this message]
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=20241109012429.x7rkol5qtr3ilab6@master \
--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