sg_alloc_table_from_pages(9)
πΈ sg_alloc_table_from_pages(9) πΈ
okay so this is the Kernel API Manual page for sg_alloc_table_from_pages(9), and bestie, it's literally the glow-up for turning a pile of pages into a proper sg table. no cap. π
β¨ NAME β¨
sg_alloc_table_from_pages β allocate and initialize an sg table from an array of pages π«Ά
πΈ SYNOPSIS πΈ
int sg_alloc_table_from_pages (struct sg_table *sgt , struct page **pages , unsigned int n_pages , unsigned int offset , unsigned long size , gfp_t gfp_mask );
π ARGUMENTS π
sgtβ the sg table header you're using π«Άpagesβ pointer to an array of page pointers β¨n_pagesβ how many pages are in the pages array π₯offsetβ offset from start of the first page to the start of a buffer πsizeβ number of valid bytes in the buffer (after offset) π¦gfp_maskβ GFP allocation mask π
π¦ DESCRIPTION π¦
okay so the whole vibe: this one allocates and initializes an sg table from a list of pages. Contiguous ranges of the pages are squashed into a single scatterlist node β yes, squashed, iconic behavior fr fr. π«Ά
A user may provide an offset at a start and a size of valid data in a buffer specified by the page array. The returned sg table is released by sg_free_table. don't forget that part, bestie, or it's giving leak energy π
π RETURN π
It's giving 0 on success, and a negative error on failure. periodt. π
π SEE ALSO π
go read these too, bestie, they're iconic:
- Kernel file
./include/linux/scatterlist.hπ 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_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)for_each_sgtable_dma_page(9)
mwah π this cutie came from ./include/linux, dated October 2026, and it's sg_alloc_table_from_pages(9) β slay and goodbye πβ¨
π¦ 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