sgl_free_n_order(9)
β¨ sgl_free_n_order β¨
okay bestie, welcome to the sgl_free_n_order page from the Kernel API Manual β yes we're in kernel land today, and yes you're gonna slay it π
πΈ NAME πΈ
sgl_free_n_order β free a scatterlist and its pages π
π¦ SYNOPSIS π¦
void sgl_free_n_order (struct scatterlist *sgl , int nents , int order );
like, that's the whole signature. no cap. β¨
π ARGUMENTS π
sglβ the scatterlist, and it's got one or more elements in it π«Άnentsβ the maximum number of elements to free. max, not exact. keep that in mind bestie πorderβ this is literally just the second argument you hand to__free_pagesβ
π NOTES π
okay so this is the part where you actually pay attention π
- if several scatterlists have been chained together and each chain element is freed separately, then it is essential to set
nentscorrectly β otherwise a page could get freed twice. and a double free is not the vibe. not iconic. avoid at all costs π - but if you'd rather free all the pages in a chained scatterlist at once? easy. just set
nentsto a high number and boom, done π
fr fr, that nents value is the whole plot. get it wrong and the kernel gets mad at you π
π₯ SEE ALSO π₯
they really said "include everything" huh π here's the whole friend group, all living 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), sg_alloc_table_from_pages_segment(9), sgl_alloc_order(9), sgl_alloc(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)
like. that's a lot of friends. collect them all π
and that's the page!! mwah π«Ά this one lives in ./lib and it's dated October 2026 β so go forth, free your scatterlist, and don't double-free anything. xoxo π
β¨π
π¦ 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