PMAP_QUICK_ENTER_PAGE(9)
π PMAP_QUICK_ENTER_PAGE π
okay bestie, so this is a page from the Kernel Developer's Manual β section 9, the deep lore section β and it's literally about yeeting a single page into kernel address space for like two seconds and then putting it back. so iconic of it.
β¨ NAME β¨
pmap_quick_enter_page, pmap_quick_remove_page β manage fast, single-page kernel address space mappings π¦
like, the speedrun version of mapping. no cap.
πΈ SYNOPSIS πΈ
#include <sys/param.h>
#include <vm/vm.h>
#include <vm/pmap.h>
vm_offset_t
pmap_quick_enter_page(vm_page_t m);
void
pmap_quick_remove_page(vm_offset_t kva);
π DESCRIPTION π
So pmap_quick_enter_page() takes one single page, m, and slots it into a preallocated address in kernel virtual address (KVA) space. that's it, that's the whole vibe. it's made for temporary mappings that you're only gonna use for a very short period β think a copy operation on the page contents. blink and it's gone, fr fr.
Then pmap_quick_remove_page() does the clean-up era: it removes a mapping that pmap_quick_enter_page() made earlier at kva, which frees up that KVA frame so pmap_quick_enter_page() can reuse it. recycle, reduce, reuse π«Ά
okay now the part where you gotta pay attention. π On many architectures, pmap_quick_enter_page() uses a per-CPU pageframe. When that's the case, it must disable preemption on the local CPU. and the corresponding pmap_quick_remove_page() call is what re-enables preemption. so, consequence time:
it is not safe for machine-independent code to sleep or perform locking operations while holding these mappings. like, don't do it. π
Also β current implementations only guarantee the availability of a single page for the calling thread, so calls to pmap_quick_enter_page() must not be nested. one at a time, bestie. one. at. a. time.
Good news tho: neither pmap_quick_enter_page() nor pmap_quick_remove_page() sleeps, and pmap_quick_enter_page() always returns a valid address. always. periodt. β¨ It's safe to use these functions under all types of locks β except spin mutexes. and it's also safe to use them in all thread contexts β except primary interrupt context. so like, everything except that one specific thing.
And one more rule, don't skip it: the page must not be swapped or otherwise reused while the mapping is active. it has to be either wired or held, or it has to belong to an unmanaged region such as I/O device memory. no exceptions, this is the vibe check. π
π RETURN VALUES π
pmap_quick_enter_page() returns the kernel virtual address that is mapped to the page m. that's your prize. take it. π
π¦ SEE ALSO π¦
π AUTHORS π
This manual page was written by Jason A Harmening <jah@FreeBSD.org>. absolute legend, we stan. π
and that's the whole page, bestie β Debian, dated August 6, 2015, PMAP_QUICK_ENTER_PAGE(9). slay, go map something (briefly) πβ¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2015 Jason A. Harmening <jah@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms