__sg_alloc_table(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’« __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 be NULL, so no pressure 🫢
  • nents_first_chunk β€” how many entries are in that (preallocated) first scatterlist chunk. and 0 means 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