[PATCH 05/17] locking/seqlock: assert static storage for DEFINE_SEQLOCK()

From: Yury Norov

Date: Mon Sep 14 2026 - 23:05:40 EST


DEFINE_SEQLOCK() statically initializes its sequence counter and spinlock.
Their lockdep maps require persistent class keys, which an automatic
local object cannot provide through this initializer.

Add ASSERT_STATIC_STORAGE() to the declaration macro. Automatic seqlocks
must use seqlock_init(); the underlying initializer remains available for
embedded objects.

Assisted-by: OpenAI Codex
Signed-off-by: Yury Norov <ynorov@xxxxxxxxxx>
---
include/linux/seqlock.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
index f865491c4f2c..2aa793a45213 100644
--- a/include/linux/seqlock.h
+++ b/include/linux/seqlock.h
@@ -824,7 +824,8 @@ static __always_inline void write_seqcount_latch_end(seqcount_latch_t *s)
* @sl: Name of the seqlock_t instance
*/
#define DEFINE_SEQLOCK(sl) \
- seqlock_t sl = __SEQLOCK_UNLOCKED(sl)
+ seqlock_t sl = __SEQLOCK_UNLOCKED(sl); \
+ ASSERT_STATIC_STORAGE(sl)

/**
* read_seqbegin() - start a seqlock_t read side critical section
--
2.53.0