From d5344c561558bb4d8e7369982f199bcc4f876671 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Thu, 2 Apr 2015 17:53:57 -0700 Subject: [PATCH] toplev: Default to -a and add --single-thread --- tl-tester | 9 ++++++--- toplev.py | 34 +++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/tl-tester b/tl-tester index 3fd32a86..4ecca21f 100755 --- a/tl-tester +++ b/tl-tester @@ -25,6 +25,7 @@ int main() { EOL LOAD="-- gcc -o /dev/null hello.c" +LOAD0="-- taskset -c 0 gcc -o /dev/null hello.c" set -o pipefail @@ -43,6 +44,8 @@ DCPU=hsw EVENTMAP=${cpus[$DCPU]} FORCECPU=$DCPU $WRAP ./toplev.py $LOAD DIRECT_MSR=1 EVENTMAP=${cpus[$DCPU]} FORCECPU=$DCPU $WRAP ./toplev.py $LOAD EVENTMAP=${cpus[$DCPU]} FORCECPU=$DCPU $WRAP ./toplev.py --no-desc -d -l4 $LOAD +EVENTMAP=${cpus[$DCPU]} FORCECPU=$DCPU $WRAP ./toplev.py --no-desc -d -l4 --single-thread $LOAD +EVENTMAP=${cpus[$DCPU]} FORCECPU=$DCPU $WRAP ./toplev.py --no-desc -d -l4 --core S0-C0-T0 $LOAD0 EVENTMAP=${cpus[$DCPU]} FORCECPU=$DCPU $WRAP ./toplev.py --no-desc -v -d -l4 $LOAD EVENTMAP=${cpus[$DCPU]} FORCECPU=$DCPU $WRAP ./toplev.py --no-desc -x, -v -d -l4 $LOAD EVENTMAP=${cpus[$DCPU]} FORCECPU=$DCPU $WRAP ./toplev.py --no-desc --metrics -x, -v -d -l4 $LOAD @@ -101,9 +104,9 @@ grep /u log # need new perf # test other perf output formats -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 --no-desc -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 --no-desc -l4 -I 1000 -a -A sleep 1 $WRAP ./toplev.py -o /dev/null --no-desc -v -l5 --run-sample $LOAD for cpu in $ALLCPUS ; do diff --git a/toplev.py b/toplev.py index bf1d8228..e505fdc9 100755 --- a/toplev.py +++ b/toplev.py @@ -263,6 +263,7 @@ def event_group(evlist): p.add_argument('--version', help=argparse.SUPPRESS, action='store_true') p.add_argument('--debug', help=argparse.SUPPRESS, action='store_true') p.add_argument('--core', help='Limit output to cores. Comma list of Sx-Cx-Tx. All parts optional.') +p.add_argument('--single-thread', '-S', help='Measure workload as single thread. Workload run single threaded. In SMT mode other thread must be idle.', action='store_true') args, rest = p.parse_known_args() if args.version: @@ -1323,6 +1324,9 @@ def ht_warning(): if args.debug: pe = lambda x: sys.stdout.write(x + "\n") +if args.single_thread: + cpu.ht = False + if cpu.cpu == "ivb": import ivb_client_ratios ivb_client_ratios.smt_enabled = cpu.ht @@ -1408,26 +1412,30 @@ def setup_with_metrics(p, runner): frequency.SetupCPU(runner, cpu) args.metrics = old_metrics -if smt_mode: - print "Running in HyperThreading mode. Will measure complete system." - if "--per-socket" in rest: - sys.exit("Hyper Threading mode not compatible with --per-socket") - if "--per-core" in rest: - sys.exit("Hyper Threading mode not compatible with --per-core") - if args.cpu: - print >>sys.stderr, "Warning: --cpu/-C mode with HyperThread must specify all core thread pairs!" - if args.pid: - sys.exit("-p/--pid mode not compatible with SMT. Use sleep in global mode.") +if "--per-socket" in rest: + sys.exit("toplev not compatible with --per-socket") +if "--per-core" in rest: + sys.exit("toplev not compatible with --per-core") + +if not args.single_thread: + print "Will measure complete system." + if smt_mode: + if args.cpu: + print >>sys.stderr, "Warning: --cpu/-C mode with HyperThread must specify all core thread pairs!" + if args.pid: + sys.exit("-p/--pid mode not compatible with SMT. Use sleep in global mode.") if not (os.geteuid() == 0 or sysctl("kernel.perf_event_paranoid") == -1): print >>sys.stderr, "Warning: Needs root or echo -1 > /proc/sys/kernel/perf_event_paranoid" - if (cpu.cpu == "ivb" and - (kernel_version[0] == 3 and kernel_version[1] >= 10 and args.level >= 3)): - print >>sys.stderr, "Warning: kernel may need to be patched to schedule all events with level %d in HT mode" % (args.level) + if "-a" not in rest: rest = ["-a"] + rest if "-A" not in rest: rest = ["-A"] + rest +if (cpu.cpu == "ivb" and + (kernel_version[0] == 3 and kernel_version[1] >= 10 and args.level >= 3)): + print >>sys.stderr, "Warning: kernel may need to be patched to schedule all events with level %d in HT mode" % (args.level) + if args.core: rest = ["-C", ",".join(["%d" % x for x in cpu.allcpus if display_core(x)])] + rest