Received: by 10.223.176.46 with SMTP id f43csp3878585wra; Tue, 23 Jan 2018 00:12:32 -0800 (PST) X-Google-Smtp-Source: AH8x225XVVk+1Kcp/Sglg/kLoZAbLNQJvSm8mfIaGPydX7ZmhYegR3AqpM0LdPh3cEp0uxZkKo7U X-Received: by 2002:a17:902:6087:: with SMTP id s7-v6mr4778765plj.6.1516695152492; Tue, 23 Jan 2018 00:12:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516695152; cv=none; d=google.com; s=arc-20160816; b=ctqVMPaihfBAhnhY/xURHg5AUjRGZo9TQUaWyXduob1gdI563z8J9Mvi35DaAYqmzr Hxn0pp9JHek17nvPXzJ/YLVWLLDCsaTGexZMAycHjLRjsjYJyDfCwn+YEGUgqyUqayjg OXZu1I/MTvkbGFsmYNnDlFtgOGlVKK3IEnEIbRof8SsOR+44pXKP1qykUH3WrGcLZ2Ol yM6aPSn6rnn61TAOg/7CYpcqhBJKFcG1FyqNwuj8ph9XD1/2DpGNKdmLG7NIaS3MeWOs qtmKf+1o52yeDTbuKv8JJIMI8O3OqJ0fDnAvqGNYAEPrGtD197yi6/P33UpO1G8x2gPg cw+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=H//pT0bCSefQKNwECeNVlOuU7ACwPV0dPJCVtXdoSdk=; b=fWS9oKF9ud/byAkj28F3Ul/ujqp/F3e3fGGBED9yF4HnhwaHtVZv0IrdNoSL3x/RrV QcjW/xb2W5rTsX59gEcgIfNu41mGOxKZctjjI8xOs/9s4t3uFbofwSwVlADK7arracg3 JfP9/AJFLYehRTOgAqzhLLkkJoV+JoFt3QsJp1GEb4W244/gp+7weFfZlErnmZOGizn4 VSihcLbtUuCwUI51hUXm1JOPeHftnhAtZcnab0qZyPDYJB6dmW1kAOBCSihlqnTo9GkN tVKwAe1H1BozpaZk1+jIAbouFzy3ZVyoduDyVVtBNVIixoDXNuSYEPQpJmmSUy8I1Oed R4RA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si4400367pgp.285.2018.01.23.00.12.18; Tue, 23 Jan 2018 00:12:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751498AbeAWIKM (ORCPT + 99 others); Tue, 23 Jan 2018 03:10:12 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:4279 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751309AbeAWIIw (ORCPT ); Tue, 23 Jan 2018 03:08:52 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 7A0A3709614AA; Tue, 23 Jan 2018 16:08:36 +0800 (CST) Received: from huawei.com (10.175.102.37) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.361.1; Tue, 23 Jan 2018 16:08:32 +0800 From: To: CC: , , , , Subject: [PATCH RFC 15/16] rcutorture: Add scripts to run experiments Date: Tue, 23 Jan 2018 15:59:40 +0800 Message-ID: <1516694381-20333-16-git-send-email-lianglihao@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1516694381-20333-1-git-send-email-lianglihao@huawei.com> References: <1516694381-20333-1-git-send-email-lianglihao@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lihao Liang Signed-off-by: Lihao Liang --- kvm.sh | 452 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ run-rcuperf.sh | 26 ++++ 2 files changed, 478 insertions(+) create mode 100755 kvm.sh create mode 100755 run-rcuperf.sh diff --git a/kvm.sh b/kvm.sh new file mode 100755 index 00000000..3b3c1b69 --- /dev/null +++ b/kvm.sh @@ -0,0 +1,452 @@ +#!/bin/bash +# +# Run a series of 14 tests under KVM. These are not particularly +# well-selected or well-tuned, but are the current set. Run from the +# top level of the source tree. +# +# Edit the definitions below to set the locations of the various directories, +# as well as the test duration. +# +# Usage: kvm.sh [ options ] +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you can access it online at +# http://www.gnu.org/licenses/gpl-2.0.html. +# +# Copyright (C) IBM Corporation, 2011 +# +# Authors: Paul E. McKenney + +scriptname=$0 +args="$*" + +T=/tmp/kvm.sh.$$ +trap 'rm -rf $T' 0 +mkdir $T + +dur=$((30*60)) +dryrun="" +KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM +PATH=${KVM}/bin:$PATH; export PATH +TORTURE_DEFCONFIG=defconfig +TORTURE_BOOT_IMAGE="" +TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD +TORTURE_KMAKE_ARG="" +TORTURE_SHUTDOWN_GRACE=180 +TORTURE_SUITE=rcu +resdir="" +configs="" +cpus=0 +ds=`date +%Y.%m.%d-%H:%M:%S` +jitter="-1" + +. functions.sh + +usage () { + echo "Usage: $scriptname optional arguments:" + echo " --bootargs kernel-boot-arguments" + echo " --bootimage relative-path-to-kernel-boot-image" + echo " --buildonly" + echo " --configs \"config-file list w/ repeat factor (3*TINY01)\"" + echo " --cpus N" + echo " --datestamp string" + echo " --defconfig string" + echo " --dryrun sched|script" + echo " --duration minutes" + echo " --interactive" + echo " --jitter N [ maxsleep (us) [ maxspin (us) ] ]" + echo " --kmake-arg kernel-make-arguments" + echo " --mac nn:nn:nn:nn:nn:nn" + echo " --no-initrd" + echo " --qemu-args qemu-system-..." + echo " --qemu-cmd qemu-system-..." + echo " --results absolute-pathname" + echo " --torture rcu" + exit 1 +} + +while test $# -gt 0 +do + case "$1" in + --bootargs|--bootarg) + checkarg --bootargs "(list of kernel boot arguments)" "$#" "$2" '.*' '^--' + TORTURE_BOOTARGS="$2" + shift + ;; + --bootimage) + checkarg --bootimage "(relative path to kernel boot image)" "$#" "$2" '[a-zA-Z0-9][a-zA-Z0-9_]*' '^--' + TORTURE_BOOT_IMAGE="$2" + shift + ;; + --buildonly) + TORTURE_BUILDONLY=1 + ;; + --configs|--config) + checkarg --configs "(list of config files)" "$#" "$2" '^[^/]*$' '^--' + configs="$2" + shift + ;; + --cpus) + checkarg --cpus "(number)" "$#" "$2" '^[0-9]*$' '^--' + cpus=$2 + shift + ;; + --datestamp) + checkarg --datestamp "(relative pathname)" "$#" "$2" '^[^/]*$' '^--' + ds=$2 + shift + ;; + --defconfig) + checkarg --defconfig "defconfigtype" "$#" "$2" '^[^/][^/]*$' '^--' + TORTURE_DEFCONFIG=$2 + shift + ;; + --dryrun) + checkarg --dryrun "sched|script" $# "$2" 'sched\|script' '^--' + dryrun=$2 + shift + ;; + --duration) + checkarg --duration "(minutes)" $# "$2" '^[0-9]*$' '^error' + dur=$(($2*60)) + shift + ;; + --interactive) + TORTURE_QEMU_INTERACTIVE=1; export TORTURE_QEMU_INTERACTIVE + ;; + --jitter) + checkarg --jitter "(# threads [ sleep [ spin ] ])" $# "$2" '^-\{,1\}[0-9]\+\( \+[0-9]\+\)\{,2\} *$' '^error$' + jitter="$2" + shift + ;; + --kmake-arg) + checkarg --kmake-arg "(kernel make arguments)" $# "$2" '.*' '^error$' + TORTURE_KMAKE_ARG="$2" + shift + ;; + --mac) + checkarg --mac "(MAC address)" $# "$2" '^\([0-9a-fA-F]\{2\}:\)\{5\}[0-9a-fA-F]\{2\}$' error + TORTURE_QEMU_MAC=$2 + shift + ;; + --no-initrd) + TORTURE_INITRD=""; export TORTURE_INITRD + ;; + --qemu-args|--qemu-arg) + checkarg --qemu-args "-qemu args" $# "$2" '^-' '^error' + TORTURE_QEMU_ARG="$2" + shift + ;; + --qemu-cmd) + checkarg --qemu-cmd "(qemu-system-...)" $# "$2" 'qemu-system-' '^--' + TORTURE_QEMU_CMD="$2" + shift + ;; + --results) + checkarg --results "(absolute pathname)" "$#" "$2" '^/' '^error' + resdir=$2 + shift + ;; + --shutdown-grace) + checkarg --shutdown-grace "(seconds)" "$#" "$2" '^[0-9]*$' '^error' + TORTURE_SHUTDOWN_GRACE=$2 + shift + ;; + --torture) + checkarg --torture "(suite name)" "$#" "$2" '^\(lock\|rcu\|rcuperf\)$' '^--' + TORTURE_SUITE=$2 + shift + ;; + *) + echo Unknown argument $1 + usage + ;; + esac + shift +done + +CONFIGFRAG=${KVM}/configs/${TORTURE_SUITE}; export CONFIGFRAG + +if test -z "$configs" +then + configs="`cat $CONFIGFRAG/CFLIST`" +fi + +if test -z "$resdir" +then + resdir=$KVM/res +fi + +# Create a file of test-name/#cpus pairs, sorted by decreasing #cpus. +touch $T/cfgcpu +for CF in $configs +do + case $CF in + [0-9]\**|[0-9][0-9]\**|[0-9][0-9][0-9]\**) + config_reps=`echo $CF | sed -e 's/\*.*$//'` + CF1=`echo $CF | sed -e 's/^[^*]*\*//'` + ;; + *) + config_reps=1 + CF1=$CF + ;; + esac + if test -f "$CONFIGFRAG/$CF1" + then + cpu_count=`configNR_CPUS.sh $CONFIGFRAG/$CF1` + cpu_count=`configfrag_boot_cpus "$TORTURE_BOOTARGS" "$CONFIGFRAG/$CF1" "$cpu_count"` + for ((cur_rep=0;cur_rep<$config_reps;cur_rep++)) + do + echo $CF1 $cpu_count >> $T/cfgcpu + done + else + echo "The --configs file $CF1 does not exist, terminating." + exit 1 + fi +done +sort -k2nr $T/cfgcpu > $T/cfgcpu.sort + +# Use a greedy bin-packing algorithm, sorting the list accordingly. +awk < $T/cfgcpu.sort > $T/cfgcpu.pack -v ncpus=$cpus ' +BEGIN { + njobs = 0; +} + +{ + # Read file of tests and corresponding required numbers of CPUs. + cf[njobs] = $1; + cpus[njobs] = $2; + njobs++; +} + +END { + alldone = 0; + batch = 0; + nc = -1; + + # Each pass through the following loop creates on test batch + # that can be executed concurrently given ncpus. Note that a + # given test that requires more than the available CPUs will run in + # their own batch. Such tests just have to make do with what + # is available. + while (nc != ncpus) { + batch++; + nc = ncpus; + + # Each pass through the following loop considers one + # test for inclusion in the current batch. + for (i = 0; i < njobs; i++) { + if (done[i]) + continue; # Already part of a batch. + if (nc >= cpus[i] || nc == ncpus) { + + # This test fits into the current batch. + done[i] = batch; + nc -= cpus[i]; + if (nc <= 0) + break; # Too-big test in its own batch. + } + } + } + + # Dump out the tests in batch order. + for (b = 1; b <= batch; b++) + for (i = 0; i < njobs; i++) + if (done[i] == b) + print cf[i], cpus[i]; +}' + +# Generate a script to execute the tests in appropriate batches. +cat << ___EOF___ > $T/script +CONFIGFRAG="$CONFIGFRAG"; export CONFIGFRAG +KVM="$KVM"; export KVM +PATH="$PATH"; export PATH +TORTURE_BOOT_IMAGE="$TORTURE_BOOT_IMAGE"; export TORTURE_BOOT_IMAGE +TORTURE_BUILDONLY="$TORTURE_BUILDONLY"; export TORTURE_BUILDONLY +TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG +TORTURE_INITRD="$TORTURE_INITRD"; export TORTURE_INITRD +TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG"; export TORTURE_KMAKE_ARG +TORTURE_QEMU_CMD="$TORTURE_QEMU_CMD"; export TORTURE_QEMU_CMD +TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE"; export TORTURE_QEMU_INTERACTIVE +TORTURE_QEMU_MAC="$TORTURE_QEMU_MAC"; export TORTURE_QEMU_MAC +TORTURE_SHUTDOWN_GRACE="$TORTURE_SHUTDOWN_GRACE"; export TORTURE_SHUTDOWN_GRACE +TORTURE_SUITE="$TORTURE_SUITE"; export TORTURE_SUITE +if ! test -e $resdir +then + mkdir -p "$resdir" || : +fi +mkdir $resdir/$ds +echo Results directory: $resdir/$ds +echo $scriptname $args +touch $resdir/$ds/log +echo $scriptname $args >> $resdir/$ds/log +echo ${TORTURE_SUITE} > $resdir/$ds/TORTURE_SUITE +pwd > $resdir/$ds/testid.txt +if test -d .git +then + git status >> $resdir/$ds/testid.txt + git rev-parse HEAD >> $resdir/$ds/testid.txt + if ! git diff HEAD > $T/git-diff 2>&1 + then + cp $T/git-diff $resdir/$ds + fi +fi +___EOF___ +awk < $T/cfgcpu.pack \ + -v TORTURE_BUILDONLY="$TORTURE_BUILDONLY" \ + -v CONFIGDIR="$CONFIGFRAG/" \ + -v KVM="$KVM" \ + -v ncpus=$cpus \ + -v jitter="$jitter" \ + -v rd=$resdir/$ds/ \ + -v dur=$dur \ + -v TORTURE_QEMU_ARG="$TORTURE_QEMU_ARG" \ + -v TORTURE_BOOTARGS="$TORTURE_BOOTARGS" \ +'BEGIN { + i = 0; +} + +{ + cf[i] = $1; + cpus[i] = $2; + i++; +} + +# Dump out the scripting required to run one test batch. +function dump(first, pastlast, batchnum) +{ + print "echo ----Start batch " batchnum ": `date`"; + print "echo ----Start batch " batchnum ": `date` >> " rd "/log"; + jn=1 + for (j = first; j < pastlast; j++) { + builddir=KVM "/b" jn + cpusr[jn] = cpus[j]; + if (cfrep[cf[j]] == "") { + cfr[jn] = cf[j]; + cfrep[cf[j]] = 1; + } else { + cfrep[cf[j]]++; + cfr[jn] = cf[j] "." cfrep[cf[j]]; + } + if (cpusr[jn] > ncpus && ncpus != 0) + ovf = "-ovf"; + else + ovf = ""; + print "echo ", cfr[jn], cpusr[jn] ovf ": Starting build. `date`"; + print "echo ", cfr[jn], cpusr[jn] ovf ": Starting build. `date` >> " rd "/log"; + print "rm -f " builddir ".*"; + print "touch " builddir ".wait"; + print "mkdir " builddir " > /dev/null 2>&1 || :"; + print "mkdir " rd cfr[jn] " || :"; + print "kvm-test-1-run.sh " CONFIGDIR cf[j], builddir, rd cfr[jn], dur " \"" TORTURE_QEMU_ARG "\" \"" TORTURE_BOOTARGS "\" > " rd cfr[jn] "/kvm-test-1-run.sh.out 2>&1 &" + print "echo ", cfr[jn], cpusr[jn] ovf ": Waiting for build to complete. `date`"; + print "echo ", cfr[jn], cpusr[jn] ovf ": Waiting for build to complete. `date` >> " rd "/log"; + print "while test -f " builddir ".wait" + print "do" + print "\tsleep 1" + print "done" + print "echo ", cfr[jn], cpusr[jn] ovf ": Build complete. `date`"; + print "echo ", cfr[jn], cpusr[jn] ovf ": Build complete. `date` >> " rd "/log"; + jn++; + } + for (j = 1; j < jn; j++) { + builddir=KVM "/b" j + print "rm -f " builddir ".ready" + print "if test -z \"$TORTURE_BUILDONLY\"" + print "then" + print "\techo ----", cfr[j], cpusr[j] ovf ": Starting kernel. `date`"; + print "\techo ----", cfr[j], cpusr[j] ovf ": Starting kernel. `date` >> " rd "/log"; + print "fi" + } + njitter = 0; + split(jitter, ja); + if (ja[1] == -1 && ncpus == 0) + njitter = 1; + else if (ja[1] == -1) + njitter = ncpus; + else + njitter = ja[1]; + if (TORTURE_BUILDONLY && njitter != 0) { + njitter = 0; + print "echo Build-only run, so suppressing jitter >> " rd "/log" + } + for (j = 0; j < njitter; j++) + print "jitter.sh " j " " dur " " ja[2] " " ja[3] "&" + print "wait" + print "if test -z \"$TORTURE_BUILDONLY\"" + print "then" + print "\techo ---- All kernel runs complete. `date`"; + print "\techo ---- All kernel runs complete. `date` >> " rd "/log"; + print "fi" + for (j = 1; j < jn; j++) { + builddir=KVM "/b" j + print "echo ----", cfr[j], cpusr[j] ovf ": Build/run results:"; + print "echo ----", cfr[j], cpusr[j] ovf ": Build/run results: >> " rd "/log"; + print "cat " rd cfr[j] "/kvm-test-1-run.sh.out"; + print "cat " rd cfr[j] "/kvm-test-1-run.sh.out >> " rd "/log"; + } +} + +END { + njobs = i; + nc = ncpus; + first = 0; + batchnum = 1; + + # Each pass through the following loop considers one test. + for (i = 0; i < njobs; i++) { + if (ncpus == 0) { + # Sequential test specified, each test its own batch. + dump(i, i + 1, batchnum); + first = i; + batchnum++; + } else if (nc < cpus[i] && i != 0) { + # Out of CPUs, dump out a batch. + dump(first, i, batchnum); + first = i; + nc = ncpus; + batchnum++; + } + # Account for the CPUs needed by the current test. + nc -= cpus[i]; + } + # Dump the last batch. + if (ncpus != 0) + dump(first, i, batchnum); +}' >> $T/script + +cat << ___EOF___ >> $T/script +echo +echo +echo " --- `date` Test summary:" +echo Results directory: $resdir/$ds +kvm-recheck.sh $resdir/$ds +___EOF___ + +if test "$dryrun" = script +then + cat $T/script + exit 0 +elif test "$dryrun" = sched +then + # Extract the test run schedule from the script. + egrep 'Start batch|Starting build\.' $T/script | + grep -v ">>" | + sed -e 's/:.*$//' -e 's/^echo //' + exit 0 +else + # Not a dryrun, so run the script. + sh $T/script +fi + +# Tracing: trace_event=rcu:rcu_grace_period,rcu:rcu_future_grace_period,rcu:rcu_grace_period_init,rcu:rcu_nocb_wake,rcu:rcu_preempt_task,rcu:rcu_unlock_preempted_task,rcu:rcu_quiescent_state_report,rcu:rcu_fqs,rcu:rcu_callback,rcu:rcu_kfree_callback,rcu:rcu_batch_start,rcu:rcu_invoke_callback,rcu:rcu_invoke_kfree_callback,rcu:rcu_batch_end,rcu:rcu_torture_read,rcu:rcu_barrier diff --git a/run-rcuperf.sh b/run-rcuperf.sh new file mode 100755 index 00000000..0526fff1 --- /dev/null +++ b/run-rcuperf.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +dur=10 +run=10 +torture="rcuperf" +rest="1m" +path=`pwd` + +for cpu in 4 8 16 +do + for type in PRCU TREE + do + folder="$path/res/rcuperf/cpu-$cpu/$type" + if ! test -d $folder + then + echo "$folder does not exist..." + exit + fi + + echo "Running rcuperf-$type-${cpu}cpus..." + `./kvm.sh --torture $torture --duration $dur --configs ${run}*${type}-${cpu} --results $folder &> $folder/$type-cpu${cpu}-${dur}min.out` + + echo "Sleep $rest..." + `sleep $rest` + done +done -- 2.14.1.729.g59c0ea183