tools/testing/selftests/mm/hugetlb_reparenting_test.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/mm/hugetlb_reparenting_test.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/mm/hugetlb_reparenting_test.sh- Extension
.sh- Size
- 5060 bytes
- Lines
- 244
- 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 get_machine_hugepage_sizefunction assert_statefunction setup
Annotated Snippet
function get_machine_hugepage_size() {
hpz=$(grep -i hugepagesize /proc/meminfo)
kb=${hpz:14:-3}
mb=$(($kb / 1024))
echo $mb
}
MB=$(get_machine_hugepage_size)
function cleanup() {
echo cleanup
set +e
rm -rf "$MNT"/* 2>/dev/null
umount "$MNT" 2>/dev/null
rmdir "$MNT" 2>/dev/null
rmdir "$CGROUP_ROOT"/a/b 2>/dev/null
rmdir "$CGROUP_ROOT"/a 2>/dev/null
rmdir "$CGROUP_ROOT"/test1 2>/dev/null
echo $nr_hugepgs >/proc/sys/vm/nr_hugepages
set -e
}
function assert_with_retry() {
local actual_path="$1"
local expected="$2"
local tolerance=$((7 * 1024 * 1024))
local timeout=20
local interval=1
local start_time
local now
local elapsed
local actual
start_time=$(date +%s)
while true; do
actual="$(cat "$actual_path")"
if [[ $actual -ge $(($expected - $tolerance)) ]] &&
[[ $actual -le $(($expected + $tolerance)) ]]; then
return 0
fi
now=$(date +%s)
elapsed=$((now - start_time))
if [[ $elapsed -ge $timeout ]]; then
echo "actual = $((${actual%% *} / 1024 / 1024)) MB"
echo "expected = $((${expected%% *} / 1024 / 1024)) MB"
cleanup
exit 1
fi
sleep $interval
done
}
function assert_state() {
local expected_a="$1"
local expected_a_hugetlb="$2"
local expected_b=""
local expected_b_hugetlb=""
if [ ! -z ${3:-} ] && [ ! -z ${4:-} ]; then
expected_b="$3"
expected_b_hugetlb="$4"
fi
assert_with_retry "$CGROUP_ROOT/a/memory.$usage_file" "$expected_a"
assert_with_retry "$CGROUP_ROOT/a/hugetlb.${MB}MB.$usage_file" "$expected_a_hugetlb"
Annotation
- Detected declarations: `function get_machine_hugepage_size`, `function assert_state`, `function setup`.
- 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.