Skip to content

Commit f806de8

Browse files
howlettakpm00
authored andcommitted
maple_tree: remove rcu_read_lock() from mt_validate()
The write lock should be held when validating the tree to avoid updates racing with checks. Holding the rcu read lock during a large tree validation may also cause a prolonged rcu read window and "rcu_preempt detected stalls" warnings. Link: https://lore.kernel.org/all/[email protected]/ Link: https://lkml.kernel.org/r/[email protected] Fixes: 54a611b ("Maple Tree: add new data structure") Signed-off-by: Liam R. Howlett <[email protected]> Reported-by: [email protected] Cc: Hillf Danton <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 6dacd79 commit f806de8

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/maple_tree.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7566,14 +7566,14 @@ static void mt_validate_nulls(struct maple_tree *mt)
75667566
* 2. The gap is correctly set in the parents
75677567
*/
75687568
void mt_validate(struct maple_tree *mt)
7569+
__must_hold(mas->tree->ma_lock)
75697570
{
75707571
unsigned char end;
75717572

75727573
MA_STATE(mas, mt, 0, 0);
7573-
rcu_read_lock();
75747574
mas_start(&mas);
75757575
if (!mas_is_active(&mas))
7576-
goto done;
7576+
return;
75777577

75787578
while (!mte_is_leaf(mas.node))
75797579
mas_descend(&mas);
@@ -7594,9 +7594,6 @@ void mt_validate(struct maple_tree *mt)
75947594
mas_dfs_postorder(&mas, ULONG_MAX);
75957595
}
75967596
mt_validate_nulls(mt);
7597-
done:
7598-
rcu_read_unlock();
7599-
76007597
}
76017598
EXPORT_SYMBOL_GPL(mt_validate);
76027599

0 commit comments

Comments
 (0)