Re: [RFC 2/1] seqlock: make the read_seqbegin_or_lock() API more simple and less error-prone ?

From: David Howells

Date: Tue Sep 30 2025 - 18:09:36 EST


Oleg Nesterov <oleg@xxxxxxxxxx> wrote:

>
> Can we improve this API?

It would also be nice to fix the static lock-balance detection stuff that you
get when you enable advanced checking during a kernel build. It doesn't
seem to understand seqlocks.

> - nextseq = 0;
> + seq = 0;

Perhaps an init function or macro that hides this bit?

void init_read_seqlock(int *seq)
{
*seq = 0;
}

init_read_seqlock(&seq);

or:

#define INIT_READ_SEQBEGIN 0

seq = INIT_READ_SEQBEGIN;

Though if we can fold the whole loop inside a macro, that might make it easier
to use.

d_walk() in fs/dcache.c might give you issues, though.

David