From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>
Subject: [PATCH 2/3] maple_tree: Fix mas_empty_area() search
Date: Fri, 14 Apr 2023 10:57:27 -0400 [thread overview]
Message-ID: <20230414145728.4067069-2-Liam.Howlett@oracle.com> (raw)
In-Reply-To: <20230414145728.4067069-1-Liam.Howlett@oracle.com>
The internal function of mas_awalk() was incorrectly skipping the last
entry in a node, which could potentially be NULL. This is only a
problem for the left-most node in the tree - otherwise that NULL would
not exist.
Fix mas_awalk() by using the metadata to obtain the end of the node for
the loop and the logical pivot as apposed to the raw pivot value.
Fixes: 54a611b60590 ("Maple Tree: add new data structure")
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---
lib/maple_tree.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index ed350aa293b2..ecf4c1c0f4b3 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -5029,10 +5029,10 @@ static inline bool mas_anode_descend(struct ma_state *mas, unsigned long size)
{
enum maple_type type = mte_node_type(mas->node);
unsigned long pivot, min, gap = 0;
- unsigned char offset;
- unsigned long *gaps;
- unsigned long *pivots = ma_pivots(mas_mn(mas), type);
- void __rcu **slots = ma_slots(mas_mn(mas), type);
+ unsigned char offset, data_end;
+ unsigned long *gaps, *pivots;
+ void __rcu **slots;
+ struct maple_node *node;
bool found = false;
if (ma_is_dense(type)) {
@@ -5040,13 +5040,15 @@ static inline bool mas_anode_descend(struct ma_state *mas, unsigned long size)
return true;
}
- gaps = ma_gaps(mte_to_node(mas->node), type);
+ node = mas_mn(mas);
+ pivots = ma_pivots(node, type);
+ slots = ma_slots(node, type);
+ gaps = ma_gaps(node, type);
offset = mas->offset;
min = mas_safe_min(mas, pivots, offset);
- for (; offset < mt_slots[type]; offset++) {
- pivot = mas_safe_pivot(mas, pivots, offset, type);
- if (offset && !pivot)
- break;
+ data_end = ma_data_end(node, type, pivots, mas->max);
+ for (; offset <= data_end; offset++) {
+ pivot = mas_logical_pivot(mas, pivots, offset, type);
/* Not within lower bounds */
if (mas->index > pivot)
--
2.39.2
next prev parent reply other threads:[~2023-04-14 14:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-14 14:57 [PATCH 1/3] maple_tree: Make maple state reusable after mas_empty_area_rev() Liam R. Howlett
2023-04-14 14:57 ` Liam R. Howlett [this message]
2023-04-14 14:57 ` [PATCH 3/3] mm/mmap: Regression fix for unmapped_area{_topdown} Liam R. Howlett
2023-04-14 16:27 ` Edgecombe, Rick P
2023-04-14 17:26 ` Liam R. Howlett
2023-04-14 17:29 ` Liam R. Howlett
2023-04-14 17:53 ` Edgecombe, Rick P
2023-04-14 18:07 ` Liam R. Howlett
2023-04-14 18:21 ` Edgecombe, Rick P
2023-04-14 18:59 ` [PATCH v2] " Liam R. Howlett
2023-04-14 19:09 ` Andrew Morton
2023-04-29 14:32 ` Tad
2023-04-30 22:41 ` Michael Keyes
2023-05-02 14:08 ` Liam R. Howlett
2023-05-02 14:09 ` Liam R. Howlett
2023-05-15 8:57 ` Juhyung Park
2023-05-15 14:36 ` Liam R. Howlett
2023-04-19 9:02 ` [PATCH 1/3] maple_tree: Make maple state reusable after mas_empty_area_rev() Peng Zhang
2023-04-19 22:54 ` Liam R. Howlett
2023-04-20 4:21 ` Peng Zhang
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=20230414145728.4067069-2-Liam.Howlett@oracle.com \
--to=liam.howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rick.p.edgecombe@intel.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