From patchwork Wed Jan 2 08:59:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 10746147 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4630F746 for ; Wed, 2 Jan 2019 08:59:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 365F52847E for ; Wed, 2 Jan 2019 08:59:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A4C528496; Wed, 2 Jan 2019 08:59:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BF252847E for ; Wed, 2 Jan 2019 08:59:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA25D8E0013; Wed, 2 Jan 2019 03:59:47 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DE5BD8E0002; Wed, 2 Jan 2019 03:59:47 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B46008E0013; Wed, 2 Jan 2019 03:59:47 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by kanga.kvack.org (Postfix) with ESMTP id 42E668E0002 for ; Wed, 2 Jan 2019 03:59:47 -0500 (EST) Received: by mail-lj1-f200.google.com with SMTP id f5-v6so8672678ljj.17 for ; Wed, 02 Jan 2019 00:59:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=rarOyscPiom4BfOyukPjF18EdM0Vr2KllAf9JRQ6xOs=; b=hRRWiK1wN847aQD9HYYvbTwJb09pvZr6So06zp5vsYQt/ZpqOXEgTAvCeCe4uj75jh ZwUwFLih0ORRfivjJusvGaUszk9G2YFHHjiZw47X8awOjVthfaK7CpdeJthKzCyNoGFx y4d0/ljGZTE6Ng7CMCH7iztvoXInOOyxMWHpFFa7uw3F9Ds0D+BiS4cnMs3rudHbrFhz uZQ75z8KOKeQ3eafXwbj04L5fcw0aGer/2xUpJ/y+jC6WMdopZRsxpnUxvdDtQrVK5FX zzwVW6J9PiPHfuDgHp/iGBm8EZRBSsYYHAhn9YushsPz4pKuroOfg2+zwztow2Zh0mms CgYg== X-Gm-Message-State: AJcUukfjB7zrFlAyDAAaK2i7hPSCFSGdW/Z+Z9/JGeZBix7Q8QUPCMud UDt2h3Og8icMMWujoNuVc3UlKZHIJM2rj8HD/08DeY3KV8zn0eKDzwdtRYj04ORsiJTzaEUhIe5 5AqmwJVzZr8W3R7A99ZLu38V149x8xI6PqgAJkGG8BoQ5JN/ogDI/9bDXgCMootPWjpfdOEUgQM txikTTQ2P/wDMByK/h+Mt5OeQyj8n5Fd9qUaixVA9By8Isn2qQdVg133BWGl0yb7fYuLIsW69Z5 yjpGlW5Mpktds+Mx8pM2GkCa+Fzb9ZRFC8g4gWK/Bj002K0bK4oFKZDoUfLZ9qLlP9rMZ9gm2tG W8fuTqLQ79zq0mt1Ne4iWdh74ZA8ObAO/JrTHL7FpUpBSoKcNbSWVA0S3ptvKZYHCk4VfbYwdb/ X X-Received: by 2002:a2e:9d8e:: with SMTP id c14-v6mr23560020ljj.146.1546419586556; Wed, 02 Jan 2019 00:59:46 -0800 (PST) X-Received: by 2002:a2e:9d8e:: with SMTP id c14-v6mr23559992ljj.146.1546419585311; Wed, 02 Jan 2019 00:59:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546419585; cv=none; d=google.com; s=arc-20160816; b=omaq3l2KDm6vO9Lrt9biRr+OUiSs4ZR7dQxeZC+TZ9L/HG1KK0ASchnXaLp421+2hf zj1XSJJ2IvTWwgpOLa/M6D0tRoWIeXMfxCBisE20u6MgsvkqI/YCvOVQGQYawBMywDK6 PrPT9Q4FYRz8Nv6dJQdOOulRaMx8T1C1dpllijUfSTXEY5WVV2leK88NwxDgjhne+wgX mq8eNCckXWe0VrG4sXL9xhacvceb4cT0vie6VuXF6oyZiJ5zfAG+m30JymNut6SLX25w YF5vq0AVvge+ZwjVE9i/VQyQU9cVdxgTx0q8Jfye1kD2q9orUVN95dE9J/nY0h87x7tA r/NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rarOyscPiom4BfOyukPjF18EdM0Vr2KllAf9JRQ6xOs=; b=GKehMmqfCBxoGe/ql/aiwT6R3wHtjuIR2NA2p9KpYx8AFTLHOKQAeYn3J3SWjWVi15 6HScfpeIoukGKvXqQBQO5oYjAEoSDPeBVsT6bf+a0mnlyPQEbGI363IWv2wf3qwNN0Eo z6vXEe/qGZupC/Iizm1P1LJZdY5q/o6NkkQh2+VB2mfYxV+mCJIXoVvUCb6dIZPzQKNE LC43Eiy+lkce2dVsIntueJChMPKITjqh4pHPBhfhbg/DUalZX9vXAjHKkypzkR66gLDz KKwl+vbYwmHtkyWLlk2ft+ealo2wwSDfzq0gWc2aYuNstSqVOmHx+TWXK22sMjqwmV4U vjhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hXMrUOnY; spf=pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id u19sor12773625lfc.20.2019.01.02.00.59.45 for (Google Transport Security); Wed, 02 Jan 2019 00:59:45 -0800 (PST) Received-SPF: pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hXMrUOnY; spf=pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rarOyscPiom4BfOyukPjF18EdM0Vr2KllAf9JRQ6xOs=; b=hXMrUOnY5kfX6othwfgOCM1MWxpu49CBGcP7AmVOvFEbB7XiwDK+PR6KqVxQaEGg7y anPT/E+LSiXHSoCzZO7D/t2BPT5tr7geD/5ozb/6uMio8vh3NXSCzZK2/Cm6s39kpmKa Tua3Oz6YkZScDiZ30uZ2J4432iJ6Kp1JLMbcPeNCOZApc+rBZkKxNgOa7RMwvrxaGEPo JQgaggbmGDXtUKuxB4YhOtnBVslkHIrKD09nbnbnei8FENLLBlBRNCCpMKAj+gaNj0/q 7SWH+BTzJW5AiIb0Wv2BYZJ4TpWUZKWtWc3h3sQuaDJQOesKK9DnbNrgvKQ4KH+hcxjF qI8w== X-Google-Smtp-Source: AFSGD/UlF7IwT1L9rmiQG9sOiuefsgfcYqz2shl+JBnq0+GikF8jkxXvRK4hhzM9jimP6jmw3pkPUQ== X-Received: by 2002:a19:10a4:: with SMTP id 36mr20677421lfq.60.1546419584706; Wed, 02 Jan 2019 00:59:44 -0800 (PST) Received: from localhost.localdomain (mm-79-4-214-37.mogilev.dynamic.pppoe.byfly.by. [37.214.4.79]) by smtp.gmail.com with ESMTPSA id 10sm7489670ljr.4.2019.01.02.00.59.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Jan 2019 00:59:44 -0800 (PST) From: "Uladzislau Rezki (Sony)" To: Michal Hocko , Kees Cook , Shuah Khan , Andrew Morton , linux-mm@kvack.org Cc: LKML , Matthew Wilcox , Oleksiy Avramchenko , Thomas Gleixner , "Uladzislau Rezki (Sony)" Subject: [RFC v3 3/3] selftests/vm: add script helper for CONFIG_TEST_VMALLOC_MODULE Date: Wed, 2 Jan 2019 09:59:24 +0100 Message-Id: <20190102085924.14145-4-urezki@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190102085924.14145-1-urezki@gmail.com> References: <20190102085924.14145-1-urezki@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Uladzislau Rezki (Sony) --- tools/testing/selftests/vm/run_vmtests | 16 +++ tools/testing/selftests/vm/test_vmalloc.sh | 176 +++++++++++++++++++++++++++++ 2 files changed, 192 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..48ac0f757e9c 100755 --- a/tools/testing/selftests/vm/run_vmtests +++ b/tools/testing/selftests/vm/run_vmtests @@ -200,4 +200,20 @@ else echo "[PASS]" fi +echo "------------------------------------" +echo "running vmalloc stability smoke test" +echo "------------------------------------" +./test_vmalloc.sh smoke +ret_val=$? + +if [ $ret_val -eq 0 ]; then + echo "[PASS]" +elif [ $ret_val -eq $ksft_skip ]; then + echo "[SKIP]" + exitcode=$ksft_skip +else + echo "[FAIL]" + exitcode=1 +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..06d2bb109f06 --- /dev/null +++ b/tools/testing/selftests/vm/test_vmalloc.sh @@ -0,0 +1,176 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2018 Uladzislau Rezki (Sony) +# +# 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 + +# 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="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 $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 +} + +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 0 +} + +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