From: shuah <shuah@kernel.org>
To: "Uladzislau Rezki (Sony)" <urezki@gmail.com>,
Michal Hocko <mhocko@suse.com>, Kees Cook <keescook@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org
Cc: LKML <linux-kernel@vger.kernel.org>,
Matthew Wilcox <willy@infradead.org>,
Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>,
Thomas Gleixner <tglx@linutronix.de>, shuah <shuah@kernel.org>
Subject: Re: [RFC v2 3/3] selftests/vm: add script helper for CONFIG_TEST_VMALLOC_MODULE
Date: Mon, 31 Dec 2018 10:47:55 -0700 [thread overview]
Message-ID: <5c40e334-f8ae-7fbf-fde1-44bc390ee6a7@kernel.org> (raw)
In-Reply-To: <20181231132640.21898-4-urezki@gmail.com>
On 12/31/18 6:26 AM, Uladzislau Rezki (Sony) wrote:
> Add the test script for the kernel test driver to analyse vmalloc
> allocator for benchmarking and stressing purposes. It is just a kernel
> module loader. You can specify and pass different parameters in order
> to investigate allocations behaviour. See "usage" output for more
> details.
>
> Also add basic vmalloc smoke test to the "run_vmtests" suite.
Thanks for the test. A few comments below.
>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> ---
> tools/testing/selftests/vm/run_vmtests | 11 ++
> tools/testing/selftests/vm/test_vmalloc.sh | 173 +++++++++++++++++++++++++++++
> 2 files changed, 184 insertions(+)
> create mode 100755 tools/testing/selftests/vm/test_vmalloc.sh
>
> diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
> index 88cbe5575f0c..56053ac2bf47 100755
> --- a/tools/testing/selftests/vm/run_vmtests
> +++ b/tools/testing/selftests/vm/run_vmtests
> @@ -200,4 +200,15 @@ else
> echo "[PASS]"
> fi
>
> +echo "------------------------------------"
> +echo "running vmalloc stability smoke test"
> +echo "------------------------------------"
> +./test_vmalloc.sh smoke
> +if [ $? -ne 0 ]; then
> + echo "[FAIL]"
> + exitcode=1
Please handle skil cases - exit code for skip is 4.
> +else
> + echo "[PASS]"
> +fi
> +
> exit $exitcode
> diff --git a/tools/testing/selftests/vm/test_vmalloc.sh b/tools/testing/selftests/vm/test_vmalloc.sh
> new file mode 100755
> index 000000000000..f4f0d3990f2c
> --- /dev/null
> +++ b/tools/testing/selftests/vm/test_vmalloc.sh
> @@ -0,0 +1,173 @@
> +#!/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}"
> +
> +# 1 if fails
> +exitcode=1
> +
> +#
> +# Static templates for performance, stressing and smoke tests.
> +# Also it is possible to pass any supported parameters manualy.
> +#
> +PERF_PARAM="single_cpu_test=1 sequential_test_order=1 test_repeat_count=3"
> +SMOKE_PARAM="single_cpu_test=1 test_loop_count=10000 test_repeat_count=10"
> +STRESS_PARAM="test_repeat_count=20"
> +
> +check_test_requirements()
> +{
> + uid=$(id -u)
> + if [ $uid -ne 0 ]; then
> + echo "$0: Must be run as root"
> + exit $exitcode
This is a skip and not a fail.
> + fi
> +
> + if ! which modprobe > /dev/null 2>&1; then
> + echo "$0: You need modprobe installed"
> + exit $exitcode
This is a skip and not a fail.
> + 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 $exitcode
This is a skip and not a fail.
> + fi
> +}
> +
> +run_perfformance_check()
> +{
> + echo "Run performance tests to evaluate how fast vmalloc allocation is."
> + echo "It runs all test cases on one single CPU with sequential order."
> +
> + modprobe $DRIVER $PERF_PARAM > /dev/null 2>&1
> + echo "Done."
> + echo "Ccheck the kernel message buffer to see the summary."
> +}
> +
> +run_stability_check()
> +{
> + echo "Run stability tests. In order to stress vmalloc subsystem we run"
> + echo "all available test cases on all available CPUs simultaneously."
> + echo "It will take time, so be patient."
> +
> + modprobe $DRIVER $STRESS_PARAM > /dev/null 2>&1
> + echo "Done."
> + echo "Check the kernel ring buffer to see the summary."
> +}
> +
> +run_smoke_check()
> +{
> + echo "Run smoke test. Note, this test provides basic coverage."
> + echo "Please check $0 output how it can be used"
> + echo "for deep performance analysis as well as stress testing."
> +
> + modprobe $DRIVER $SMOKE_PARAM > /dev/null 2>&1
> + echo "Done."
> + echo "Check the kernel ring buffer to see the summary."
> +}
> +
> +usage()
> +{
> + echo -n "Usage: $0 [ performance ] | [ stress ] | | [ smoke ] | "
> + echo "manual parameters"
> + echo
> + echo "Valid tests and parameters:"
> + echo
> + modinfo $DRIVER
> + echo
> + echo "Example usage:"
> + echo
> + echo "# Shows help message"
> + echo "./${DRIVER}.sh"
> + echo
> + echo "# Runs 1 test(id_1), repeats it 5 times on all online CPUs"
> + echo "./${DRIVER}.sh run_test_mask=1 test_repeat_count=5"
> + echo
> + echo -n "# Runs 4 tests(id_1|id_2|id_4|id_16) on one CPU with "
> + echo "sequential order"
> + echo -n "./${DRIVER}.sh single_cpu_test=1 sequential_test_order=1 "
> + echo "run_test_mask=23"
> + echo
> + echo -n "# Runs all tests on all online CPUs, shuffled order, repeats "
> + echo "20 times"
> + echo "./${DRIVER}.sh test_repeat_count=20"
> + echo
> + echo "# Performance analysis"
> + echo "./${DRIVER}.sh performance"
> + echo
> + echo "# Stress testing"
> + echo "./${DRIVER}.sh stress"
> + echo
> + exit $exitcode
> +}
> +
> +function validate_passed_args()
> +{
> + VALID_ARGS=`modinfo $DRIVER | awk '/parm:/ {print $2}' | sed 's/:.*//'`
> +
> + #
> + # Something has been passed, check it.
> + #
> + for passed_arg in $@; do
> + key=${passed_arg//=*/}
> + val="${passed_arg:$((${#key}+1))}"
> + valid=0
> +
> + for valid_arg in $VALID_ARGS; do
> + if [[ $key = $valid_arg ]] && [[ $val -gt 0 ]]; then
> + valid=1
> + break
> + fi
> + done
> +
> + if [[ $valid -ne 1 ]]; then
> + echo "Error: key or value is not correct: ${key} $val"
> + exit $exitcode
> + fi
> + done
> +}
> +
> +function run_manual_check()
> +{
> + #
> + # Validate passed parameters. If there is wrong one,
> + # the script exists and does not execute further.
> + #
> + validate_passed_args $@
> +
> + echo "Run the test with following parameters: $@"
> + modprobe $DRIVER $@ > /dev/null 2>&1
> + echo "Done."
> + echo "Check the kernel ring buffer to see the summary."
> +}
> +
> +function run_test()
> +{
> + if [ $# -eq 0 ]; then
> + usage
> + else
> + if [[ "$1" = "performance" ]]; then
> + run_perfformance_check
> + elif [[ "$1" = "stress" ]]; then
> + run_stability_check
> + elif [[ "$1" = "smoke" ]]; then
> + run_smoke_check
> + else
> + run_manual_check $@
> + fi
> + fi
> +}
> +
> +check_test_requirements
> +run_test $@
> +
> +exit 0
>
thanks,
-- Shuah
next prev parent reply other threads:[~2018-12-31 17:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-31 13:26 [RFC v2 0/3] test driver to analyse vmalloc allocator Uladzislau Rezki (Sony)
2018-12-31 13:26 ` [RFC v2 1/3] vmalloc: export __vmalloc_node_range for CONFIG_TEST_VMALLOC_MODULE Uladzislau Rezki (Sony)
2018-12-31 18:50 ` Matthew Wilcox
2019-01-01 16:55 ` Uladzislau Rezki
2018-12-31 13:26 ` [RFC v2 2/3] vmalloc: add test driver to analyse vmalloc allocator Uladzislau Rezki (Sony)
2018-12-31 13:26 ` [RFC v2 3/3] selftests/vm: add script helper for CONFIG_TEST_VMALLOC_MODULE Uladzislau Rezki (Sony)
2018-12-31 17:47 ` shuah [this message]
2019-01-01 17:12 ` Uladzislau Rezki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5c40e334-f8ae-7fbf-fde1-44bc390ee6a7@kernel.org \
--to=shuah@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=oleksiy.avramchenko@sonymobile.com \
--cc=tglx@linutronix.de \
--cc=urezki@gmail.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox