set_ptes(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… set_ptes(9) β€” like, the kernel API manual, bestie ✨

Okay so welcome to the set_ptes(9) page from the Kernel API Manual β€” grab a strawberry πŸ“ and let's get into it, because this one is genuinely iconic if you're into page tables (and you are, or you wouldn't be here).


🌸 NAME 🌸

set_ptes β€” map consecutive pages to a contiguous range of addresses. That's the whole vibe. Consecutive pages, contiguous addresses, no cap. 🫢


✨ SYNOPSIS ✨

void set_ptes (struct mm_struct *mm , unsigned long addr , pte_t *ptep ,
pte_t pte , unsigned int nr );

She takes five things and returns nothing (void, queen of not needing to prove anything πŸ’…).


πŸŽ€ ARGUMENTS πŸŽ€

  • mm β€” the address space you're mapping the pages into. The whole neighborhood, basically.
  • addr β€” the address where the first page goes. Everyone else lines up behind her.
  • ptep β€” page table pointer for the first entry. Your starting point, your main character position.
  • pte β€” the page table entry for the first page. The blueprint.
  • nr β€” number of pages to map. How many besties are we bringing.

πŸ”₯ DESCRIPTION πŸ”₯

Okay so here's the tea, and it's important tea, so read carefully pookie:

When nr==1, the initial state of pte may be present or not present, and the new state may be present or not present. Free and easy. Lowkey the chill case.

When nr>1, the initial state of all the ptes must be not present, and the new state must be present. No exceptions. That's the rule, fr fr. 😀

Also β€” this function may be overridden by the architecture, or the architecture can define set_pte and PFN_PTE_SHIFT. So like, your arch might have opinions. Respect them. 🧚


πŸ’€ CONTEXT πŸ’€

Three things you need to know before you call her, and yes they're all mandatory:

  • The caller holds the page table lock.
  • The pages all belong to the same folio.
  • The PTEs are all in the same PMD.

Squad requirements. Don't show up without them. 🎯


πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./include/linux/pgtable.h, plus this absolute friend group right here β€” go say hi to all of them:


and that's the page, bestie 🌈 This one lives under ./include/linux and the doc crew stamped it October 2026 β€” so yeah, go map those consecutive pages, stay in your folio, and don't forget the lock. mwah πŸ’–πŸ¦‹

πŸ“¦ where this page comes from