kvmemdup(9)
π kvmemdup(9) π
okay so real talk, bestie, this is a page from the Kernel API Manual, and it's about kvmemdup β the "copy this chunk of memory for me please" girlie. she's giving allocator energy and we're obsessed. let's get into it β¨
πΈ NAME πΈ
kvmemdup β duplicate region of memory. that's it, that's the whole vibe. she copies a region of memory. periodt.
π¦ SYNOPSIS π¦
void * kvmemdup (const void *src , size_t len , gfp_t gfp );
like, look at her. three arguments. returns a void *. so clean, so iconic π
π ARGUMENTS π
srcβ the memory region you wanna duplicate. the original. the main character, if you will πlenβ how long that memory region is. gotta tell her the length or she's just guessing, and we don't guess, we know β¨gfpβ the GFP mask to use. that's the flags she gets to allocate with, no cap π«Ά
β RETURN β
she hands you back a newly allocated copy of src, or NULL if something goes wrong π β that's the error case, so like, check it, bestie, fr fr.
β οΈ important vibe check: the result may be not physically contiguous. do not assume it is. she said what she said π
and when you're done with it? free it with kvfree. don't just leave it hanging, that's rude and also a leak π
π SEE ALSO π
kernel file ./mm/util.c, plus this whole friend group right here β go say hi ππ
kfree_const(9)__kmemdup_nul(9)kstrdup(9)kstrdup_const(9)kstrndup(9)kmemdup(9)kmemdup_array(9)kmemdup_nul(9)memdup_user(9)vmemdup_user(9)strndup_user(9)memdup_user_nul(9)randomize_page(9)__account_locked_vm(9)account_locked_vm(9)__vmalloc_array(9)vmalloc_array(9)__vcalloc(9)vcalloc(9)folio_mapping(9)folio_copy(9)get_cmdline(9)mem_dump_obj(9)compat_set_desc_from_vma(9)__compat_vma_mmap(9)compat_vma_mmap(9)snapshot_page(9)mmap_action_prepare(9)mmap_action_complete(9)folio_pte_batch(9)page_range_contiguous(9)
and that's the whole page, bestie π§ ty for coming to my ted talk. this one lives in the ./mm directory and it's dated October 2026 β so like, future girlie behavior, we love to see it πβ¨ slay!
π¦ 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