From b26dc289d048912f39e465175b8f4317c7f691ca Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Mon, 2 Feb 2015 22:13:24 -0800 Subject: [PATCH] toplev: Fix --kernel separator handling and improve test suite --- tl-tester | 58 +++++++++++++++++++++++++++++++++++-------------------- toplev.py | 9 +++++++-- 2 files changed, 44 insertions(+), 23 deletions(-) diff --git a/tl-tester b/tl-tester index ff8900a1..e030f3ca 100755 --- a/tl-tester +++ b/tl-tester @@ -2,6 +2,7 @@ # simple regression tester for toplev # this just tests if all events resolve etc, as it would # need the individual CPUs. +# for non root set kernel.perf_event_paranoid = -1 set -e set -x @@ -27,7 +28,15 @@ LOAD="-- gcc -o /dev/null hello.c" set -o pipefail -ALLCPUS="snb ivb ivt hsw hsx bdw slm" +SMTCPUS="ivb ivt hsw hsx" # bdw +NOSMTCPUS="snb jkt slm" +ALLCPUS="$SMTCPUS $NOSMTCPUS" + +if [ $(whoami) = root ] ; then + ALL="--all" +else + ALL="--metrics -l5 --tsx --power" +fi EVENTMAP=${cpus[ivb]} FORCECPU=$j $WRAP ./toplev.py $LOAD DIRECT_MSR=1 EVENTMAP=${cpus[ivb]} FORCECPU=$j $WRAP ./toplev.py $LOAD @@ -35,39 +44,46 @@ EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py -d -l4 $LOAD EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py -v -d -l4 $LOAD EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py -x, -v -d -l4 $LOAD EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py --metrics -x, -v -d -l4 $LOAD -EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py -d --all --kernel $LOAD +EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py -d $ALL --kernel $LOAD | tee log +grep :k log +grep /k log + +# test L1 uses a single group +onegroup() { + grep perf | tr -cd '{}' | awk ' { if ($1 != "{}") { print "more than one group for L1" ; exit(1); } } ' +} + +for j in $SMTCPUS ; do +EVENTMAP=${cpus[$j]} FORCEHT=1 FORCECPU=$j $WRAP ./toplev.py -d -l1 $LOAD | tee log +onegroup < log +EVENTMAP=${cpus[$j]} FORCEHT=0 FORCECPU=$j $WRAP ./toplev.py -d -l1 $LOAD | tee log +onegroup < log +EVENTMAP=${cpus[$j]} FORCEHT=1 FORCECPU=$j $WRAP ./toplev.py -d $ALL $LOAD +EVENTMAP=${cpus[$j]} FORCEHT=0 FORCECPU=$j $WRAP ./toplev.py -d $ALL $LOAD +done -for j in $ALLCPUS ; do -EVENTMAP=${cpus[$j]} FORCECPU=$j $WRAP ./toplev.py -d -l1 $LOAD -EVENTMAP=${cpus[$j]} FORCECPU=$j $WRAP ./toplev.py -d --all $LOAD -EVENTMAP=${cpus[$j]} FORCECPU=$j $WRAP ./toplev.py -d --all -l5 $LOAD +for j in $NOSMTCPUS ; do +EVENTMAP=${cpus[$j]} FORCECPU=$j $WRAP ./toplev.py -d -l1 $LOAD | tee log +onegroup < log +EVENTMAP=${cpus[$j]} FORCECPU=$j $WRAP ./toplev.py -d $ALL $LOAD done +# misc features EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py -d --metrics --no-multiplex -l4 $LOAD EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py -d --power -l4 $LOAD -EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py -d --all --no-group $LOAD -EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py -d --all --user $LOAD +EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py -d $ALL --no-group $LOAD EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py -d --sw -l4 $LOAD EVENTMAP=${cpus[hsw]} FORCECPU=hsw $WRAP ./toplev.py --graph -o x.png -d --metrics -l4 $LOAD EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py -d -l4 -I 100 sleep 1 EVENTMAP=${cpus[ivb]} FORCECPU=ivb $WRAP ./toplev.py -d -l4 --user $LOAD | tee log grep :u log - -# test L1 uses a single group -onegroup() { - tr -cd '{}' | awk ' { if ($1 != "{}") { print "more than one group for L1" ; exit(1); } ' -} - -for j in $ALLCPUS ; do -EVENTMAP=${cpus[$j]} FORCECPU=$j $WRAP ./toplev.py -l1 true $LOAD | onegroup -done +grep /u log # need new perf # test other perf output formats -# need force smt off first -#EVENTMAP=${cpus[snb]} FORCECPU=snb $WRAP ./toplev.py -d -l4 -I 1000 -a --per-core sleep 1 -#EVENTMAP=${cpus[snb]} FORCECPU=snb $WRAP ./toplev.py -d -l4 -I 1000 -a --per-socket sleep 1 -#EVENTMAP=${cpus[snb]} FORCECPU=snb $WRAP ./toplev.py -d -l4 -I 1000 -a -A sleep 1 +EVENTMAP=${cpus[snb]} FORCEHT=0 FORCECPU=snb $WRAP ./toplev.py -d -l4 -I 1000 -a --per-core sleep 1 +EVENTMAP=${cpus[snb]} FORCEHT=0 FORCECPU=snb $WRAP ./toplev.py -d -l4 -I 1000 -a --per-socket sleep 1 +EVENTMAP=${cpus[snb]} FORCEHT=0 FORCECPU=snb $WRAP ./toplev.py -d -l4 -I 1000 -a -A sleep 1 trap "" ERR 0 diff --git a/toplev.py b/toplev.py index 47197dd0..521a1487 100755 --- a/toplev.py +++ b/toplev.py @@ -429,10 +429,15 @@ def filter_string(): return filter_to_perf[ring_filter] return "" +def separator(x): + if x.startswith("cpu"): + return "" + return ":" + def add_filter(s): f = filter_string() if f: - s = set([x + ":" + f for x in s]) + s = set([x + separator(x) + f for x in s]) return s def raw_event(i): @@ -440,7 +445,7 @@ def raw_event(i): if i in fixed_counters: i = fixed_counters[i] if filter_string(): - if ":" not in i: + if ":" not in i and not i.startswith("cpu"): i += ":" i += filter_string() return i