percpu_ref_switch_to_percpu(9)
π NAME π
okay so bestie, this is percpu_ref_switch_to_percpu(9) from the Kernel API Manual, and it's literally here to switch a percpu_ref to percpu mode. That's the whole name β no cap. It's giving "specialized kernel refcount glow-up," not your everyday refcount situation β¨.
β¨ SYNOPSIS β¨
void percpu_ref_switch_to_percpu (struct percpu_ref *ref );
π ARGUMENTS π
refβ thepercpu_refyou want to switch to percpu mode. That's it, that's the argument π
π¦ DESCRIPTION π¦
okay so first things first: there's no reason to use this function for the usual reference counting. like, none. if you're trying to re-use an expired ref, use percpu_ref_reinit instead, okay? π
This function switches ref to percpu mode. It may be invoked concurrently with all the get/put operations, and it can safely be mixed with kill and reinit operations β yes, bestie, it's built different π₯. It reverses the sticky atomic state set by PERCPU_REF_INIT_ATOMIC or percpu_ref_switch_to_atomic. If ref is dying or dead, the actual switching takes place on the following percpu_ref_reinit.
β οΈ heads up: this function may block ifrefis in the process of switching to atomic mode. If the caller ensures thatrefis not in the process of switching to atomic mode, this function can be called from any context. So like, know your ref's situation before you call, periodt π
π SEE ALSO π
- Kernel file
./lib/percpu-refcount.cβ the home base for this whole situation π percpu_ref_init(9)percpu_ref_exit(9)percpu_ref_switch_to_atomic(9)percpu_ref_switch_to_atomic_sync(9)percpu_ref_kill_and_confirm(9)percpu_ref_is_zero(9)percpu_ref_reinit(9)percpu_ref_resurrect(9)
and that's the whole page, bestie π«Ά source/version is ./lib, date is October 2026, and percpu_ref_switch_to_percpu(9) is signing off πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms