__remove_pages(9)
π
__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, orNULLif you're using the default memmap. pick one, it's not that deep πpgmapβ device page map, orNULLif it's notZONE_DEVICE. if it's not a device zone, just passNULLand 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_pagesis the cleanup crew,offline_pagesis the bouncer. you need both. periodt. π
β SEE ALSO β
- Kernel file
./mm/memory_hotplug.cβ the source, the mothership, the origin story π§ __add_memory_driver_managed(9)add_memory_driver_managed(9)try_offline_node(9)__remove_memory(9)offline_and_remove_memory_ranges(9)
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
- 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