for_each_sgtable_dma_page(9)
β¨ for_each_sgtable_dma_page β¨
okay so bestie, welcome to the Kernel API Manual β yes this is a real manual page, no cap, and it's about the cutest lil loop macro in the DMA-adjacent scatterlist cinematic universe π¦
πΈ NAME πΈ
for_each_sgtable_dma_page β the one that iterates over the DMA mapped sg_table object π
like it literally just loops, that's the whole vibe
π SYNOPSIS π
for_each_sgtable_dma_page (sgt , dma_iter , pgoffset );
that's it. three little args, iconic, ate, periodt β¨
π ARGUMENTS π
sgtβ thesg_tableobject you're iterating over, main character energy, show it some respect π«Άdma_iterβ the DMA page iterator, and it's the one holding the current page, so like, it's carrying the whole loop honestly πpgoffsetβ your starting page offset, measured in pages, not bytes, don't come at me with bytes π
π₯ DESCRIPTION π₯
So what it does: it iterates over all the DMA mapped pages in the buffer described by a scatterlist stored in the given sg_table object. all of them. every single one. no skipping π
Also go peek at for_each_sg_dma_page while you're here β see also, bestie, it's giving sibling energy π
And real talk, the important detail: in each loop it operates on PAGE_SIZE unit β so every step of the loop is one whole page, not a byte, not a nibble, a page. write that down π
π SEE ALSO π
Kernel file ./include/linux/scatterlist.h β and honestly the whole scatterlist friend group came to the function:
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_page(9)
like that's the whole group chat, everyone showed up, obsessed π
okay mwah, that's the page!! this lil icon lives in ./include/linux (that's the source/version, cute right), dated October 2026, and it's brought to you by the for_each_sgtable_dma_page(9) girlies. bye bestie, go iterate responsibly π§ββοΈπ
π¦ 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