kunit_kmalloc(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… kunit_kmalloc

okay so bestie, this is kunit_kmalloc(9) β€” the kernel API manual page, and yes the manual name goes right up there, we're not copying the header line, we're folding it in like a cute little hair clip πŸŽ€

It does exactly what kmalloc() does… except the allocation is test managed. Periodt. ✨


✨ SYNOPSIS ✨

void * kunit_kmalloc (struct kunit *test , size_t size , gfp_t gfp );

🫢 ARGUMENTS 🫢

  • test β€” the test context object. your main character of the operation ngl.
  • size β€” the size, in bytes, of the memory you want. how much memory is it giving? that much. πŸ’…
  • gfp β€” the flags handed straight down to the underlying kmalloc.

🌸 DESCRIPTION 🌸

Like, kmalloc() but the allocation is test managed, so you don't have to stress about cleaning it up yourself. Iconic behavior honestly.

For the full lore, go see kmalloc and kunit_kmalloc_array β€” they've got more info for you.

⚠️ heads up bestie: some internal context data is also allocated with GFP_KERNEL, no matter what gfp you pass in. so your flags aren't the whole story, iykyk πŸ™ˆ

πŸ¦‹ SEE ALSO πŸ¦‹

The whole friend group, fr fr β€” all of these live in the kernel file ./include/kunit/test.h:


and that's the whole page, bestie πŸ’– this one's sourced from ./include/kunit, dated October 2026, and it's filed under kunit_kmalloc(9) β€” slay, go write some tests, mwah πŸ§šβ€β™€οΈβœ¨

πŸ“¦ where this page comes from