file_ref_put_close(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… file_ref_put_close β€” the "last one out, hit the lights" of file refs πŸŽ€

So this little cutie lives in the kernel API manual, section 9, and it's called file_ref_put_close. Its whole personality? Drop a reference, but do it expecting that reference was the last one and the count is gonna slide all the way down to FILE_REF_NOREF. ✨


🌸 SYNOPSIS 🌸

bool file_ref_put_close (file_ref_t *ref );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • ref β€” Pointer to the reference count. That's it, that's the whole argument list, bestie πŸ’–

πŸ”₯ DESCRIPTION πŸ”₯

Okay so semantically? It's literally equivalent to calling file_ref_put. Same vibe, same meaning, no cap. But it makes a trade-off: it gives up some performance when other CPUs are also out here modifying the refcount 😭 in exchange for higher performance when this particular call happens to be the last reference πŸ‘‘.

Here's the tea on why that matters: for the last reference, file_ref_put issues 2 atomics. One to drop the reference, and another to transition it to FILE_REF_DEAD. Two whole atomics, the way that's just so much work πŸ’€. This routine does all of it in one step, which is iconic β€” but to pull that off it has to pre-read the variable, and that pre-read decreases scalability πŸ“‰.

Use with close et al, but stick to file_ref_put by default. Like, this one is the special-occasion fit, not the everyday outfit πŸŽ€

⭐ SEE ALSO ⭐

Kernel file ./include/linux/file_ref.h:


okay that's the whole page, go forth and manage your references responsibly 🫢

sign-off szn: this one's from ./include/linux, dated October 2026, and it's the file_ref_put_close(9) page β€” mwah, catch you in the next manpage πŸ’œβœ¨

πŸ“¦ where this page comes from