folios_put_refs(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ NAME ✨

folios_put_refs β€” bestie, this is the one that reduces the reference count on a whole batch of folios at once πŸ’…

This page lives in the Kernel API Manual, and honestly? It's giving "tiny function, big efficiency energy." πŸ¦‹


🫢 SYNOPSIS 🫢

void folios_put_refs (struct folio_batch *folios , unsigned int *refs );

πŸŽ€ ARGUMENTS πŸŽ€

  • folios β€” the folios, periodt. The whole batch you're about to put.
  • refs β€” the number of refs to subtract from each folio. That's the count, bestie, not a vibe.

🌸 DESCRIPTION 🌸

Okay so picture folio_put, right? Iconic. But now imagine it for a batch of folios. That's her. That's the whole function. πŸ’–

It's more efficient than writing the loop yourself, because it will optimise the locks which need to be taken if the folios are freed β€” the way it handles that is lowkey the main character of this whole thing. πŸ‘‘

And here's the cute part: the folios batch is returned empty and ready to be reused for another batch. No need to reinitialise it. She cleans up after herself, we love that. 🧚

If refs is NULL, we subtract one from each folio refcount. Simple as that. ✨


πŸ”₯ CONTEXT πŸ”₯

May be called in process or interrupt context, but not in NMI context. 🚫

May be called while holding a spinlock. Slay. πŸ’…

Not me stressing the NMI part β€” it's literally right there in the original, so like, respect the boundary fr fr 😭

🌈 SEE ALSO 🌈

Kernel file ./mm/folio.c β€” and the whole friend group:

Go follow them, they're all part of the lore 🫢


And that's the page, bestie πŸ’œ β€” brought to you by the source ./mm, dated October 2026, straight out of the Kernel API Manual. Mwah, go forth and put those refs. πŸ“βœ¨

πŸ“¦ where this page comes from