tools/testing/selftests/mm/charge_reserved_hugetlb.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/mm/charge_reserved_hugetlb.sh- Extension
.sh- Size
- 17640 bytes
- Lines
- 603
- 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 cleanupfunction expect_equalfunction get_machine_hugepage_sizefunction wait_for_file_valuefunction wait_for_hugetlb_memory_to_get_depletedfunction cleanup_hugetlb_memoryfunction run_test
Annotated Snippet
function cleanup() {
if [[ $cgroup2 ]]; then
echo $$ >$cgroup_path/cgroup.procs
else
echo $$ >$cgroup_path/tasks
fi
if [[ -e /mnt/huge ]]; then
rm -rf /mnt/huge/*
umount /mnt/huge || echo error
rmdir /mnt/huge
fi
if [[ -e $cgroup_path/hugetlb_cgroup_test ]]; then
rmdir $cgroup_path/hugetlb_cgroup_test
fi
if [[ -e $cgroup_path/hugetlb_cgroup_test1 ]]; then
rmdir $cgroup_path/hugetlb_cgroup_test1
fi
if [[ -e $cgroup_path/hugetlb_cgroup_test2 ]]; then
rmdir $cgroup_path/hugetlb_cgroup_test2
fi
echo 0 >/proc/sys/vm/nr_hugepages
echo CLEANUP DONE
}
function expect_equal() {
local expected="$1"
local actual="$2"
local error="$3"
if [[ "$expected" != "$actual" ]]; then
echo "expected ($expected) != actual ($actual): $3"
cleanup
exit 1
fi
}
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 setup_cgroup() {
local name="$1"
local cgroup_limit="$2"
local reservation_limit="$3"
mkdir $cgroup_path/$name
echo writing cgroup limit: "$cgroup_limit"
echo "$cgroup_limit" >$cgroup_path/$name/hugetlb.${MB}MB.$fault_limit_file
echo writing reservation limit: "$reservation_limit"
echo "$reservation_limit" > \
$cgroup_path/$name/hugetlb.${MB}MB.$reservation_limit_file
if [ -e "$cgroup_path/$name/cpuset.cpus" ]; then
echo 0 >$cgroup_path/$name/cpuset.cpus
fi
if [ -e "$cgroup_path/$name/cpuset.mems" ]; then
echo 0 >$cgroup_path/$name/cpuset.mems
fi
}
function wait_for_file_value() {
local path="$1"
Annotation
- Detected declarations: `function cleanup`, `function expect_equal`, `function get_machine_hugepage_size`, `function wait_for_file_value`, `function wait_for_hugetlb_memory_to_get_depleted`, `function cleanup_hugetlb_memory`, `function run_test`.
- 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.