shrink_dpa_allocation(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 reclaim n bytes 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 🌈

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