mtrr_add_page(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… mtrr_add_page(9) β€” the mtrr_add_page page, but make it make sense

okay so bestie, you're in the Kernel API Manual and this is the page for mtrr_add_page. Sit down, hydrate, let's go. 🫢


✨ NAME ✨

mtrr_add_page β€” literally just "add a memory type region". That's the whole vibe. πŸŽ€


🌸 SYNOPSIS 🌸

int mtrr_add_page (unsigned long base , unsigned long size , unsigned int type , bool increment );

yep, that's the whole signature, no notes. πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • base β€” the physical base address of your region, but measured in pages (and a page here is in units of 4 kB β€” read the exclamation mark, it's there for a reason, bestie 😭).
  • size β€” physical size of the region, also in pages (4 kB).
  • type β€” which flavour of MTRR you want. Pick from the list below, no off-menu ordering πŸ™ˆ.
  • increment β€” if this is true, we do usage counting on the region. like a little tally mark for your region 🧚.

πŸ’– DESCRIPTION πŸ’–

so. Memory type region registers are the things that control caching on newer Intel processors and on non-Intel ones too (equal opportunity caching ✨). This function is how a driver politely requests that an MTRR gets added.

The details and the hardware specifics of how each processor actually implements it? Completely hidden from you, the caller. Not your problem, iconic behaviour πŸ‘‘. But β€” and this is the important part β€” you should still expect to need to provide a power of two size on an equivalent power of two boundary. Like, the universe needs the numbers to line up. no cap.

If the region can't be added β€” either because all the regions are already in use, or because the CPU just cannot support it β€” you get a negative value back. Not a vibe. πŸ’€

On success you get the register number for this entry returned… but please, please treat it as a cookie only. It's a little snack, not a promise. πŸ“

On a multiprocessor machine the changes get made to all the processors. On x86 this is required by the Intel processors β€” non-negotiable, the whole squad is getting the update. 🌈

The available types are:

  • MTRR_TYPE_UNCACHABLE β€” No caching. none. zero. nothing gets cached. 🚫
  • MTRR_TYPE_WRBACK β€” Write data back in bursts whenever.
  • MTRR_TYPE_WRCOMB β€” Write data back soon but allow bursts.
  • MTRR_TYPE_WRTHROUGH β€” Cache reads but not writes.

πŸ› BUGS πŸ›

Ok so known issue time, gather round πŸ”₯: this needs a quiet flag for the cases where drivers do not mind failures and do not wish system log messages to be sent. Right now it's out here announcing everything. loud. main character energy, but in a bad way 😭.


⭐ SEE ALSO ⭐

Kernel file ./arch/x86/kernel/cpu/mtrr/mtrr.c β€” go read the source, iykyk πŸ’œ


and that's the page!! πŸŽ€ sourced from ./arch/x86/kernel/cpu/mtrr, dated October 2026 β€” go off, kernel docs, we love to see it. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from