vm_insert_pages(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

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

okay so bestie, gather round, because this one's a banger. We're in the Kernel API Manual today and the star of the show is vm_insert_pages(9). Yes it's a mouthful, no we're not changing it, it's iconic like that. πŸŽ€


✨ NAME ✨

vm_insert_pages β€” insert multiple pages into user vma, batching the pmd lock. that's it. that's the whole vibe. lowkey a whole function in one line. πŸ’…


🌸 SYNOPSIS 🌸

int vm_insert_pages (struct vm_area_struct *vma , unsigned long addr ,
       struct page **pages , unsigned long *num );

copy it exactly, don't be cute with it, the compiler is not your friend like that. 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • vma β€” the user vma to map to. this is the destination, the main character we're all here for.
  • addr β€” target start user address of these pages. the starting line, literally.
  • pages β€” source kernel pages. the goods. the actual pages being brought over. ✨
  • num β€” the sneaky two-faced one, bestie, watch out:
    • in: number of pages to map.
    • out: number of pages that were *not* mapped. and 0 means all pages were successfully mapped. so zero is the good outcome here, which feels illegal but okay we roll with it. 😭

πŸ’– DESCRIPTION πŸ’–

Preferred over vm_insert_page when inserting multiple pages. like, if you've got a whole friend group of pages, don't send them one at a time, use this one. batching the pmd lock is the entire point and it ate. πŸ”₯

In case of error, we may have mapped a subset of the provided pages. It is the caller's responsibility to account for this case. not me warning you that a partial mapping can absolutely happen and then just... handing you the bill. πŸ™ˆ this is on you to handle, bestie, no cap. check your num and do the math.

The same restrictions apply as in vm_insert_page. same rules, different friend. if you don't know them, go read that one β€” iykyk. πŸ’€


πŸ‘‘ SEE ALSO πŸ‘‘

The kernel file ./mm/memory.c is where all this lives, and honestly the whole ./mm girlies are here for the cross-references:

that's the whole squad. every single one. don't skip anybody, that's rude. 🌈


🧚 sign-off 🧚

okay that's the page!! this one's chilling in ./mm and the manual itself is dated October 2026 β€” the version info in the footer says Kernel API Manual and the date, and since we're being cute about it: consider it stamped, signed, and blessed. go map some pages bestie, you're gonna slay. πŸ’œπŸ¦‹β­ πŸŽ€

πŸ“¦ where this page comes from