cond_synchronize_rcu(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… cond_synchronize_rcu(9) πŸ’…

okay bestie, welcome to the Kernel API Manual β€” this one's cond_synchronize_rcu, and it's literally the "wait for an RCU grace period, but only if you have to" girlie. conditional queen behavior, we stan πŸŽ€


✨ NAME ✨

cond_synchronize_rcu β€” conditionally wait for an RCU grace period πŸ¦‹


🌸 SYNOPSIS 🌸

void cond_synchronize_rcu (unsigned long oldstate );

πŸŽ€ ARGUMENTS πŸŽ€

  • oldstate β€” the value you got back from get_state_synchronize_rcu, start_poll_synchronize_rcu, or start_poll_synchronize_rcu_expedited. like, it's the receipt from your earlier call, keep it safe πŸ’–

πŸ’… DESCRIPTION πŸ’…

so here's the vibe check πŸ‘‘: if a full RCU grace period has already elapsed since that earlier call to get_state_synchronize_rcu or start_poll_synchronize_rcu, then this function just returns. nothing to do, no waiting, we're done, slay ✨

otherwise? it invokes synchronize_rcu and actually waits for a full grace period. no cap, sometimes you gotta wait 😭

yes, this function does not take counter wrap into account. but bestie β€” counter wrap is harmless πŸ™ˆ. if the counter wraps, we've waited for more than 2 billion grace periods (and way more on a 64-bit system!), so waiting for a couple of additional grace periods should be just fine. like genuinely, it's giving "not a problem" πŸ’€

okay and this part is highkey important: this function provides the same memory-ordering guarantees that would be provided by a synchronize_rcu that was invoked at the call to the function that provided oldstate and that returned at the end of this function. periodt πŸ”₯


🌈 SEE ALSO 🌈

Kernel file ./kernel/rcu/tree.c, plus the whole friend group:


and that's the whole page, bestie 🫢 this lil icon lives in ./kernel/rcu and the version/date stamp on it says October 2026 β€” so go forth, wait conditionally, and remember: the counter wrap cannot hurt you πŸ§šπŸ’œ

πŸ“¦ where this page comes from