Commit 776e664e authored by Liam R. Howlett's avatar Liam R. Howlett Committed by Jinjie Ruan
Browse files

maple_tree: remove rcu_read_lock() from mt_validate()

mainline inclusion
from mainline-v6.11-rc7
commit f806de88d8f7f8191afd0fd9b94db4cd058e7d4f
category: performance
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IB1S01

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f806de88d8f7f8191afd0fd9b94db4cd058e7d4f

--------------------------------

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/0000000000001d12d4062005aea1@google.com/
Link: https://lkml.kernel.org/r/20240820175417.2782532-1-Liam.Howlett@oracle.com


Fixes: 54a611b6 ("Maple Tree: add new data structure")
Signed-off-by: default avatarLiam R. Howlett <Liam.Howlett@Oracle.com>
Reported-by: default avatar <syzbot+036af2f0c7338a33b0cd@syzkaller.appspotmail.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: "Paul E. McKenney" <paulmck@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarJinjie Ruan <ruanjinjie@huawei.com>
parent 37d69284
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -7618,14 +7618,14 @@ static void mt_validate_nulls(struct maple_tree *mt)
 * 2. The gap is correctly set in the parents
 */
void mt_validate(struct maple_tree *mt)
	__must_hold(mas->tree->ma_lock)
{
	unsigned char end;

	MA_STATE(mas, mt, 0, 0);
	rcu_read_lock();
	mas_start(&mas);
	if (!mas_is_active(&mas))
		goto done;
		return;

	while (!mte_is_leaf(mas.node))
		mas_descend(&mas);
@@ -7646,9 +7646,6 @@ void mt_validate(struct maple_tree *mt)
		mas_dfs_postorder(&mas, ULONG_MAX);
	}
	mt_validate_nulls(mt);
done:
	rcu_read_unlock();

}
EXPORT_SYMBOL_GPL(mt_validate);