for_each_sg_page(9)
π 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_SIZEmeansPAGE_SIZE. not bytes of your choosing, not "whatever feels right today." it'sPAGE_SIZEand she means it π
π₯ SEE ALSO π₯
the kernel file: ./include/linux/scatterlist.h β and then the whole friend group shows up, fr fr:
sg_next(9)sg_assign_page(9)sg_set_page(9)sg_set_folio(9)sg_set_buf(9)sg_chain(9)sg_mark_end(9)sg_unmark_end(9)sg_dma_is_bus_address(9)sg_dma_mark_bus_address(9)sg_dma_unmark_bus_address(9)sg_dma_is_swiotlb(9)sg_dma_mark_swiotlb(9)sg_phys(9)sg_virt(9)sg_init_marker(9)sg_alloc_table_from_pages(9)sg_page_iter_page(9)sg_page_iter_dma_address(9)for_each_sg_dma_page(9)for_each_sgtable_page(9)for_each_sgtable_dma_page(9)
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
- 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