From: Sidhartha Kumar <sidhartha.kumar@oracle.com>
To: linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org
Cc: linux-mm@kvack.org, akpm@linux-foundation.org,
liam.howlett@oracle.com, richard.weiyang@gmail.com,
Sidhartha Kumar <sidhartha.kumar@oracle.com>
Subject: [PATCH v2 4/6] maple_tree: break on convergence in mas_spanning_rebalance()
Date: Fri, 21 Feb 2025 16:36:08 +0000 [thread overview]
Message-ID: <20250221163610.578409-5-sidhartha.kumar@oracle.com> (raw)
In-Reply-To: <20250221163610.578409-1-sidhartha.kumar@oracle.com>
This allows support for using the vacant height to calculate the worst
case number of nodes needed for wr_rebalance operation.
mas_spanning_rebalance() was seen to perform unnecessary node allocations.
We can reduce allocations by breaking early during the rebalancing loop
once we realize that we have ascended to a common ancestor.
Suggested-by: Liam Howlett <liam.howlett@oracle.com>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
lib/maple_tree.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index ef71af0529f4..4de257003251 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -2896,11 +2896,24 @@ static void mas_spanning_rebalance(struct ma_state *mas,
mast_combine_cp_right(mast);
mast->orig_l->last = mast->orig_l->max;
- if (mast_sufficient(mast))
- continue;
+ if (mast_sufficient(mast)) {
+ if (mast_overflow(mast))
+ continue;
+
+ if (mast->orig_l->node == mast->orig_r->node) {
+ /*
+ * The data in b_node should be stored in one
+ * node and in the tree
+ */
+ slot = mast->l->offset;
+ /* May be a new root stored in mast->bn */
+ if (mas_is_root_limits(mast->orig_l))
+ new_height++;
+ break;
+ }
- if (mast_overflow(mast))
continue;
+ }
/* May be a new root stored in mast->bn */
if (mas_is_root_limits(mast->orig_l)) {
--
2.43.0
next prev parent reply other threads:[~2025-02-21 16:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-21 16:36 [PATCH v2 0/6] Track node vacancy to reduce worst case allocation counts Sidhartha Kumar
2025-02-21 16:36 ` [PATCH v2 1/6] maple_tree: convert mas_prealloc_calc() to take in a maple write state Sidhartha Kumar
2025-02-25 15:40 ` Liam R. Howlett
2025-02-21 16:36 ` [PATCH v2 2/6] maple_tree: use height and depth consistently Sidhartha Kumar
2025-02-25 15:39 ` Liam R. Howlett
2025-02-21 16:36 ` [PATCH v2 3/6] maple_tree: use vacant nodes to reduce worst case allocations Sidhartha Kumar
2025-02-25 15:46 ` Liam R. Howlett
2025-02-25 16:22 ` Sidhartha Kumar
2025-02-26 15:30 ` Liam R. Howlett
2025-02-21 16:36 ` Sidhartha Kumar [this message]
2025-02-25 15:47 ` [PATCH v2 4/6] maple_tree: break on convergence in mas_spanning_rebalance() Liam R. Howlett
2025-02-21 16:36 ` [PATCH v2 5/6] maple_tree: add sufficient height Sidhartha Kumar
2025-02-25 16:02 ` Liam R. Howlett
2025-02-25 20:36 ` Sidhartha Kumar
2025-02-26 15:15 ` Liam R. Howlett
2025-02-21 16:36 ` [PATCH v2 6/6] maple_tree: reorder mas->store_type case statements Sidhartha Kumar
2025-02-25 16:03 ` Liam R. Howlett
2025-02-25 15:40 ` [PATCH v2 0/6] Track node vacancy to reduce worst case allocation counts Liam R. Howlett
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=20250221163610.578409-5-sidhartha.kumar@oracle.com \
--to=sidhartha.kumar@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=liam.howlett@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maple-tree@lists.infradead.org \
--cc=richard.weiyang@gmail.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