percpu_ref_tryget_live(9)
π percpu_ref_tryget_live(9) β from the Kernel API Manual, bestie
okay so real talk, this one is a tiny function but it has lore. Sit down, hydrate, and let's get into it π«Ά
β¨ NAME β¨
percpu_ref_tryget_live β the "try to increment a live percpu refcount" girlie. She's giving cautious optimism. She's giving "I'll bump your count but only if you're still alive" π
β¨ SYNOPSIS β¨
bool percpu_ref_tryget_live (struct percpu_ref *ref );
β¨ ARGUMENTS β¨
refβ thepercpu_refyou're trying to try-get πΈ like that's literally the whole job. Just the percpu_ref to try-get, no cap.
β¨ DESCRIPTION β¨
So here's the vibe: percpu_ref_tryget_live increments a percpu refcount unless it has already been killed. That's it, that's the whole personality.
It returns true on success and false on failure. Iconic. Binary. Periodt β¨
Now for the part you actually need to internalize, bestie, because this is where people get Gotβ’:
Completion of percpu_ref_kill in itself doesn't guarantee that this function will fail. π
Yes I know. I know. Take a sec. The kill finishing does not automatically mean percpu_ref_tryget_live starts failing β those are two different things, okay?
For that guarantee, you want percpu_ref_kill_and_confirm. Once the confirm_kill callback is invoked, then it's guaranteed that no new reference will be given out by percpu_ref_tryget_live. That's the lock-in moment. That's when the door actually closes π₯
And one more safety note so nothing jumps you:
This function is safe to call as long as ref is between init and exit. Outside that window? Not our problem, not our era π
β¨ SEE ALSO β¨
Kernel file ./include/linux/percpu-refcount.h β and the whole friend group:
percpu_ref_kill(9)percpu_ref_get_many(9)percpu_ref_get(9)percpu_ref_tryget_many(9)percpu_ref_tryget(9)percpu_ref_tryget_live_rcu(9)percpu_ref_put_many(9)percpu_ref_put(9)percpu_ref_is_dying(9)
and that's the page, bestie π sourced fresh out of ./include/linux in the October 2026 edition of the Kernel API Manual β go forth and try-get responsibly, mwah ππ
π¦ 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