]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
documentation: seqlock: fix the wrong documentation of read_seqbegin_or_lock/need_seq...
authorOleg Nesterov <oleg@redhat.com>
Sun, 28 Sep 2025 16:20:29 +0000 (18:20 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 21 Oct 2025 10:31:56 +0000 (12:31 +0200)
commit28a0ee311960baad97bf85e1e995aed4a71e22a2
treefadecc4815fde6027e94fc75f89619ad6cf597ed
parent44472d1b83127e579c798ff92a07ae86d98b61b9
documentation: seqlock: fix the wrong documentation of read_seqbegin_or_lock/need_seqretry

The comments and pseudo code in Documentation/locking/seqlock.rst are wrong:

int seq = 0;
do {
read_seqbegin_or_lock(&foo_seqlock, &seq);

/* ... [[read-side critical section]] ... */

} while (need_seqretry(&foo_seqlock, seq));

read_seqbegin_or_lock() always returns with an even "seq" and need_seqretry()
doesn't change this counter. This means that seq is always even and thus the
locking pass is simply impossible.

IOW, "_or_lock" has no effect and this code doesn't differ from

do {
seq = read_seqbegin(&foo_seqlock);

/* ... [[read-side critical section]] ... */

} while (read_seqretry(&foo_seqlock, seq));

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Documentation/locking/seqlock.rst