From patchwork Thu Jan 3 14:21:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 10747391 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 A80E0746 for ; Thu, 3 Jan 2019 14:22:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97CC02863B for ; Thu, 3 Jan 2019 14:22:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C0C42882C; Thu, 3 Jan 2019 14:22:42 +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 DBAA82863B for ; Thu, 3 Jan 2019 14:22:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 973A68E0073; Thu, 3 Jan 2019 09:22:40 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 94BE88E0002; Thu, 3 Jan 2019 09:22:40 -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 839228E0073; Thu, 3 Jan 2019 09:22:40 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by kanga.kvack.org (Postfix) with ESMTP id 13F088E0002 for ; Thu, 3 Jan 2019 09:22:40 -0500 (EST) Received: by mail-lj1-f197.google.com with SMTP id l12-v6so9404914ljb.11 for ; Thu, 03 Jan 2019 06:22:40 -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=KGoHN334DZNkqWv2smL0AGypDg5avCRm0FTt0IHsxCg=; b=lcF+IqXJsDEqFZXEAe/HU66U2sdHba80mH/0qmMF2DfrPA8OUwP0MVXimAdHCT6Y9P 9c8rmBJ++URA8TSunS27uKCn6gJL4vFwecJXLa7Mh6K7+F8SvJfm/k3fJptp2h4hO2n2 GTk+YWLQi7FzcABEGwdaeUIMnTJm+rpukl15iVhhomT3OssbKL6XrF404U/JVSw08Pwj f76129glMrDN3Ohzz8kVF6Cux9yzge7DJPd3buUPachc56XyK24a4TNIgX7QWQ5v8azW FZKpADZVyGLZ91cpk28QDaMq3DFk85oMAhKiFSxbK4/rsRu+RGY+tycCHYXstceXXQXk 84/A== X-Gm-Message-State: AA+aEWYBJrvRZ9aQ29d2n+PcMCf+M31QTSLnu+p1wfY4d2DP8rjJG6/C B742mBdW1E3hwNzsfAt3LByTFhUOIzuy5p4axQHBBRAXOM0TG/6vTtbVkNB8FcEPjBUT2zTkC7p ZZosMffmncM5Wu1sN+lFCavz+eStL4P6UCDqwP+RNaYUMugwS7329FbRRTKWctlC6dYwQUf0Iu5 5g0981PWAXc3NrJL3MNG+PNNhYdavv58hVI1sPPEyDJZl0I47XIis+vI9Nf3XIY6HyJf0d6oRlt JNbX0BGYX7nlJwUBG//3ORToFla9xVYUi68FVsnwBeNZnne/IaElSLpokl93TK/Vca7Fo6v7lYL E02IAZa+5XarSyTlQVJICEXkXAMvS8T4ewpTlDgJmx0gUtm3ncgCBBBiCIRnAz31FYX1OHnPSZE S X-Received: by 2002:a19:1994:: with SMTP id 142mr24999684lfz.134.1546525359371; Thu, 03 Jan 2019 06:22:39 -0800 (PST) X-Received: by 2002:a19:1994:: with SMTP id 142mr24999644lfz.134.1546525358137; Thu, 03 Jan 2019 06:22:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546525358; cv=none; d=google.com; s=arc-20160816; b=0s54UfSipTLvw/1+cCMh7eW7576vXjsuSWZY/w1hklPcbLxvPvfIr59vHhqYhFF95k 0sX04HttY4BnOdMbnVxjSA/xm5V/0w8aa17+02bn67li+yKIQ13DIbyPVVGh+LmeYi3P RwIbfHyvt/FjyYFSentFGqvU+dcMT5d3eZs8XYKwFzP0nYFCFy9UxUfSRdl8ZCXgU9Ug BnFqjaeXXGD9K/aVewiC1k4NPdoiHc7g5JsfhiOzDadkqveYDLHbEbfbOWLISr3Xys4W 8P++4q1UAiN/ELEomwm2QwGV0iID0wQEEiWYtSK4CFmlC/kmoL+JA4nezQQv18rBQWRl ssVA== 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=KGoHN334DZNkqWv2smL0AGypDg5avCRm0FTt0IHsxCg=; b=kQX4U4xkSdu4XZsu8r/cTsciOKR4OMM1+MRA5MbLGb88c9ibNHM8809my9zPucv3cQ ehh6UMarUP4ZBjeWO1m5j5t1EvbVlYzOByGXvDqXr8+XFFcsyFS7CzDT//a+Ak4aaJra z+3QxTXEsbzUb87TVivZNATILLMzYLnE6fRG4DOks0cFrjM3k5D5gw2p6TtnFu1NFdJl 6U8g2GvZn9NTyhRMdCwM14QGWc5A1VUWZbgEWvkRJKtwFeWGnlUOUxjajfJvXV8kRE6P IDq76G24QJqzREsTKEcp0rCGeSfRDeugnPB+ZjoEU3s6+RtJGjjEG9zZlh2eYuIaD2/o e8Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FgXnFROF; 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 r16-v6sor31631756ljr.41.2019.01.03.06.22.37 for (Google Transport Security); Thu, 03 Jan 2019 06:22:38 -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=FgXnFROF; 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=KGoHN334DZNkqWv2smL0AGypDg5avCRm0FTt0IHsxCg=; b=FgXnFROF2uw5rUs18+D159AuX48O8b00qTHM3dz0lrZAa1rbwI7PiZCJ1yoSul7UCd XMbsEJsTx5VDoT5670LhhPnf8AWKVe0cfNg3Y7Q3YWMz8xoAGkJ4qbYJhGyBo7J3n6d/ /BVTHQnZNZNCGdizso4JPLXTJE00INLjXw79x80sUYNUUluRl7eJwEcboIOFXPXhczX9 +ysMm+cOZiVJr2Di7GmWjFBiv3dDTrnytTKS2bR9vRmzNLZFp/Sp/2ap3KoTZ5VD1p9m 7SzNsxYqQaVGCrepXCboSFeg3gJ9u3HHowf+Zba2DMXjIxLcg6O8NHjNLr0yAILYwmAw wi+Q== X-Google-Smtp-Source: AFSGD/VlHsOjo4kT1Htw31QucG73s9as9B/mjMeVAQu9hdC+qKe3PonCTrE6ghy6ar9qEsEa94uBsg== X-Received: by 2002:a2e:744:: with SMTP id i4-v6mr26451587ljd.140.1546525357638; Thu, 03 Jan 2019 06:22:37 -0800 (PST) Received: from localhost.localdomain ([37.212.195.0]) by smtp.gmail.com with ESMTPSA id b25sm10594690lfa.96.2019.01.03.06.22.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Jan 2019 06:22:37 -0800 (PST) From: "Uladzislau Rezki (Sony)" To: Andrew Morton , Michal Hocko , Kees Cook , Matthew Wilcox , linux-mm@kvack.org, Shuah Khan Cc: LKML , Oleksiy Avramchenko , Thomas Gleixner , "Uladzislau Rezki (Sony)" Subject: [RFC PATCH 3/3] selftests/vm: add script helper for CONFIG_TEST_VMALLOC_MODULE Date: Thu, 3 Jan 2019 15:21:08 +0100 Message-Id: <20190103142108.20744-4-urezki@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190103142108.20744-1-urezki@gmail.com> References: <20190103142108.20744-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) Reviewed-by: Shuah Khan --- 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 584a91ae4a8f..951c507a27f7 100755 --- a/tools/testing/selftests/vm/run_vmtests +++ b/tools/testing/selftests/vm/run_vmtests @@ -211,4 +211,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