mtrr_add_page(9)
π
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 istrue, 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 π
mtrr_rendezvous_handler(9)set_mtrr(9)mtrr_add(9)mtrr_del_page(9)mtrr_del(9)arch_phys_wc_add(9)mtrr_bp_init(9)mtrr_save_state(9)
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
- 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