Fix invalid THP kernel param in optimize_kernel (#176)#177
Draft
VijitSingh97 wants to merge 2 commits into
Draft
Fix invalid THP kernel param in optimize_kernel (#176)#177VijitSingh97 wants to merge 2 commits into
VijitSingh97 wants to merge 2 commits into
Conversation
optimize_kernel wrote `transparent_hugepages=never` (plural) into GRUB_CMDLINE_LINUX_DEFAULT. The real kernel parameter is singular (`transparent_hugepage=never`); the plural form is unrecognized and silently ignored, so disabling Transparent HugePages for RandomX never took effect even after the GRUB edit + reboot — /sys/kernel/mm/ transparent_hugepage/enabled stayed at the distro default. Extract the boot params into a single `randomx_boot_params` helper (one source of truth, unit-testable) with the corrected singular param, and add a unit test that guards against the plural typo regressing. The explicit HugePages reservation (hugepages=3072) was already correct and is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…UB edit (#176) Two related robustness fixes flagged while reviewing optimize_kernel for idempotency: 1. Self-heal already-broken installs. A box that ran the buggy version has the plural transparent_hugepages= AND hugepages= in GRUB, so the reservation guard (grep -q "hugepages=") would report "already configured" and skip — leaving the dead plural token in place forever. heal_grub_thp_typo() rewrites it to the singular form (idempotent: a no-op once corrected) and re-runs update-grub. 2. Stop silently no-op'ing the insert. The sed only handles the standard double-quoted GRUB_CMDLINE_LINUX_DEFAULT="..." line; previously a single-quoted/commented/absent line meant the sed changed nothing yet update-grub still ran and a reboot was flagged. append_grub_boot_params() now anchors to the active (non-comment) line, returns non-zero when there's nothing to edit, and the caller prints manual instructions instead of claiming success. The ^-anchor also stops a commented-out example line from being edited. Adds sudo_sed (safe_sed's GNU/BSD -i split, with sudo) so the helpers are portable, and unit tests that exercise the real heal/insert transforms via a passthrough-sudo stub against sandbox grub files. 125 passed, 0 failed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
⛔ Merge order: goes after #114
Draft on purpose. This touches GRUB / kernel boot params, so it should be validated against the real-server end-to-end test harness in #114 before merging. Hold until #114 testing is done.
Fixes #176.
Problem
optimize_kernelappendedtransparent_hugepages=never(plural) toGRUB_CMDLINE_LINUX_DEFAULT. The real Linux kernel parameter is singular —transparent_hugepage=never. The plural form is an unrecognized param the kernel silently ignores, so disabling Transparent HugePages for RandomX never took effect even after the GRUB edit + reboot:No error, no warning, and
doctordoesn't check THP state — so it failed silently.The explicit HugePages reservation (
hugepagesz=2M hugepages=3072) was already correct and is unchanged — only the THP-disable was broken.Fix
randomx_boot_paramshelper (one source of truth, unit-testable) with the corrected singular param;optimize_kernel's edit now consumes it.hugepages=in GRUB, so the reservation guard (grep -q "hugepages=") would report "already configured" and skip — leaving the dead plural token in place forever.heal_grub_thp_typorewrites it to the singular form (idempotent: a no-op once corrected) and re-runsupdate-grub.GRUB_CMDLINE_LINUX_DEFAULT="..."line; previously a single-quoted / commented / absent line meant nothing changed yetupdate-grubstill ran and a reboot was flagged.append_grub_boot_paramsnow anchors to the active (non-comment) line, returns non-zero when there's nothing to edit, and the caller prints manual instructions instead of claiming success. The^-anchor also stops a commented-out example line from being edited.sudo_sed(safe_sed's GNU/BSD-isplit, with sudo) so the helpers are portable across the Linux target and a macOS dev box.Confirmed on a live box: with the singular form +
update-grub+ reboot,/sys/kernel/mm/transparent_hugepage/enabledreads[never].Test
bash tests/stack/run.sh→ 125 passed, 0 failed. New assertions:unit: randomx_boot_params— generated cmdline reserves HugePages and uses the singular THP param; explicitly fails on the plural typo so it can't regress.unit: grub heal + boot-param insert— exercises the real heal/insert transforms via a passthrough-sudo stub against sandbox grub files: heal rewrites plural→singular and is an idempotent no-op once corrected; insert appends to the active line while preserving existing params; a commented-out line is left untouched and reported (no silent reboot).shellcheck -S warning pithead tests/stack/run.sh→ clean.🤖 Generated with Claude Code