linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] maple_tree: Fix sparse reported issues
@ 2022-07-12 14:24 Liam Howlett
  2022-07-12 14:54 ` Matthew Wilcox
  2022-07-13  8:34 ` David Hildenbrand
  0 siblings, 2 replies; 18+ messages in thread
From: Liam Howlett @ 2022-07-12 14:24 UTC (permalink / raw)
  To: maple-tree, linux-mm, linux-kernel, Andrew Morton

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


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2022-07-19  1:39 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-12 14:24 [PATCH] maple_tree: Fix sparse reported issues Liam Howlett
2022-07-12 14:54 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox