kfence_shutdown_cache(9)
okay bestie, welcome to kfence_shutdown_cache(9) from the Kernel API Manual π β itβs the page about handling shutdown_cache() for KFENCE objects, and honestly itβs giving βniche but crucial.β β¨
β¨ NAME β¨
kfence_shutdown_cache β handle shutdown_cache() for KFENCE objects π
πΈ SYNOPSIS πΈ
void kfence_shutdown_cache (struct kmem_cache *s );
π¦ ARGUMENTS π¦
sβ the cache being shut down. π«Ά
π DESCRIPTION π
okay so, before shutting down a cache, one must ensure there are no remaining objects allocated from it. literally the vibe check. because KFENCE objects are not referenced from the cache directly, we need to check them here. π
ngl, note that shutdown_cache is internal to SL*B, and kmem_cache_destroy does not return if allocated objects still exist: it prints an error message and simply aborts destruction of a cache, leaking memory. π so yeah, thatβs the no-good outcome.
If the only such objects are KFENCE objects, we will not leak the entire cache, but instead try to provide more useful debug info by making allocated objects "zombie allocations". Objects may then still be used or freed (which is handled gracefully), but usage will result in showing KFENCE error reports which include stack traces to the user of the object, the original allocation site, and caller to shutdown_cache. πβ¨
π SEE ALSO π
Kernel file ./include/linux/kfence.h is in the group chat too, and the related squad is:
is_kfence_address(9)kfence_alloc_pool_and_metadata(9)kfence_init(9)kfence_alloc(9)kfence_ksize(9)kfence_object_start(9)__kfence_free(9)kfence_free(9)kfence_handle_page_fault(9)__kfence_obj_info(9)
mwah π β footer source/version: ./include/linux; date: October 2026. bestie out π«Ά
π¦ 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