for_each_sgtable_page(9)
π« for_each_sgtable_page(9) π«
okay bestie, welcome to the Kernel API Manual page for for_each_sgtable_page β yes that's a lot of underscores, no we're not gonna shorten it, it's iconic and it commits π
β¨ NAME β¨
for_each_sgtable_page β the little macro that iterates over all pages in the sg_table object π¦
πΈ SYNOPSIS πΈ
for_each_sgtable_page (sgt , piter , pgoffset );
literally just three things and you're looping, periodt β¨
π ARGUMENTS π
sgtβ thesg_tableobject you're iterating over. the main character, fr fr πpiterβ the page iterator, holding the current page. think of it as the vibe tracker for where you're at rn π§pgoffsetβ the starting page offset, measured in pages. not bytes, bestie, pages π
π«Ά DESCRIPTION π«Ά
so here's the tea: this macro iterates over all the memory pages in the buffer that's described by a scatterlist, which is stored inside the sg_table object you passed in βπ
see also for_each_sg_page if you're curious about the sibling.
and the important bit β in each loop it operates on a PAGE_SIZE unit. so every spin around the loop is exactly one page's worth, no cap π₯
π₯ SEE ALSO π₯
Kernel file ./include/linux/scatterlist.h, plus this whole friend group of related man pages:
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_page(9)for_each_sg_dma_page(9)for_each_sgtable_dma_page(9)
go read them all, i'll wait π
okay that's the whole page, you ate that π β this one comes to you from ./include/linux, dated October 2026, and that's the vibe check complete. slay, bye! πβ
π¦ 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