Re: seqlock: Cure some more scoped_seqlock() optimization fails
From: Arnd Bergmann
Date: Thu Dec 04 2025 - 09:06:17 EST
On Thu, Dec 4, 2025, at 11:43, Peter Zijlstra wrote:
> Arnd reported an x86 randconfig using gcc-15 tripped over
> __scoped_seqlock_bug(). Turns out GCC chose not to inline the
> scoped_seqlock helper functions and as such was not able to optimize
> properly.
>
> Reported-by: Arnd Bergmann <arnd@xxxxxxxx>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Tested-by: Arnd Bergmann <arnd@xxxxxxxx>
>
> -static inline void __scoped_seqlock_cleanup(struct ss_tmp *sst)
> +static __always_inline void __scoped_seqlock_cleanup(struct ss_tmp *sst)
> {
> if (sst->lock)
> spin_unlock(sst->lock);
> @@ -1252,7 +1252,7 @@ static inline void __scoped_seqlock_bug(void) { }
> extern void __scoped_seqlock_bug(void);
> #endif
>
> -static inline void
> +static __always_inline void
> __scoped_seqlock_next(struct ss_tmp *sst, seqlock_t *lock, enum
> ss_state target)
> {
> switch (sst->state) {
It looks I got close: I had tried the __always_inline on
__scoped_seqlock_next but missed the one on __scoped_seqlock_cleanup,
so that was not enough.
Your version addresses the issue for me, thanks a lot for the fix!
Arnd