From: Liam Howlett <liam.howlett@oracle.com>
To: "maple-tree@lists.infradead.org" <maple-tree@lists.infradead.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] maple_tree: Fix sparse reported issues
Date: Tue, 12 Jul 2022 14:24:55 +0000 [thread overview]
Message-ID: <20220712142441.4184969-1-Liam.Howlett@oracle.com> (raw)
When building with C=1, the maple tree had some rcu type mismatch &
locking mismatches in the destroy functions. There were cosmetic only
since this happens after the nodes are removed from the tree.
Fixes: f8acc5e9581e (Maple Tree: add new data structure)
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---
lib/maple_tree.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 79e07c7dc323..9dc4ffff18d0 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -2319,7 +2319,7 @@ static inline void mast_topiary(struct maple_subtree_state *mast)
MA_WR_STATE(wr_mas, mast->orig_l, NULL);
unsigned char r_start, r_end;
unsigned char l_start, l_end;
- void **l_slots, **r_slots;
+ void __rcu **l_slots, **r_slots;
wr_mas.type = mte_node_type(mast->orig_l->node);
mast->orig_l->index = mast->orig_l->last;
@@ -5461,6 +5461,7 @@ static void mt_free_walk(struct rcu_head *head)
mt_free_bulk(node->slot_len, slots);
start_slots_free:
+ mas_unlock(&mas);
free_leaf:
mt_free_rcu(&node->rcu);
}
@@ -5513,6 +5514,7 @@ static void mt_destroy_walk(struct maple_enode *enode, unsigned char ma_flags,
do {
enum maple_type type;
unsigned char offset;
+ struct maple_enode *parent, *tmp;
node->slot_len = mas_dead_leaves(&mas, slots);
if (free)
@@ -5524,13 +5526,17 @@ static void mt_destroy_walk(struct maple_enode *enode, unsigned char ma_flags,
type = mte_node_type(mas.node);
slots = ma_slots(mte_to_node(mas.node), type);
- if ((offset < mt_slots[type]) && mte_node_type(slots[offset]) &&
- mte_to_node(slots[offset])) {
- struct maple_enode *parent = mas.node;
+ if (offset >= mt_slots[type])
+ goto next;
- mas.node = mas_slot_locked(&mas, slots, offset);
+ tmp = mas_slot_locked(&mas, slots, offset);
+ if (mte_node_type(tmp) && mte_to_node(tmp)) {
+
+ parent = mas.node;
+ mas.node = tmp;
slots = mas_destroy_descend(&mas, parent, offset);
}
+next:
node = mas_mn(&mas);
} while (start != mas.node);
--
2.35.1
next reply other threads:[~2022-07-12 14:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-12 14:24 Liam Howlett [this message]
2022-07-12 14:54 ` [PATCH] maple_tree: Fix sparse reported issues Matthew Wilcox
2022-07-12 15:44 ` Liam Howlett
2022-07-13 8:34 ` David Hildenbrand
2022-07-13 13:29 ` Liam Howlett
2022-07-13 15:55 ` Hugh Dickins
2022-07-13 17:50 ` Liam Howlett
2022-07-15 19:53 ` Liam Howlett
2022-07-17 20:57 ` Hugh Dickins
2022-07-18 2:27 ` Liam Howlett
2022-07-18 4:28 ` Hugh Dickins
2022-07-18 6:47 ` Hugh Dickins
2022-07-18 12:56 ` Liam Howlett
2022-07-18 13:45 ` Liam Howlett
2022-07-18 17:30 ` Hugh Dickins
2022-07-18 17:47 ` Liam Howlett
2022-07-18 21:34 ` Hugh Dickins
2022-07-19 1:39 ` Liam 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=20220712142441.4184969-1-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=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