bio_kmalloc(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– bio_kmalloc(9) β€” from the Kernel API Manual, bestie πŸ’–

okay so picture this: it's a kernel manual page, it lives in ./block, it's dated October 2026, and its whole entire name is bio_kmalloc(9). yes that's the title AND the manual name, we're keeping both, slay. now let's get into it ✨


🌸 NAME 🌸

bio_kmalloc β€” literally just kmalloc'ing a bio. that's it. that's the vibe. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

struct bio * bio_kmalloc (unsigned short nr_vecs , gfp_t gfp_mask );

✨ ARGUMENTS ✨

  • nr_vecs β€” the number of bio_vecs you want to allocate, bestie. count 'em.
  • gfp_mask β€” the GFP_* mask that gets handed off to the slab allocator. iykyk πŸ’…

πŸ‘‘ DESCRIPTION πŸ‘‘

so the whole thing here is you use kmalloc to allocate a bio β€” and yes, that includes the bvecs, they come along for the ride 🫢

the bio must be initialized using bio_init before you use it. no skipping steps, no cap.

to free a bio that came back from this function, you use kfree after calling bio_uninit. in that order. πŸ™ˆ

and good news β€” a bio returned from this function can totally be reused: just call bio_uninit before calling bio_init again. recycling is main character energy β™»οΈβœ¨

πŸ’€ okay important part, listen up: unlike bio_alloc or bio_alloc_bioset, allocations from this function are not backed by a mempool and can fail. and because of that: do not use this function for allocations in the file system I/O path. fr fr, don't do it.

🌈 RETURN 🌈

a pointer to the shiny new bio on success πŸŽ‰ β€” or NULL on failure 😭.


🧚 SEE ALSO 🧚

kernel file ./block/bio.c and honestly a whole friend group of functions, all of them:


⭐ and that's the page!! sign-off time: this little icon came from ./block, dated October 2026, and it answers to the name bio_kmalloc(9) πŸ’œ go forth and allocate responsibly, bestie πŸ“πŸ’–

πŸ“¦ where this page comes from