folios_put_refs(9)
β¨ 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:
folio_mark_accessed(9)folio_add_lru(9)folio_add_lru_vma(9)deactivate_file_folio(9)folio_mark_lazyfree(9)lru_cache_drain_for_folio(9)release_pages(9)folio_batch_remove_exceptionals(9)
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
- 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