kmap(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– kmap(9) β€” the Kernel API Manual, bestie edition πŸ’–

okay so welcome to kmap(9), straight out of the Kernel API Manual, and no cap this is one of those little functions that has a bigger personality than it looks πŸ’…


✨ NAME ✨

kmap β€” map a page for long term usage πŸ—ΊοΈβœ¨


🌸 SYNOPSIS 🌸

void * kmap (struct page *page );

πŸŽ€ ARGUMENTS πŸŽ€

  • page β€” pointer to the page that's getting mapped 🫢

⭐ RETURN ⭐

it hands you back the virtual address of the mapping, periodt ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe check πŸ‘‘ β€” you can only invoke this from preemptible task context. why? because on 32bit systems with CONFIG_HIGHMEM enabled, this function might sleep 😴😭. like, it will literally nap on you. so don't be that girl calling it from somewhere that can't handle a snooze.

for systems with CONFIG_HIGHMEM=n, and also for pages sitting in the low memory area, it just returns the virtual address of the direct kernel mapping 🎯 easy, clean, slay.

the returned virtual address is globally visible and stays valid right up to the point where it gets unmapped via kunmap πŸ”“. and yes bestie, the pointer can be handed off to other contexts β€” it's not a one-context-only situation, it's main character energy that travels 🌈.

now the ⚠️ moment: for highmem pages on 32bit systems this can be slow 😬 because the mapping space is limited and protected by a global lock πŸ”’. and if there's no mapping slot available? the function blocks until a slot gets released via kunmap 🧚 it's giving "waiting in line at the club" energy fr fr.


πŸ‘€ SEE ALSO πŸ‘€

kernel file ./include/linux/highmem.h πŸ’« and all these icons:


🫢 friendly reminder bestie: preemptible task context only. she might sleep. do not test her.

and that's the whole page, no notes πŸ’œ this icon of a manpage lives under ./include/linux, dated October 2026, and answers to the name kmap(9) β€” mwah, go map something responsibly πŸ’…πŸŽ€

πŸ“¦ where this page comes from