vread_iter(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’œ vread_iter(9) β€” the Kernel API Manual page you didn't know you needed

okay so first things first: this is a page from the Kernel API Manual, section 9, and it's about vread_iter. it's lowkey niche but it's giving "trusted gatekeeper of vmalloc" energy and i'm obsessed πŸŽ€


✨ NAME ✨

vread_iter β€” read vmalloc area in a safe way to an iterator.

like, safely. no cap. πŸ¦‹


🌸 SYNOPSIS 🌸

long vread_iter (struct iov_iter *iter , const char *addr , size_t count
);

she returns a long, she takes three things, she's an icon πŸ’…


πŸ“ ARGUMENTS πŸ“

  • iter β€” the iterator to which data should be written. yeah, "read" function, "written" arg, that's just how she rolls πŸ™ˆ
  • addr β€” the vm address. the starting point. the main character of the address space ✨
  • count β€” number of bytes to be read. the vibes-per-byte budget 🌈

πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the tea β˜• this function first does a vibe check on addr β€” it checks that addr is a valid vmalloc'ed area, and then copies data from that area into the given iterator.

if the memory range [addr...addr+count) includes some valid address, the data gets copied to the proper area of iter. slay. but if there are memory holes, those get zero-filled β€” no drama, just zeroes πŸ’€

and a IOREMAP area? treated as a memory hole, and no copy is done. she said "not my problem, bestie" πŸ™…β€β™€οΈ

also, if [addr...addr+count) doesn't include any intersection with an alive vm_struct area, it returns 0. periodt.


🫢 NOTE 🫢

genuinely important one, so listen up πŸ’– In usual ops, vread_iter is never necessary, because the caller should know the vmalloc area is valid and can just use memcpy. fr fr.

this one is for routines which have to access vmalloc area without any information, as /proc/kcore. she's the emergency contact of the vmalloc world 😭


⭐ RETURN ⭐

she returns the number of bytes for which addr and iter should be advanced (same number as count) β€” or 0 if [addr...addr+count) doesn't include any intersection with a valid vmalloc area. simple, honest, iconic πŸ‘‘


πŸ¦‹ SEE ALSO πŸ¦‹

Kernel file ./mm/vmalloc.c and honestly her whole friend group:

that's the whole group chat, no one's getting left on read πŸ’œ


and that's the page!! mwah πŸ’‹ this lil slice of the Kernel API Manual comes to you from ./mm, dated October 2026, page vread_iter(9) β€” go read some vmalloc, bestie, you got this 🧚✨

πŸ“¦ where this page comes from