tools/testing/selftests/mm/test_vmalloc.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/mm/test_vmalloc.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/mm/test_vmalloc.sh- Extension
.sh- Size
- 5180 bytes
- Lines
- 203
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function validate_passed_argsfunction run_manual_check
Annotated Snippet
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (C) 2018 Uladzislau Rezki (Sony) <urezki@gmail.com>
#
# This is a test script for the kernel test driver to analyse vmalloc
# allocator. Therefore it is just a kernel module loader. You can specify
# and pass different parameters in order to:
# a) analyse performance of vmalloc allocations;
# b) stressing and stability check of vmalloc subsystem.
TEST_NAME="vmalloc"
DRIVER="test_${TEST_NAME}"
NUM_CPUS=`grep -c ^processor /proc/cpuinfo`
# Default number of times we allocate percpu objects:
NR_PCPU_OBJECTS=35000
# 1 if fails
exitcode=1
# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4
#
# Static templates for performance, stressing and smoke tests.
# Also it is possible to pass any supported parameters manualy.
#
PERF_PARAM="sequential_test_order=1 test_repeat_count=3"
SMOKE_PARAM="test_loop_count=10000 test_repeat_count=10"
STRESS_PARAM="nr_threads=$NUM_CPUS test_repeat_count=20"
PCPU_OBJ_PARAM="nr_pcpu_objects=$NR_PCPU_OBJECTS"
check_test_requirements()
{
uid=$(id -u)
if [ $uid -ne 0 ]; then
echo "$0: Must be run as root"
exit $ksft_skip
fi
if ! which modprobe > /dev/null 2>&1; then
echo "$0: You need modprobe installed"
exit $ksft_skip
fi
if ! modinfo $DRIVER > /dev/null 2>&1; then
echo "$0: You must have the following enabled in your kernel:"
echo "CONFIG_TEST_VMALLOC=m"
exit $ksft_skip
fi
}
check_memory_requirement()
{
# The pcpu_alloc_test allocates nr_pcpu_objects per cpu. If the
# PAGE_SIZE is on the larger side it is easier to set a value
# that can cause oom events during testing. Since we are
# testing the functionality of vmalloc and not the oom-killer,
# calculate what is 90% of available memory and divide it by
# the number of online CPUs.
pages=$(($(getconf _AVPHYS_PAGES) * 90 / 100 / $NUM_CPUS))
if (($pages < $NR_PCPU_OBJECTS)); then
echo "Updated nr_pcpu_objects to 90% of available memory."
echo "nr_pcpu_objects is now set to: $pages."
PCPU_OBJ_PARAM="nr_pcpu_objects=$pages"
fi
}
Annotation
- Detected declarations: `function validate_passed_args`, `function run_manual_check`.
- 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.