>From c291e6d64840ae5dc6a2166bc0de8b82a6906705 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett (Oracle)" Date: Mon, 20 Jul 2026 17:30:38 -0400 Subject: [PATCH] maple_tree: Stop flooding logs when debug_locks is set to zero When lockdep detects an issue, it sets debug_locks to 0 disabling further reports. The newly added maple tree sequence counting on locks to detect errors is not taking this nor the fact that lock_is_held() can return -1 (unknown state) into account. The resulting action is a flood of logging of not matching sequence numbers being reported on failure. __lock_sequnece() will return u32 ~0 when debug_locks is zero, and the real sequnece count cannot return such a high value as it is less than 32bits. By always updating the sequence number, regardless of lock state and by ignoring ~0 value in the sequence number will avoid ever printing a WARN_ON when this condition is hit. Signed-off-by: Liam R. Howlett (Oracle) --- lib/maple_tree.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 06cc05b79fbdc..2280be62235ca 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1173,6 +1173,8 @@ static void mas_lock_check(struct ma_state *mas) { #ifdef CONFIG_LOCKDEP struct lockdep_map *map; + u32 seq; + if (!mas_is_active(mas)) return; @@ -1184,8 +1186,12 @@ static void mas_lock_check(struct ma_state *mas) #endif /* CONFIG_RCU_STRICT_GRACE_PERIOD */ map = mas_lockdep_map(mas); - if (map && lock_is_held(map)) - WARN_ON_ONCE(mas->ld_seq != lock_sequence(map)); + if (!map) + return; + + seq = lock_sequence(map); + if (seq != UINT_MAX && mas->ld_seq != UINT_MAX) + WARN_ON_ONCE(mas->ld_seq != seq); #endif /* CONFIG_LOCKDEP */ } @@ -1203,8 +1209,8 @@ static void mas_init_lock_check(struct ma_state *mas) #endif /* CONFIG_RCU_STRICT_GRACE_PERIOD */ map = mas_lockdep_map(mas); - if (map && lock_is_held(map)) - mas->ld_seq = lock_sequence(mas_lockdep_map(mas)); + if (map) /* Update regardless of lock state */ + mas->ld_seq = lock_sequence(map); #endif /* CONFIG_LOCKDEP */ } -- 2.47.3