Re: [PATCH 1/5] seqlock: introduce SEQLOCK_READ_SECTION()
From: Oleg Nesterov
Date: Sun Oct 05 2025 - 12:09:36 EST
OK. I'll send v2 but let me ask...
On 10/05, Linus Torvalds wrote:
>
> As far as the users are concerned, the result doesn't end up being
> really any different from our scoped guards, so I'd actually suggest
> you just make this helper look like our scoped_guard() macro does.
I swear, I too thought about scoped_seqlock_xxx ;)
> And instead of making people pass in a NULL 'flags', just do a
> separate version of it, exactly like we do for locking. Even if the
> internal implementation then ends up sharing most of the code, please
> don't make people pass in NULL just because they don't want the
> irqsave version.
>
> So make it two different things:
>
> scoped_seqlock_read(lock) { .... }
>
> scoped_seqlock__read_irqsave(lock, flags) { ... }
OK. But if you don't object I'd like to avoid another DEFINE_LOCK_GUARD()
or something like it in this case. To me it won't buy anything.
And I think that the "generic" seqlock_read_section_retry(flags) makes
sense, the "if (flags)" checks should not generate the extra code.
Will you agree?
> (Maybe 'flags' can even be local to that scope?)
The problem is that you can't declare "int lockless/seq" and
"unsigned long flags" inside "for (...)", but I'll try to think about
it more.
Oleg.