tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/memory-hotplug/mem-on-off-test.sh- Extension
.sh- Size
- 6593 bytes
- Lines
- 313
- 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
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
SYSFS=
# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4
prerequisite()
{
msg="skip all tests:"
if [ $UID != 0 ]; then
echo $msg must be run as root >&2
exit $ksft_skip
fi
SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'`
if [ ! -d "$SYSFS" ]; then
echo $msg sysfs is not mounted >&2
exit $ksft_skip
fi
if ! ls $SYSFS/devices/system/memory/memory* > /dev/null 2>&1; then
echo $msg memory hotplug is not supported >&2
exit $ksft_skip
fi
if ! grep -q 1 $SYSFS/devices/system/memory/memory*/removable; then
echo $msg no hot-pluggable memory >&2
exit $ksft_skip
fi
}
#
# list all hot-pluggable memory
#
hotpluggable_memory()
{
local state=${1:-.\*}
for memory in $SYSFS/devices/system/memory/memory*; do
if grep -q 1 $memory/removable &&
grep -q $state $memory/state; then
echo ${memory##/*/memory}
fi
done
}
hotpluggable_offline_memory()
{
hotpluggable_memory offline
}
hotpluggable_online_memory()
{
hotpluggable_memory online
}
memory_is_online()
{
grep -q online $SYSFS/devices/system/memory/memory$1/state
}
memory_is_offline()
{
grep -q offline $SYSFS/devices/system/memory/memory$1/state
}
Annotation
- 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.