for_each_sg_page(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– for_each_sg_page(9) πŸ’–

ok so bestie, welcome to the Kernel API Manual β€” this is the page for for_each_sg_page, and honestly? it's giving "tiny macro, big responsibilities" ✨


🌸 NAME 🌸

for_each_sg_page β€” iterate over the pages of the given sg list πŸ¦‹

like, literally just loop through every page in your scatterlist. that's the whole vibe. no cap.


✨ SYNOPSIS ✨

for_each_sg_page (sglist , piter , nents , pgoffset );

she's short, she's sweet, she takes four (4) arguments and she will be judging you if you get them wrong πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • sglist β€” the sglist you wanna iterate over. your main character scatterlist, basically πŸ‘‘
  • piter β€” the page iterator, and she's doing a LOT of work here: she holds the current page, the current sg, and the sg_pgoffset. triple threat. respect her 🫢
  • nents β€” the maximum number of sg entries to iterate over. it's a cap, bestie, not a suggestion πŸ™ˆ
  • pgoffset β€” the starting page offset, measured in pages (not bytes!! in pages, ok, stay with me) ⭐

🌈 DESCRIPTION 🌈

so here's the tea β˜• β€” callers can use sg_page_iter_page to grab each page pointer. that's your move. that's how you actually get your hands on the page you're currently looking at πŸ’–

and in each loop? it operates on PAGE_SIZE units. PAGE_SIZE. that's the unit. that's the whole deal. every iteration = one PAGE_SIZE step forward, no funny business 🌸

lowkey important: PAGE_SIZE means PAGE_SIZE. not bytes of your choosing, not "whatever feels right today." it's PAGE_SIZE and she means it 😭

πŸ”₯ SEE ALSO πŸ”₯

the kernel file: ./include/linux/scatterlist.h β€” and then the whole friend group shows up, fr fr:

ok that's the whole squad, go say hi πŸ¦‹βœ¨


and that's the page, bestie πŸŽ€ source lives at ./include/linux, version stamp is October 2026, and yes she signed off as for_each_sg_page(9) because the icon knows exactly who she is πŸ’…πŸ’œ

πŸ“¦ where this page comes from