Skip to content

fix(ktuner): shmall target uses runtime page size#1337

Open
jfeng18 wants to merge 1 commit into
alibaba:mainfrom
jfeng18:fix/ktuner-shmall-pagesize
Open

fix(ktuner): shmall target uses runtime page size#1337
jfeng18 wants to merge 1 commit into
alibaba:mainfrom
jfeng18:fix/ktuner-shmall-pagesize

Conversation

@jfeng18

@jfeng18 jfeng18 commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

What

eval_shmall hardcoded a 4096-byte page size when converting RAM to pages. kernel.shmall is measured in pages, and page size is architecture-dependent (4 KiB on x86_64, up to 64 KiB on arm64). On 64K-page kernels the recommended value was ~16x too high.

Fix

  • Read the page size at runtime via sysconf(_SC_PAGESIZE) (fallback 4096).
  • Extract a pure shmall_target_pages(mem_gb, page_size) that guards page_size == 0.
  • Replace the previous vacuous if let test with a discriminating one: asserts the 4K result equals the 64K result x16, and page_size 0 -> 0.

Testing

  • Only unit-tested: 1.89.0 cargo fmt --check / clippy --all-targets -- -D warnings / cargo test all pass (192 tests).
  • Mutation-tested: reverting to hardcoded 4096 fails the scaling assert; removing the zero-guard panics; flipping /2 fails — the test is discriminating.
  • Not E2E-verified on a real 64K-page arm64 kernel (dev host is x86_64/4K); the page-size scaling is covered by the pure-function test injecting 65536.

eval_shmall hardcoded a 4096-byte page size to convert RAM to pages,
but shmall is measured in pages and page size is arch-dependent (up to
64 KiB on arm64). On 64K-page kernels this over-recommended ~16x. Read
the page size at runtime via sysconf(_SC_PAGESIZE); extract a pure
shmall_target_pages() covered by a discriminating test across page
sizes (replacing the previous vacuous if-let test).
@jfeng18 jfeng18 requested a review from casparant as a code owner July 4, 2026 13:38
@github-actions github-actions Bot added the scope:chore !component && !other scope stuff label Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:ktuner scope:chore !component && !other scope stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants