kunit_kmalloc(9)
π 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 underlyingkmalloc.
πΈ 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 withGFP_KERNEL, no matter whatgfpyou 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:
enum kunit_status(9),struct kunit_case(9)KUNIT_CASE(9),KUNIT_CASE_ATTR(9),KUNIT_CASE_SLOW(9),KUNIT_CASE_PARAM(9),KUNIT_CASE_PARAM_ATTR(9),KUNIT_CASE_PARAM_WITH_INIT(9)struct kunit_suite(9),struct kunit(9),kunit_test_suites(9),kunit_test_init_section_suites(9)kunit_kmalloc_array(9),kunit_kfree(9),kunit_kzalloc(9),kunit_kcalloc(9),kunit_kfree_const(9),kunit_kstrdup(9),kunit_kstrdup_const(9),kunit_attach_mm(9),kunit_vm_mmap(9)kunit_mark_skipped(9),kunit_skip(9),kunit_info(9),kunit_warn(9),kunit_err(9),KUNIT_SUCCEED(9),KUNIT_FAIL(9)KUNIT_EXPECT_TRUE(9),KUNIT_EXPECT_FALSE(9),KUNIT_EXPECT_EQ(9),KUNIT_EXPECT_PTR_EQ(9),KUNIT_EXPECT_NE(9),KUNIT_EXPECT_PTR_NE(9),KUNIT_EXPECT_LT(9),KUNIT_EXPECT_LE(9),KUNIT_EXPECT_GT(9),KUNIT_EXPECT_GE(9),KUNIT_EXPECT_STREQ(9),KUNIT_EXPECT_STRNEQ(9),KUNIT_EXPECT_MEMEQ(9),KUNIT_EXPECT_MEMNEQ(9),KUNIT_EXPECT_NULL(9),KUNIT_EXPECT_NOT_NULL(9),KUNIT_EXPECT_NOT_ERR_OR_NULL(9)KUNIT_FAIL_AND_ABORT(9),KUNIT_ASSERT_TRUE(9),KUNIT_ASSERT_FALSE(9),KUNIT_ASSERT_EQ(9),KUNIT_ASSERT_PTR_EQ(9),KUNIT_ASSERT_NE(9),KUNIT_ASSERT_PTR_NE(9),KUNIT_ASSERT_LT(9),KUNIT_ASSERT_LE(9),KUNIT_ASSERT_GT(9),KUNIT_ASSERT_GE(9),KUNIT_ASSERT_STREQ(9),KUNIT_ASSERT_STRNEQ(9),KUNIT_ASSERT_MEMEQ(9),KUNIT_ASSERT_MEMNEQ(9),KUNIT_ASSERT_NULL(9),KUNIT_ASSERT_NOT_NULL(9),KUNIT_ASSERT_NOT_ERR_OR_NULL(9)KUNIT_ARRAY_PARAM(9),KUNIT_ARRAY_PARAM_DESC(9),kunit_register_params_array(9),kunit_warning_suppress(9),KUNIT_SUPPRESSED_WARNING_COUNT(9),KUNIT_EXPECT_SUPPRESSED_WARNING_COUNT(9),KUNIT_ASSERT_SUPPRESSED_WARNING_COUNT(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms