Re: [PATCH v2 1/4] seqlock: introduce scoped_seqlock_read() and scoped_seqlock_read_irqsave()
From: Linus Torvalds
Date: Thu Oct 09 2025 - 16:25:19 EST
On Thu, 9 Oct 2025 at 13:12, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> Slightly nicer version that's actually compiled :-)
I assume that "target of ss_lockless" is an intentional extension to
just make the loop never take a lock at all?
I do like it, but I think you'll find that having a separate 'seq' and
'flags' like this:
> +struct ss_tmp {
> + enum ss_state state;
> + int seq;
> + unsigned long flags;
> + spinlock_t *lock;
> +};
makes it unnecessarily waste a register.
You never need both seq and flags at the same time, since if you take
the spinlock the sequence number is pointless.
So please make that a union, and I think it will help avoid wasting a
register in the loop.
Other than that I like it. Except that "BUG()" really bugs me. It will
generate horrendous code for no reason and we *really* shouldn't add
BUG statements anyway.
Either that inline function is fine, or it isn't. Don't make it
generate stupid code for "I'm not fine" that will also be a huge pain
to debug because if that code is buggy it will presumably trigger in
context where the machine will be dead, dead, dead.
Linus