folio_release_kmap(9)
π folio_release_kmap β from the Kernel API Manual, bestie β¨
Okay so real talk, this one's a little function with big "clean up after yourself" energy, and honestly? Iconic behavior. It lives in the Kernel API Manual and it's here to unmap a folio and drop a refcount. Two jobs, one function, main character energy fr fr. π«Ά
β¨ SYNOPSIS β¨
void folio_release_kmap (struct folio *folio , void *addr );
Returns nothing (void), takes two args, does exactly what it says on the tin. No notes. π
π ARGUMENTS π
folioβ the folio you're releasing. Say bye to it, bestie. πaddrβ the address that a previous call tokmap_local_foliohanded back to you. Like, the exact one. Don't be out here making up addresses. π
πΈ DESCRIPTION πΈ
So the vibe here is: it's super common (directory handling is the classic example, iykyk) to kmap a folio. You map it, you poke at it, you do your little tasks. Gorgeous. But then somebody has to clean up, and that somebody is this function. π
What it does: it unmaps the folio, and it drops the refcount that was being held to keep the folio alive while we were accessing it. Both. Together. One call. Slay. β¨
Lowkey the whole point is that you don't leak a refcount by forgetting the second half β this bad boy handles the pair for you. π§
π₯ SEE ALSO π₯
All the siblings and cousins, in the order the page gives them, no cap:
Kernel file ./include/linux/highmem.h:
kmap(9)kunmap(9)kmap_to_page(9)kmap_flush_unused(9)kmap_local_page(9)kmap_local_folio(9)kmap_atomic(9)clear_user_page(9)clear_user_pages(9)clear_user_highpage(9)clear_user_highpages(9)vma_alloc_zeroed_movable_folio(9)memcpy_from_folio(9)memcpy_to_folio(9)folio_zero_tail(9)folio_fill_tail(9)memcpy_from_file_folio(9)folio_zero_segments(9)folio_zero_segment(9)folio_zero_range(9)
Like, the whole highmem friend group showed up to the group chat. Obsessed. π
Alright bestie, that's the whole page π¦ β this lil gem comes to you from ./include/linux and it's stamped October 2026, so go forth, release those kmaps, drop those refcounts, and remember: always clean up your mappings. Periodt. ππβ
π¦ 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