sg_alloc_ta...ages_segment(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’« 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 that pages array.
  • 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 ⭐

  • 0 on 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