shrink_dpa_allocation(9)
π shrink_dpa_allocation β a.k.a. the Kernel API Manual glow-up (section 9, bestie)
okay so picture this: you're deep in the nvdimm trenches and you need to give some bytes back. That's this function. She's the "let it go" anthem of DPA allocations, and honestly? Iconic. β¨
πΈ NAME πΈ
shrink_dpa_allocation β for each dimm in region, free n bytes for label_id
no cap, that's the whole vibe: you point her at a region, you point her at a label id, you hand her a byte count, and she starts handing memory back. π
β¨ SYNOPSIS β¨
int shrink_dpa_allocation (struct nd_region *nd_region , struct nd_label_id *label_id , resource_size_t n );
three args, one int coming back at you. simple. clean. she ate. π
π«Ά ARGUMENTS π«Ά
nd_regionβ the set of dimms to reclaimnbytes from. like, this is the friend group she's taking the memory back from.label_idβ unique identifier for the namespace consuming this dpa range. yes bestie, unique. she knows exactly which namespace this dpa range belongs to, no confusion, no drama. π₯nβ number of bytes per-dimm to release. per. dimm. important detail, don't skim it. π
π¦ DESCRIPTION π¦
So here's the tea. π΅
She assumes resources are ordered. That's the starting assumption β not a suggestion, not a cute little hint, an assumption. Keep that in mind.
Then, starting from the end, she tries to adjust_resource the allocation to n.
But β and this is the plot twist π β if n is larger than the allocation, she doesn't just awkwardly shove it through. Nope. She deletes it, and then finds the 'new' last allocation in the label set. Clean cut, no leftover mess. The way she just handles it. π§
β οΈ fr fr remember: this only works out because resources are assumed to be ordered. That's the foundation the whole thing stands on, bestie. Don't come for her if that assumption isn't holding.
β RETURN β
0 on success and -errno on error. (The page literally words it as 0 on success on -errno on error β yes, "on", we love a quirky typo, we keep her exactly as she is. π)
So: zero means slay, negative errno means something went sideways. You already knew that, iykyk. π
π SEE ALSO π
- Kernel file
./drivers/nvdimm/namespace_devs.c nd_is_uuid_unique(9)space_valid(9)grow_dpa_allocation(9)β yes, her sister, the one who does the opposite πnamespace_update_uuid(9)create_namespace_pmem(9)
go read those too, they're all in the same friend group, it's giving connected lore. π
and that's the page!! mwah π this little gem lives in ./drivers/nvdimm, dated October 2026, and she answers to shrink_dpa_allocation(9) β go forth and free those bytes responsibly, bestie πβ¨
π¦ 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