__remove_pages(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __remove_pages β€” Kernel API Manual, bestie edition

okay so picture this: you're deep in the kernel, you're doing memory hotplug things, and you need to yeet a whole chunk of pages out of existence (well, out of the mapping). That's this function. It's the manual's main character, and the manual name is literally "Kernel API Manual" β€” we love a title. πŸŽ€


✨ NAME ✨

__remove_pages β€” removes sections of pages, no cap 🫢


🌸 SYNOPSIS 🌸

void __remove_pages (unsigned long pfn , unsigned long nr_pages , struct
       vmem_altmap *altmap , struct dev_pagemap *pgmap );

like literally that's the whole signature, copy it exactly bestie, it's giving C function realness πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • pfn β€” the starting pageframe. ⚠️ it must be aligned to the start of a section, okay? not "roughly near", not "close enough" β€” aligned. the vibes must be immaculate.
  • nr_pages β€” how many pages you're removing. and it must be a multiple of section size. yes, the whole section size. don't come at me with a random number πŸ™ˆ
  • altmap β€” alternative device page map, or NULL if you're using the default memmap. pick one, it's not that deep πŸ’œ
  • pgmap β€” device page map, or NULL if it's not ZONE_DEVICE. if it's not a device zone, just pass NULL and move on ✨

πŸ”₯ DESCRIPTION πŸ”₯

so this is a generic helper function, and its whole job is to remove section mappings and sysfs entries for the section of memory we're removing. two things at once, multitasking icon behavior πŸ‘‘

BUT β€” and this is the important part, i'm being so serious right now β€” the caller needs to make sure that pages are marked reserved and that zones are adjusted properly by calling offline_pages. the function does not do that for you. that's on you. that's your moment. don't skip it 😭

tl;dr: __remove_pages is the cleanup crew, offline_pages is the bouncer. you need both. periodt. πŸ’€

⭐ SEE ALSO ⭐

bestie go read those too, iykyk 🌈


and that's the page! brought to you by ./mm, dated October 2026 β€” mwah, love u, go mark those pages reserved πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from