Skip to content

Commit

Permalink
toplev: Fix --kernel separator handling and improve test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Andi Kleen committed Feb 3, 2015
1 parent 09ecc02 commit b26dc28
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 deletions.
58 changes: 37 additions & 21 deletions tl-tester
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,47 +28,62 @@ 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
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

Expand Down
9 changes: 7 additions & 2 deletions toplev.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,18 +429,23 @@ 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):
if i.count(".") > 0:
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
Expand Down

0 comments on commit b26dc28

Please sign in to comment.