hugepages-ab.sh: one binary, hpoff vs hpon (LELEKA_HUGEPAGES=on), 8 ABBA-balanced pairs of the 5-turn ~245k session at the product PCIe share 0.45, baseline-sampler state record (buddyinfo, AnonHugePages, process smaps_rollup) per run. hugepages-id.sh: bitwise replay identity at 8,000 static slots. hugepages-analyze.py: pairs, predecessor split, exit fragmentation. owner-shmem-thp.sh: root-only shmem_enabled toggle, not needed by the decode path. huge_pages.rs: mapped_len test-only (dead-code warning). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
28 lines
2.0 KiB
Bash
28 lines
2.0 KiB
Bash
#!/usr/bin/env bash
|
|
# OWNER-RUN (root), NOT run by agents. claude/hugepages, 2026-11-01. Changes ONE runtime THP knob, reversibly; nothing persists across a reboot.
|
|
#
|
|
# Why (and why it is optional): the KAR holder's sealed memfd (51.5 GiB, memfd_create = shmem) cannot get transparent huge pages while
|
|
# /sys/kernel/mm/transparent_hugepage/shmem_enabled is "never" (rnr5090 default): MADV_HUGEPAGE on shmem is ignored, MFD_HUGETLB needs reserved hugetlbfs pages
|
|
# (vm.nr_hugepages=0). The serve path does NOT map that memfd during decode (the PLE rows are pread() copies through the kernel's own large-page direct map, and the
|
|
# experts are read from the separate resident bank copy, which LELEKA_HUGEPAGES=on puts on huge pages from userspace), so this knob is not needed for the
|
|
# decode path measured in docs/experiments/hugepages-5090.md. It only matters if a future path maps the memfd (e.g. a zero-copy KAR expert source).
|
|
#
|
|
# sudo bash owner-shmem-thp.sh show # print the knobs (default action)
|
|
# sudo bash owner-shmem-thp.sh advise # shmem_enabled=advise: shmem/memfd regions get THP where MADV_HUGEPAGE is asked (and on khugepaged collapse)
|
|
# sudo bash owner-shmem-thp.sh never # revert to the rnr5090 default
|
|
# After "advise" the existing memfd keeps its 4 KiB pages; it gets huge pages only when the holder re-creates it (restart kar_holder2.py between jobs) AND the
|
|
# holder maps it with MADV_HUGEPAGE before writing, or when a process MADV_COLLAPSEs a mapping of it.
|
|
set -euo pipefail
|
|
K=/sys/kernel/mm/transparent_hugepage
|
|
case "${1:-show}" in
|
|
show) ;;
|
|
advise|never)
|
|
[ "$(id -u)" = 0 ] || { echo "run as root" >&2; exit 1; }
|
|
echo "shmem_enabled before: $(cat $K/shmem_enabled)"
|
|
echo "$1" > $K/shmem_enabled
|
|
;;
|
|
*) echo "usage: $0 show|advise|never" >&2; exit 2 ;;
|
|
esac
|
|
for f in enabled defrag shmem_enabled hugepages-2048kB/shmem_enabled khugepaged/defrag; do echo "$f: $(cat $K/$f 2>/dev/null)"; done
|
|
grep -E "ShmemHugePages|ShmemPmdMapped|AnonHugePages|HugePages_Total" /proc/meminfo
|