Skip to content

Commit

Permalink
toplev: Default to -a and add --single-thread
Browse files Browse the repository at this point in the history
  • Loading branch information
Andi Kleen committed Apr 3, 2015
1 parent 50ac3a6 commit d5344c5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
9 changes: 6 additions & 3 deletions tl-tester
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
34 changes: 21 additions & 13 deletions toplev.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit d5344c5

Please sign in to comment.