Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/powerpc: Count more instructions & use decimal

Although we expect some small discrepancies for very large counts, we
seem to be able to count up to 64 billion instructions without too much
skew, so do so.

Also switch to using decimals for the instruction counts. This just
makes it easier to visually compare the expected vs actual values, as
well as the raw result from instructions.

Before:

instructions: result 68719476753 running/enabled 13101961654
cycles: result 38077343785 running/enabled 13101725752
Looped for 68719476736 instructions, overhead 17
Expected 68719476753
Actual 68719476753
Delta 0, 0.000000%
success: count_instructions

After:
instructions: result 64000000016 running/enabled 12197599964
cycles: result 35412471674 running/enabled 12197534110
Looped for 64000000000 instructions, overhead 16
Expected 64000000016
Actual 64000000016
Delta 0, 0.000000%
success: count_instructions

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Michael Ellerman and committed by
Benjamin Herrenschmidt
7d3fa968 86450f20

+14 -8
+14 -8
tools/testing/selftests/powerpc/pmu/count_instructions.c
··· 112 112 overhead = determine_overhead(events); 113 113 printf("Overhead of null loop: %llu instructions\n", overhead); 114 114 115 - /* Run for 1M instructions */ 116 - FAIL_IF(do_count_loop(events, 0x100000, overhead, true)); 115 + /* Run for 1Mi instructions */ 116 + FAIL_IF(do_count_loop(events, 1000000, overhead, true)); 117 117 118 - /* Run for 10M instructions */ 119 - FAIL_IF(do_count_loop(events, 0xa00000, overhead, true)); 118 + /* Run for 10Mi instructions */ 119 + FAIL_IF(do_count_loop(events, 10000000, overhead, true)); 120 120 121 - /* Run for 100M instructions */ 122 - FAIL_IF(do_count_loop(events, 0x6400000, overhead, true)); 121 + /* Run for 100Mi instructions */ 122 + FAIL_IF(do_count_loop(events, 100000000, overhead, true)); 123 123 124 - /* Run for 1G instructions */ 125 - FAIL_IF(do_count_loop(events, 0x40000000, overhead, true)); 124 + /* Run for 1Bi instructions */ 125 + FAIL_IF(do_count_loop(events, 1000000000, overhead, true)); 126 + 127 + /* Run for 16Bi instructions */ 128 + FAIL_IF(do_count_loop(events, 16000000000, overhead, true)); 129 + 130 + /* Run for 64Bi instructions */ 131 + FAIL_IF(do_count_loop(events, 64000000000, overhead, true)); 126 132 127 133 event_close(&events[0]); 128 134 event_close(&events[1]);