scoped_seqlock_read(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… scoped_seqlock_read(9) πŸ’…

okay so you found a page in the Kernel API Manual and it's honestly kind of a vibe β€” it's basically a macro that does the read-side critical section for you so you don't have to hand-juggle sequence counters or call a million little helpers yourself. no cap, it's giving "let the macro handle it." πŸ¦‹


✨ NAME ✨

scoped_seqlock_read β€” execute the read-side critical section without manual sequence counter handling or calls to other helpers πŸ’–


🌸 SYNOPSIS 🌸

scoped_seqlock_read (_seqlock , _target );

πŸŽ€ ARGUMENTS πŸŽ€

  • _seqlock β€” pointer to seqlock_t protecting the data πŸ”’ (this is the thing doing the protecting, bestie, keep it safe)
  • _target β€” an enum ss_state: one of {ss_lock, ss_lock_irqsave, ss_lockless} indicating the type of critical read section. lowkey this is you telling it which flavour of read section you want πŸ“

πŸ’œ DESCRIPTION πŸ’œ

Example, because seeing it is way easier than me explaining it:

scoped_seqlock_read (lock, ss_lock) {
    // read-side critical section
}

Starts with a lockess pass first. If it fails, restarts the critical section with the lock held. ✨ (yes, it says "lockess" β€” that's the original spelling, I'm not touching it, iykyk 😭)

fr fr: it tries the fast lockless route first and only brings in the lock when that first attempt doesn't work out. main character energy from the lock, honestly.

πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./include/linux/seqlock.h plus the whole friend group:

seqcount_init(9), SEQCNT_ZERO(9), __read_seqcount_begin(9), raw_read_seqcount_begin(9), read_seqcount_begin(9), raw_read_seqcount(9), raw_seqcount_try_begin(9), raw_seqcount_begin(9), __read_seqcount_retry(9), read_seqcount_retry(9), raw_write_seqcount_begin(9), raw_write_seqcount_end(9), write_seqcount_begin_nested(9), write_seqcount_begin(9), write_seqcount_end(9), raw_write_seqcount_barrier(9), write_seqcount_invalidate(9), SEQCNT_LATCH_ZERO(9), seqcount_latch_init(9), raw_read_seqcount_latch(9), read_seqcount_latch(9), raw_read_seqcount_latch_retry(9), read_seqcount_latch_retry(9), raw_write_seqcount_latch(9), write_seqcount_latch_begin(9), write_seqcount_latch(9), write_seqcount_latch_end(9), seqlock_init(9), DEFINE_SEQLOCK(9), read_seqbegin(9), read_seqretry(9), write_seqlock(9), write_sequnlock(9), write_seqlock_bh(9), write_sequnlock_bh(9), write_seqlock_irq(9), write_sequnlock_irq(9), write_seqlock_irqsave(9), write_sequnlock_irqrestore(9), read_seqlock_excl(9), read_sequnlock_excl(9), read_seqlock_excl_bh(9), read_sequnlock_excl_bh(9), read_seqlock_excl_irq(9), read_sequnlock_excl_irq(9), read_seqlock_excl_irqsave(9), read_seqlock_excl_irqrestore(9), read_seqbegin_or_lock(9), need_seqretry(9), done_seqretry(9), read_seqbegin_or_lock_irqsave(9), done_seqretry_irqrestore(9)


and that's the whole page, bestie 🫢 it ships from ./include/linux and it's dated October 2026, so it's literally from the future β€” iconic. go read your seqlocks, ily, bye πŸ’…πŸŒˆβ­

πŸ“¦ where this page comes from