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

perf bench: Harmonize all the -l/--nr_loops options

We have three benchmarking subsystems that specify some sort of 'number
of loops' parameter - but all of them do it inconsistently:

numa: -l/--nr_loops
sched messaging: -l/--loops
mem memset/memcpy: -i/--iterations

Harmonize them to -l/--nr_loops by picking the numa variant - which is
also the most likely one to have existing scripting which we don't want
to break.

Plus improve the parameter help texts to indicate the default value for
the nr_loops variable to keep users from guessing ...

Also propagate the naming to internal variables.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1445241870-24854-13-git-send-email-mingo@kernel.org
[ Let the harmonisation reach the perf-bench man page as well ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ingo Molnar and committed by
Arnaldo Carvalho de Melo
b0d22e52 5dd93304

+23 -23
+5 -5
tools/perf/Documentation/perf-bench.txt
··· 82 82 Specify number of groups 83 83 84 84 -l:: 85 - --loop=:: 85 + --nr_loops=:: 86 86 Specify number of loops 87 87 88 88 Example of *messaging* ··· 149 149 Available routines are depend on the architecture. 150 150 On x86-64, x86-64-unrolled, x86-64-movsq and x86-64-movsb are supported. 151 151 152 - -i:: 153 - --iterations:: 152 + -l:: 153 + --nr_loops:: 154 154 Repeat memcpy invocation this number of times. 155 155 156 156 -c:: ··· 173 173 Available routines are depend on the architecture. 174 174 On x86-64, x86-64-unrolled, x86-64-stosq and x86-64-stosb are supported. 175 175 176 - -i:: 177 - --iterations:: 176 + -l:: 177 + --nr_loops:: 178 178 Repeat memset invocation this number of times. 179 179 180 180 -c::
+11 -11
tools/perf/bench/mem-functions.c
··· 25 25 26 26 static const char *size_str = "1MB"; 27 27 static const char *routine_str = "all"; 28 - static int iterations = 1; 28 + static int nr_loops = 1; 29 29 static bool use_cycles; 30 30 static int cycles_fd; 31 31 32 32 static const struct option options[] = { 33 - OPT_STRING('l', "size", &size_str, "1MB", 33 + OPT_STRING('s', "size", &size_str, "1MB", 34 34 "Specify the size of the memory buffers. " 35 35 "Available units: B, KB, MB, GB and TB (case insensitive)"), 36 36 37 37 OPT_STRING('r', "routine", &routine_str, "all", 38 38 "Specify the routine to run, \"all\" runs all available routines, \"help\" lists them"), 39 39 40 - OPT_INTEGER('i', "iterations", &iterations, 41 - "Repeat the function this number of times"), 40 + OPT_INTEGER('l', "nr_loops", &nr_loops, 41 + "Specify the number of loops to run. (default: 1)"), 42 42 43 43 OPT_BOOLEAN('c', "cycles", &use_cycles, 44 44 "Use a cycles event instead of gettimeofday() to measure performance"), ··· 159 159 init_cycles(); 160 160 161 161 size = (size_t)perf_atoll((char *)size_str); 162 - size_total = (double)size * iterations; 162 + size_total = (double)size * nr_loops; 163 163 164 164 if ((s64)size <= 0) { 165 165 fprintf(stderr, "Invalid size:%s\n", size_str); ··· 222 222 fn(dst, src, size); 223 223 224 224 cycle_start = get_cycles(); 225 - for (i = 0; i < iterations; ++i) 225 + for (i = 0; i < nr_loops; ++i) 226 226 fn(dst, src, size); 227 227 cycle_end = get_cycles(); 228 228 ··· 247 247 fn(dst, src, size); 248 248 249 249 BUG_ON(gettimeofday(&tv_start, NULL)); 250 - for (i = 0; i < iterations; ++i) 250 + for (i = 0; i < nr_loops; ++i) 251 251 fn(dst, src, size); 252 252 BUG_ON(gettimeofday(&tv_end, NULL)); 253 253 ··· 256 256 free(src); 257 257 free(dst); 258 258 259 - return (double)(((double)size * iterations) / timeval2double(&tv_diff)); 259 + return (double)(((double)size * nr_loops) / timeval2double(&tv_diff)); 260 260 } 261 261 262 262 struct routine memcpy_routines[] = { ··· 313 313 fn(dst, -1, size); 314 314 315 315 cycle_start = get_cycles(); 316 - for (i = 0; i < iterations; ++i) 316 + for (i = 0; i < nr_loops; ++i) 317 317 fn(dst, i, size); 318 318 cycle_end = get_cycles(); 319 319 ··· 337 337 fn(dst, -1, size); 338 338 339 339 BUG_ON(gettimeofday(&tv_start, NULL)); 340 - for (i = 0; i < iterations; ++i) 340 + for (i = 0; i < nr_loops; ++i) 341 341 fn(dst, i, size); 342 342 BUG_ON(gettimeofday(&tv_end, NULL)); 343 343 344 344 timersub(&tv_end, &tv_start, &tv_diff); 345 345 346 346 free(dst); 347 - return (double)(((double)size * iterations) / timeval2double(&tv_diff)); 347 + return (double)(((double)size * nr_loops) / timeval2double(&tv_diff)); 348 348 } 349 349 350 350 static const char * const bench_mem_memset_usage[] = {
+2 -2
tools/perf/bench/numa.c
··· 164 164 OPT_STRING('L', "mb_proc_locked", &p0.mb_proc_locked_str,"MB", "process serialized/locked memory access (MBs), <= process_memory"), 165 165 OPT_STRING('T', "mb_thread" , &p0.mb_thread_str, "MB", "thread memory (MBs)"), 166 166 167 - OPT_UINTEGER('l', "nr_loops" , &p0.nr_loops, "max number of loops to run"), 168 - OPT_UINTEGER('s', "nr_secs" , &p0.nr_secs, "max number of seconds to run"), 167 + OPT_UINTEGER('l', "nr_loops" , &p0.nr_loops, "max number of loops to run (default: unlimited)"), 168 + OPT_UINTEGER('s', "nr_secs" , &p0.nr_secs, "max number of seconds to run (default: 5 secs)"), 169 169 OPT_UINTEGER('u', "usleep" , &p0.sleep_usecs, "usecs to sleep per loop iteration"), 170 170 171 171 OPT_BOOLEAN('R', "data_reads" , &p0.data_reads, "access the data via writes (can be mixed with -W)"),
+5 -5
tools/perf/bench/sched-messaging.c
··· 33 33 #define DATASIZE 100 34 34 35 35 static bool use_pipes = false; 36 - static unsigned int loops = 100; 36 + static unsigned int nr_loops = 100; 37 37 static bool thread_mode = false; 38 38 static unsigned int num_groups = 10; 39 39 ··· 79 79 err(EXIT_FAILURE, "poll"); 80 80 } 81 81 82 - /* Sender sprays loops messages down each file descriptor */ 82 + /* Sender sprays nr_loops messages down each file descriptor */ 83 83 static void *sender(struct sender_context *ctx) 84 84 { 85 85 char data[DATASIZE]; ··· 88 88 ready(ctx->ready_out, ctx->wakefd); 89 89 90 90 /* Now pump to every receiver. */ 91 - for (i = 0; i < loops; i++) { 91 + for (i = 0; i < nr_loops; i++) { 92 92 for (j = 0; j < ctx->num_fds; j++) { 93 93 int ret, done = 0; 94 94 ··· 213 213 /* Create the pipe between client and server */ 214 214 fdpair(fds); 215 215 216 - ctx->num_packets = num_fds * loops; 216 + ctx->num_packets = num_fds * nr_loops; 217 217 ctx->in_fds[0] = fds[0]; 218 218 ctx->in_fds[1] = fds[1]; 219 219 ctx->ready_out = ready_out; ··· 250 250 OPT_BOOLEAN('t', "thread", &thread_mode, 251 251 "Be multi thread instead of multi process"), 252 252 OPT_UINTEGER('g', "group", &num_groups, "Specify number of groups"), 253 - OPT_UINTEGER('l', "loop", &loops, "Specify number of loops"), 253 + OPT_UINTEGER('l', "nr_loops", &nr_loops, "Specify the number of loops to run (default: 100)"), 254 254 OPT_END() 255 255 }; 256 256