skwq_has_sleeper(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 skwq_has_sleeper β€” a kernel API manual, bestie edition 🌸

okay so this is from the Kernel API Manual, page skwq_has_sleeper(9), and honestly? it's a little baddie. let's get into it πŸ’…


✨ NAME ✨

skwq_has_sleeper β€” check if there are any waiting processes πŸ‘€

like... is anybody in the queue? hello?? 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

bool skwq_has_sleeper (struct socket_wq *wq );

that's it. that's the whole thing. short and iconic πŸ’–


πŸŽ€ ARGUMENTS πŸŽ€

  • wq β€” a struct socket_wq. that's the whole description, she's mysterious like that πŸ™ˆ

⭐ RETURN ⭐

returns true if the socket_wq has waiting processes. no cap, that's the vibe check πŸ”₯


πŸ’€ DESCRIPTION πŸ’€

okay so here's the tea, bestie. the whole point of skwq_has_sleeper and sock_poll_wait is to wrap the memory barrier call. they exist because of a race that got found hanging out in the tcp code 😭 like, actual bug energy.

consider the following tcp code paths:

CPU1                CPU2
sys_select          receive packet
...                 ...
__add_wait_queue    update tp->rcv_nxt
...                 ...
tp->rcv_nxt check   sock_def_readable
...                 {
schedule               rcu_read_lock;
                       wq = rcu_dereference(sk->sk_wq);
                       if (wq && waitqueue_active(wq->wait))
                           wake_up_interruptible(wq->wait)
                       ...
                    }

so the race for tcp fires when the __add_wait_queue changes that CPU1 did just... stay chilling in its cache. and the same goes for the tp->rcv_nxt update on the CPU2 side. πŸ’€ so then CPU1 could end up calling schedule and sleep forever if there's no more data on the socket. forever!! not me having a whole existential crisis about a sleep that never wakes up 😭

like genuinely, that's the danger here β€” a process stuck sleeping with no wakeup coming. that's why the memory barrier wrapping exists. slay for correctness, not for vibes 🫢

πŸ‘‘ SEE ALSO πŸ‘‘

all the siblings and cousins, in the kernel file ./include/net/sock.h:


🌈 and that's the page!! it lives in ./include/net and the date on this one is October 2026 β€” so yeah, future-coded manual page, we love to see it. go read sock_poll_wait(9) next, iykyk πŸ’œπŸŽ€βœ¨

πŸ“¦ where this page comes from