shrink_slab(9)
π shrink_slab β bestie edition
ok so this is a page from the Kernel API Manual, and we're talking about shrink_slab β a lil kernel function with main character energy that shrinks slab caches. yes. that's the whole vibe. let's get into it π
β¨ NAME β¨
shrink_slab β shrink slab caches. that's it. that's the function. it makes the slab caches smaller and honestly it ate π
πΈ SYNOPSIS πΈ
unsigned long shrink_slab (gfp_t gfp_mask , int nid , struct mem_cgroup
*memcg , int priority );
look at her. four arguments, returns an unsigned long. iconic behavior fr fr β¨
π¦ ARGUMENTS π¦
gfp_maskβ the allocation context. yep, that's the whole description, it's giving minimal and mysterious πnidβ the node whose slab caches we're targeting. very "I know a guy" energy.memcgβ the memory cgroup whose slab caches we're targeting. sister argument tonid, we love a matched set πpriorityβ the reclaim priority. lowkey the moment of truth, more on that below π
π₯ DESCRIPTION π₯
So what does she actually do? She calls the shrink functions to age shrinkable caches. that's the job. that's the assignment. aging caches like they're fine wine π
Now the details, bestie, don't skip:
nid gets passed along to shrinkers that have SHRINKER_NUMA_AWARE set. the unaware shrinkers β bless them β will receive a node id of 0 instead. no cap, that's literally just how it works.
memcg specifies the memory cgroup to target. and here's the thing: the unaware shrinkers are called only if it is the root cgroup. so if you're not at root, those unaware shrinkers are simply not invited to the function. sorry bestie π«Ά
priority is sc->priority β and this part is so clever. we take the number of objects and >> by priority in order to get the scan target. shift it right, that's the whole trick. the way that priority just slides the numbers down πβ¨
and the return value? the number of reclaimed slab objects. that's your receipt. keep it.
β οΈ tiny heads-up: everything above is exactly what the page says β I'm not adding lore, that's all of it π
π SEE ALSO π
- Kernel file
./mm/shrinker.cβ go read the source, bestie, it's right there π₯
ok that's the whole page and honestly it was short but she made her point π stay shiny, keep your caches aged, and remember: unaware shrinkers get node id 0 and they get called only at the root cgroup. periodt. π
β this has been the ./mm corner of the world, dated October 2026, brought to you by the shrink_slab(9) entry itself πβ¨
π¦ 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