tools/testing/selftests/mm/test_page_frag.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/mm/test_page_frag.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/mm/test_page_frag.sh
Extension
.sh
Size
3686 bytes
Lines
176
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.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (C) 2024 Yunsheng Lin <linyunsheng@huawei.com>
# Copyright (C) 2018 Uladzislau Rezki (Sony) <urezki@gmail.com>
#
# This is a test script for the kernel test driver to test the
# correctness and performance of page_frag's implementation.
# Therefore it is just a kernel module loader. You can specify
# and pass different parameters in order to:
#     a) analyse performance of page fragment allocations;
#     b) stressing and stability check of page_frag subsystem.

DRIVER="./page_frag/page_frag_test.ko"
CPU_LIST=$(grep -m 2 processor /proc/cpuinfo | cut -d ' ' -f 2)
TEST_CPU_0=$(echo $CPU_LIST | awk '{print $1}')

if [ $(echo $CPU_LIST | wc -w) -gt 1 ]; then
	TEST_CPU_1=$(echo $CPU_LIST | awk '{print $2}')
	NR_TEST=100000000
else
	TEST_CPU_1=$TEST_CPU_0
	NR_TEST=1000000
fi

# 1 if fails
exitcode=1

# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4

check_test_failed_prefix() {
	if dmesg | grep -q 'page_frag_test failed:';then
		echo "page_frag_test failed, please check dmesg"
		exit $exitcode
	fi
}

#
# Static templates for testing of page_frag APIs.
# Also it is possible to pass any supported parameters manually.
#
SMOKE_PARAM="test_push_cpu=$TEST_CPU_0 test_pop_cpu=$TEST_CPU_1"
NONALIGNED_PARAM="$SMOKE_PARAM test_alloc_len=75 nr_test=$NR_TEST"
ALIGNED_PARAM="$NONALIGNED_PARAM test_align=1"

check_test_requirements()
{
	uid=$(id -u)
	if [ $uid -ne 0 ]; then
		echo "$0: Must be run as root"
		exit $ksft_skip
	fi

	if ! which insmod > /dev/null 2>&1; then
		echo "$0: You need insmod installed"
		exit $ksft_skip
	fi

	if [ ! -f $DRIVER ]; then
		echo "$0: You need to compile page_frag_test module"
		exit $ksft_skip
	fi
}

run_nonaligned_check()
{
	echo "Run performance tests to evaluate how fast nonaligned alloc API is."

	insmod $DRIVER $NONALIGNED_PARAM > /dev/null 2>&1

Annotation

Implementation Notes