clear_user_pages(9)
π clear_user_pages β the kernel API manual, bestie edition π
okay so real talk, this one is a Kernel API Manual page (iykyk), and it's about clear_user_pages. strap in π
β¨ NAME β¨
clear_user_pages β clears a page range so it can be mapped into user space. yes bestie, we're zeroing pages before they go hang out with userspace π
πΈ SYNOPSIS πΈ
void clear_user_pages (void *addr , unsigned long vaddr , struct page
*page , unsigned int npages );
literally the whole signature, no notes, copy it exactly π
π¦ ARGUMENTS π¦
addrβ the start address. that's it, that's the vibe β¨vaddrβ the start address of the user mapping (different address, same energy π)pageβ the start pagenpagesβ how many pages we're talking about π
π DESCRIPTION π
okay so here's the tea β β this function assumes the region (addr, +npages) has already been validated. like, somebody else did the vibe check already. so it does no exception handling. none. zero. not a single one π that's not a bug, that's just the contract, bestie.
and then: if the architecture provides a clear_user_page, use that one β slay, use the native one π
. otherwise, we can safely use clear_pages. iconic fallback behaviour, no cap π«Ά
β SEE ALSO β
the whole friend group π β kernel file ./include/linux/highmem.h, plus:
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_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)folio_release_kmap(9)
π reminder bestie: the no-exception-handling thing is load-bearing β that region better be validated before you call this, fr fr.
and that's the page!! sign-off time π this one lives over in ./include/linux, dated October 2026, and it's filed under clear_user_pages(9). mwah, go clear some pages πβ¨π¦
π¦ 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