percpu_ref_switch_to_atomic(9)
β¨ NAME β¨
percpu_ref_switch_to_atomic β switch a percpu_ref to atomic mode, bestie π
Okay so this is from the Kernel API Manual, and itβs the little switch-up that flips a percpu_ref from percpu mode into atomic mode. Slay. β¨
π SYNOPSIS π
void percpu_ref_switch_to_atomic (struct percpu_ref *ref ,
percpu_ref_func_t *confirm_switch );
π ARGUMENTS π
refβ thepercpu_refyouβre switching to atomic mode. Main character energy, no cap πconfirm_switchβ optional confirmation callback. Itβs optional, but if you pass it, remember the rule: it may not block π«Ά
πΈ DESCRIPTION πΈ
Okay so first things first, bestie: do not reach for this for your usual reference counting. Thereβs literally no reason to use this function for the usual reference counting. Use percpu_ref_kill or percpu_ref_kill_and_confirm instead. Periodt. π
This function schedules switching ref to atomic mode. All its percpu counts will be collected to the main atomic counter. On completion, when all CPUs are guaranteed to be in atomic mode, confirm_switch is invoked β and note that confirm_switch may not block. Like, no blocking allowed, okay? π
This function may be invoked concurrently with all the get/put operations, and it can safely be mixed with kill and reinit operations. No cap. Also note: ref will stay in atomic mode across kill/reinit cycles until percpu_ref_switch_to_percpu is called. So itβs not doing a little temporary vibe β it stays atomic until you switch it back. π¦
β οΈ Blocking tea: 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. π«Ά
π¦ SEE ALSO π¦
Kernel file ./lib/percpu-refcount.c and these iconic little references:
percpu_ref_init(9)percpu_ref_exit(9)percpu_ref_switch_to_atomic_sync(9)percpu_ref_switch_to_percpu(9)percpu_ref_kill_and_confirm(9)percpu_ref_is_zero(9)percpu_ref_reinit(9)percpu_ref_resurrect(9)
Made with π from ./lib, October 2026 β percpu_ref_switch_to_atomic(9) β¨π
π¦ 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