tools/testing/selftests/kvm/x86/nx_huge_pages_test.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/x86/nx_huge_pages_test.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/x86/nx_huge_pages_test.sh- Extension
.sh- Size
- 2197 bytes
- Lines
- 70
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function do_sudo
Annotated Snippet
function do_sudo () {
"$@"
}
else
function do_sudo () {
sudo "$@"
}
fi
set +e
function sudo_echo () {
echo "$1" | do_sudo tee -a "$2" > /dev/null
}
NXECUTABLE="$(dirname $0)/nx_huge_pages_test"
sudo_echo test /dev/null || exit 4 # KSFT_SKIP=4
(
set -e
sudo_echo 1 /sys/module/kvm/parameters/nx_huge_pages
sudo_echo 1 /sys/module/kvm/parameters/nx_huge_pages_recovery_ratio
sudo_echo 100 /sys/module/kvm/parameters/nx_huge_pages_recovery_period_ms
sudo_echo "$(( $HUGE_PAGES + 3 ))" /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
# Test with reboot permissions
if [ $(whoami) == "root" ] || sudo setcap cap_sys_boot+ep $NXECUTABLE 2> /dev/null; then
echo Running test with CAP_SYS_BOOT enabled
$NXECUTABLE -t 887563923 -p 100 -r
test $(whoami) == "root" || sudo setcap cap_sys_boot-ep $NXECUTABLE
else
echo setcap failed, skipping nx_huge_pages_test with CAP_SYS_BOOT enabled
fi
# Test without reboot permissions
if [ $(whoami) != "root" ] ; then
echo Running test with CAP_SYS_BOOT disabled
$NXECUTABLE -t 887563923 -p 100
else
echo Running as root, skipping nx_huge_pages_test with CAP_SYS_BOOT disabled
fi
)
RET=$?
sudo_echo "$NX_HUGE_PAGES" /sys/module/kvm/parameters/nx_huge_pages
sudo_echo "$NX_HUGE_PAGES_RECOVERY_RATIO" /sys/module/kvm/parameters/nx_huge_pages_recovery_ratio
sudo_echo "$NX_HUGE_PAGES_RECOVERY_PERIOD" /sys/module/kvm/parameters/nx_huge_pages_recovery_period_ms
sudo_echo "$HUGE_PAGES" /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
exit $RET
Annotation
- Detected declarations: `function do_sudo`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.