sg_set_folio(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… sg_set_folio (kernel API manual, bestie edition)

okay so this is sg_set_folio(9) from the Kernel API Manual, and it's literally the "please stop poking the folio pointer with your bare hands" function 🫢


✨ NAME ✨

sg_set_folio β€” set an sg entry so it points at the given folio πŸŽ€


🌸 SYNOPSIS 🌸

void sg_set_folio (struct scatterlist *sg , struct folio *folio , size_t
len , size_t offset );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • sg β€” the SG entry. the main character of this whole operation πŸ’…
  • folio β€” the folio itself. yes, that folio πŸ“
  • len β€” length of the data. how many bytes we're talking about ✨
  • offset β€” offset into the folio. where in the folio we're starting, iykyk 🌸

πŸ’– DESCRIPTION πŸ’–

Use this function to set an sg entry pointing at a folio. and like β€” never assign the folio directly, okay?? 😭 not even once.

why, you ask? because we encode sg table information in the lower bits of the folio pointer. so if you go around assigning it raw, you're lowkey stomping on that encoded info and it will not be slay. the encoding is the whole vibe check here πŸ‘‘

when you need to look up the page belonging to an sg entry, see sg_page. that's the one you want for that job, fr fr 🧚

no cap: this is one of those "use the setter, don't touch the pointer" situations. the function is the gatekeeper and honestly it's giving main character energy 🌈

πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./include/linux/scatterlist.h, plus the whole scatterlist friend group πŸ’œ:


πŸŽ€ and that's the page!! sourced straight from ./include/linux, dated October 2026 β€” mwah, go set some folios responsibly, bestie πŸ’…βœ¨πŸ”₯

πŸ“¦ where this page comes from