Skip to content

Fix unsigned underflow in available physical page calculation#377

Open
cmssmc00 wants to merge 2 commits into
ovg-project:mainfrom
cmssmc00:fix-avail-physical-pages-underflow
Open

Fix unsigned underflow in available physical page calculation#377
cmssmc00 wants to merge 2 commits into
ovg-project:mainfrom
cmssmc00:fix-avail-physical-pages-underflow

Conversation

@cmssmc00

@cmssmc00 cmssmc00 commented Jul 2, 2026

Copy link
Copy Markdown

Partially addresses #371.

Summary:

  • Avoid unsigned underflow when subtracting GPU utilization headroom from available physical memory.
  • Return 0 usable physical memory when available memory is below the configured headroom.
  • Prevent the prealloc path from seeing an artificially huge available-page count under memory pressure.

Tests:

  • git diff --check

@RixinLiu RixinLiu self-assigned this Jul 20, 2026
@shipiyouniao

Copy link
Copy Markdown
Contributor

The saturating subtraction looks correct. Could we add a regression test for the boundary that caused the unsigned underflow?

It would be useful to cover available > headroom, available == headroom, and available < headroom, with the latter two producing zero usable pages. The PR currently records only git diff --check, so the exact size_t boundary can regress without CI noticing. If the GPU query makes this difficult to test directly, extracting the saturating subtraction into a small helper would allow a GPU-free unit test.

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.

3 participants