poll_state_synchronize_rcu(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… poll_state_synchronize_rcu(9) πŸ’…

okay bestie, welcome to the Kernel API Manual β€” section 9 energy, obviously β€” and this page is literally asking one question: has the specified RCU grace period completed? πŸ¦‹

✨ NAME ✨

poll_state_synchronize_rcu β€” has the specified RCU grace period completed?

πŸ¦‹ SYNOPSIS πŸ¦‹

bool poll_state_synchronize_rcu (unsigned long oldstate );

πŸŽ€ ARGUMENTS πŸŽ€

  • oldstate β€” value from get_state_synchronize_rcu or start_poll_synchronize_rcu

πŸ’– DESCRIPTION πŸ’–

So here's the tea, bestie: if a full RCU grace period has elapsed since the earlier call from which oldstate was obtained, this function returns true; otherwise it returns false. Simple as that. ✨

If false is returned, it is the caller's responsibility to invoke this function later on until it does return true. No ghosting the poll, okay? Alternatively, the caller can explicitly wait for a grace period, for example, by passing oldstate to either cond_synchronize_rcu or cond_synchronize_rcu_expedited on the one hand, or by directly invoking either synchronize_rcu or synchronize_rcu_expedited on the other. 🫢

Yes, this function does not take counter wrap into account. But counter wrap is harmless. If the counter wraps, we have waited for more than a billion grace periods (and way more on a 64-bit system!). Those needing to keep old state values for very long time periods (many hours even on 32-bit systems) should check them occasionally and either refresh them or set a flag indicating that the grace period has completed. Alternatively, they can use get_completed_synchronize_rcu to get a guaranteed-completed grace-period state. πŸ’…

In addition, because oldstate compresses the grace-period state for both normal and expedited grace periods into a single unsigned long, it can miss a grace period when synchronize_rcu runs concurrently with synchronize_rcu_expedited. If this is unacceptable, please instead use the _full variant of these polling APIs. Noted, no cap. 😭

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. That's the main character guarantee, periodt. πŸ‘‘

🌈 SEE ALSO 🌈

Kernel file ./kernel/rcu/tree.c β€” and the whole squad is: rcu_softirq_qs(9), rcu_watching_snap_stopped_since(9), rcu_is_cpu_rrupt_from_idle(9), rcu_irq_exit_check_preempt(9), __rcu_irq_enter_check_tick(9), rcu_is_watching(9), rcu_set_gpwrap_lag(9), call_rcu_hurry(9), call_rcu(9), synchronize_rcu(9), get_completed_synchronize_rcu_full(9), get_state_synchronize_rcu(9), get_state_synchronize_rcu_full(9), start_poll_synchronize_rcu(9), start_poll_synchronize_rcu_full(9), poll_state_synchronize_rcu_full(9), cond_synchronize_rcu(9), cond_synchronize_rcu_full(9), rcu_barrier(9), rcu_barrier_throttled(9).

Mwah πŸ’‹ β€” signed off from source/version ./kernel/rcu, stamped October 2026, and still serving poll_state_synchronize_rcu(9), bestie. πŸŽ€

πŸ“¦ where this page comes from