__sg_alloc_table(9)
π« __sg_alloc_table β Kernel API Manual edition β¨
okay so bestie, we're in the Kernel API Manual today and the star of the show is __sg_alloc_table π
yes that's the one with the double underscore, she's the internal queen, main character energy but lowkey. Let's get into it π
πΈ NAME πΈ
__sg_alloc_table β allocate and initialize an sg table, but likeβ¦ with your allocator of choice π«Ά
π¦ SYNOPSIS π¦
int __sg_alloc_table (struct sg_table *table , unsigned int nents ,
unsigned int max_ents , struct scatterlist *first_chunk , unsigned int
nents_first_chunk , gfp_t gfp_mask , sg_alloc_fn *alloc_fn );
that's a whole lot of arguments and honestly? she ate π₯ every single one is doing her job, no cap.
π ARGUMENTS π
tableβ the sg table header you're gonna use. the lil control center of the whole operation β¨nentsβ how many entries are in the sg list. the headcount, the guest list, the vibe check πmax_entsβ the maximum number of entries the allocator hands back in a single call. like, she gives you up to this many per round, no more πfirst_chunkβ the first SGL, if you already got it preallocated. and yes, it may beNULL, so no pressure π«Άnents_first_chunkβ how many entries are in that (preallocated) first scatterlist chunk. and0means nope, you the user didn't provide any such preallocated chunk at all πgfp_maskβ the GFP allocation mask. the whole allocation mood, iykyk πalloc_fnβ the allocator to use. literally your chosen one, your fave π
π DESCRIPTION π
so this function returns a table that's nents long, periodt π
the allocator is defined to return scatterlist chunks of maximum size max_ents. so if nents is bigger than max_ents, the scatterlists get chained in units of max_ents β like a little linked chain of chunks, iconic behavior honestly πβ¨
β NOTES β
okay important bestie, listen: if this function returns non-0 (eg failure π), the caller must call __sg_free_table to cleanup any leftover allocations. don't leave the leftovers hanging, that's not cute π
π SEE ALSO π
Kernel file ./lib/scatterlist.c β and the whole scatterlist friend group π§:
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_append_table_from_pages(9), sg_alloc_table_from_pages_segment(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)
and that's the page π brought to you straight outta ./lib, dated October 2026, and the title's __sg_alloc_table(9) in case you forgot already (you didn't, you're slaying) πβ¨ stay hydrated, free your tables, bye 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