sg_alloc_ta...ages_segment(9)
π« sg_alloc_ta...ages_segment(9) β the Kernel API Manual glow-up π«
okay so bestie, listen. we're in the Kernel API Manual, section 9, and today's main character is sg_alloc_table_from_pages_segment β yes the name is a whole mouthful, no I will not be shortening it, it's iconic and we respect it. π
β¨ SYNOPSIS β¨
int sg_alloc_table_from_pages_segment (struct sg_table *sgt , struct
page **pages , unsigned int n_pages , unsigned int offset , unsigned
long size , unsigned int max_segment , gfp_t gfp_mask );
look at her. seven arguments. absolute queen behavior. π
πΈ ARGUMENTS πΈ
sgtβ the sg table header you're gonna use. the vessel. the container. the moment. πpagesβ a pointer to an array of page pointers, fr fr.n_pagesβ how many pages are actually chillin' in thatpagesarray.offsetβ the offset from the start of the first page to the start of your buffer (iykyk).sizeβ number of valid bytes in the buffer, after the offset. so like, the real ones only.max_segmentβ maximum size of a scatterlist element, in bytes. the ceiling. the limit. the vibe check.gfp_maskβ the GFP allocation mask. π§
π¦ DESCRIPTION π¦
so what she does is: allocate and initialize an sg table from a list of pages. simple enough, right? but here's the slay β contiguous ranges of the pages get squashed into a single scatterlist node, up to the maximum size you specified in max_segment. squashed! combined! efficient! we love a consolidation arc. π₯
and a user may also provide an offset at the start and a size of valid data in a buffer specified by the page array. so you get to be precise about where the real data lives. no cap, very thoughtful.
π«Ά important bestie note: the returned sg table is released by sg_free_table. don't just leave her hanging, okay? clean up after yourself. π
β RETURN β
0on success π- negative error on failure π
that's it. that's the whole scale. zero or sadness.
π SEE ALSO π
so many friends, so many links. all of these live in the Kernel file ./lib/scatterlist.c:
sg_nents(9), sg_nents_for_len(9), sg_nents_for_dma(9), sg_last(9), sg_init_table(9), sg_init_one(9), __sg_free_table(9), sg_free_append_table(9), sg_free_table(9), __sg_alloc_table(9), sg_alloc_table(9), sg_alloc_append_table_from_pages(9), sgl_alloc_order(9), sgl_alloc(9), sgl_free_n_order(9), sgl_free_order(9), sgl_free(9), sg_miter_start(9), sg_miter_skip(9), sg_miter_next(9), sg_miter_stop(9), sg_copy_buffer(9), sg_copy_from_buffer(9), sg_copy_to_buffer(9), sg_pcopy_from_buffer(9), sg_pcopy_to_buffer(9), sg_zero_buffer(9), extract_iter_to_sg(9)
literally the whole scatterlist group chat. π
and that's the page! brought to you from ./lib, dated October 2026, filed under sg_alloc_ta...ages_segment(9) β mwah, go build something iconic bestie πβ¨
π¦ 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