Skip to content

[Store] Fix CXL capacity metric leak on segment unmount#5

Open
stmatengss wants to merge 1 commit intohemist/cxl-level-storefrom
fix/cxl-metric-unmount-leak
Open

[Store] Fix CXL capacity metric leak on segment unmount#5
stmatengss wants to merge 1 commit intohemist/cxl-level-storefrom
fix/cxl-metric-unmount-leak

Conversation

@stmatengss
Copy link
Copy Markdown

Problem

CommitUnmountSegment only decrements metrics for non-CXL segments:

if (!is_cxl) {
    dec_total_mem_capacity(...);
    dec_total_dram_capacity(...);
}
// CXL branch: nothing decremented ← bug

On CXL mount, both inc_total_mem_capacity and inc_total_cxl_capacity are called. The unmount path never mirrors this, causing the CXL capacity metric to grow monotonically across remount cycles.

Fix

Add an else branch calling dec_total_mem_capacity and dec_total_cxl_capacity for CXL segments, matching the mount path symmetrically.

Impact

  • No behavior change for RAM segments
  • CXL capacity metrics now correctly track mounted capacity

When a CXL segment is unmounted via CommitUnmountSegment, the total
capacity metrics were only decremented for non-CXL segments. CXL segments
never called dec_total_cxl_capacity, causing the metric to grow without
bound across remount cycles.

On mount (initializeCxlAllocator) both inc_total_mem_capacity and
inc_total_cxl_capacity are incremented. Match this symmetrically on unmount
by adding an else branch that calls both dec_total_mem_capacity and
dec_total_cxl_capacity for CXL segments.
@stmatengss stmatengss requested review from XucSh and YiXR as code owners April 22, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant