devm_kmemdup_const(9)
π devm_kmemdup_const β kernel API manual, but make it make sense β¨
okay so bestie, welcome to devm_kmemdup_const(9), straight out of the Kernel API Manual π this one is short, it's sweet, and it's giving "manager energy" β because it doesn't just duplicate your memory, it manages it for you too. no cap π«Ά
β¨ NAME β¨
devm_kmemdup_const β conditionally duplicate and manage a region of memory π
π¦ SYNOPSIS π¦
const void * devm_kmemdup_const (struct device *dev , const void *src ,
size_t len , gfp_t gfp );
πΈ ARGUMENTS πΈ
devβ the device this memory belongs to, like the whole thing is registered under its name πsrcβ the memory region to duplicate, the og copy, the blueprint πlenβ memory region length, (yes the comma is canon, don't come for me) πgfpβ the GFP mask to use, that's the flavour of allocation, iykyk π
π RETURN π
it hands you back the source address if that address is in .rodata β like, it literally just points at the og constant and goes "that's already perfect, why would I copy it" π
otherwise? it falls back to the return value of kmemdup π so you get a fresh copy, no cap.
lowkey important: the "conditionally" in the name is doing real work here fr fr β.rodatameans no duplication, everything else meanskmemdupcity β¨
π₯ SEE ALSO π₯
Kernel file ./drivers/base/devres.c β the whole devres family, and honestly bestie, it's a whole friend group π«Ά
__devres_alloc_node(9)devres_for_each_res(9)devres_free(9)devres_add(9)devres_find(9)devres_get(9)devres_remove(9)devres_destroy(9)devres_release(9)devres_release_all(9)devres_open_group(9)devres_close_group(9)devres_remove_group(9)devres_release_group(9)__devm_add_action(9)devm_remove_action_nowarn(9)devm_release_action(9)devm_kmalloc(9)devm_krealloc(9)devm_kstrdup(9)devm_kstrdup_const(9)devm_kvasprintf(9)devm_kasprintf(9)devm_kfree(9)devm_kmemdup(9)devm_get_free_pages(9)devm_free_pages(9)__devm_alloc_percpu(9)
and that's the whole page, bestie, you ate that π β¨
sign-off szn π: this icon lives in ./drivers/base, the date on the tin is October 2026, and the source/version is the Kernel API Manual itself β go forth and duplicate responsibly ππ¦π
π¦ 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