__sg_next(9)
β¨ __sg_next β the kernel API manual, bestie edition β¨
okay so this page is from the Kernel API Manual, section 9 (kernel internals, iykyk). it's called __sg_next and honestly? she's a tiny little function with main character energy. let's get into it π
πΈ NAME πΈ
__sg_next β return the next scatterlist entry in a list
like, literally what it says on the tin. you give her one scatterlist entry, she hands you the next one. no cap. π¦
π SYNOPSIS π
struct scatterlist * __sg_next (struct scatterlist *sg );
that's the whole signature, bestie β one arg in, one pointer out, and it returns a struct scatterlist *. periodt.
π ARGUMENTS π
sgβ the current sg entry. like, the one you're standing on right now. she needs to know where you are before she can tell you where you're going π«Ά
π₯ DESCRIPTION π₯
okay so here's the whole vibe check, and it's genuinely so simple:
- if the entry you passed in is the last one, she returns
NULL. that's it. no next entry, no drama, justNULLπ - otherwise, she steps to the next element in the array β that's
sg+1, literally just the next one, the way that pointer arithmetic ate π - then: if that next thing is a chain pointer, she follows it. (chains are how sg lists get longer than the array, iykyk π)
- otherwise (no chain pointer, just a regular entry), she just returns the pointer to the current element.
so to recap the flow: last? β NULL. chain pointer? β follow it π. anything else? β hand back the pointer and keep it moving β¨
β SEE ALSO β
the kernel file that lives here is:
./drivers/gpu/drm/i915/i915_scatterlist.h
and the whole friend group she runs with:
__for_each_sgt_daddr(9)__for_each_daddr_next(9)for_each_sgt_page(9)i915_sg_dma_sizes(9)struct i915_refct_sgt_ops(9)struct i915_refct_sgt(9)i915_refct_sgt_put(9)i915_refct_sgt_get(9)__i915_refct_sgt_init(9)
go say hi to them too, they're all in the same friend group π§π
and that's the page!! little sign-off moment π β this one's from ./drivers/gpu/drm/i915, dated October 2026, and it's the __sg_next(9) page. mwah π go read a scatterlist or something, ily π
π¦ 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