clear_user_pages(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 page
  • npages β€” 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:


πŸ’€ 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