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

perf bench mem: Rename 'routine' to 'function'

So right now there's a somewhat inconsistent mess of the benchmarking
code and options sometimes calling benchmarked functions 'functions',
sometimes calling them 'routines'.

Name them 'functions' consistently.

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-14-git-send-email-mingo@kernel.org
[ Updated perf-bench man page, pointed out by David Ahern ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ingo Molnar and committed by
Arnaldo Carvalho de Melo
2f211c84 b0d22e52

+38 -38
+8 -8
tools/perf/Documentation/perf-bench.txt
··· 143 143 Specify size of memory to copy (default: 1MB). 144 144 Available units are B, KB, MB, GB and TB (case insensitive). 145 145 146 - -r:: 147 - --routine:: 148 - Specify routine to copy (default: default). 149 - Available routines are depend on the architecture. 146 + -f:: 147 + --function:: 148 + Specify function to copy (default: default). 149 + Available functions 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 152 -l:: ··· 167 167 Specify size of memory to set (default: 1MB). 168 168 Available units are B, KB, MB, GB and TB (case insensitive). 169 169 170 - -r:: 171 - --routine:: 172 - Specify routine to set (default: default). 173 - Available routines are depend on the architecture. 170 + -f:: 171 + --function:: 172 + Specify function to set (default: default). 173 + Available functions 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 176 -l::
+30 -30
tools/perf/bench/mem-functions.c
··· 24 24 #define K 1024 25 25 26 26 static const char *size_str = "1MB"; 27 - static const char *routine_str = "all"; 27 + static const char *function_str = "all"; 28 28 static int nr_loops = 1; 29 29 static bool use_cycles; 30 30 static int cycles_fd; ··· 34 34 "Specify the size of the memory buffers. " 35 35 "Available units: B, KB, MB, GB and TB (case insensitive)"), 36 36 37 - OPT_STRING('r', "routine", &routine_str, "all", 38 - "Specify the routine to run, \"all\" runs all available routines, \"help\" lists them"), 37 + OPT_STRING('f', "function", &function_str, "all", 38 + "Specify the function to run, \"all\" runs all available functions, \"help\" lists them"), 39 39 40 40 OPT_INTEGER('l', "nr_loops", &nr_loops, 41 41 "Specify the number of loops to run. (default: 1)"), ··· 49 49 typedef void *(*memcpy_t)(void *, const void *, size_t); 50 50 typedef void *(*memset_t)(void *, int, size_t); 51 51 52 - struct routine { 52 + struct function { 53 53 const char *name; 54 54 const char *desc; 55 55 union { ··· 101 101 } while (0) 102 102 103 103 struct bench_mem_info { 104 - const struct routine *routines; 105 - u64 (*do_cycles)(const struct routine *r, size_t size); 106 - double (*do_gettimeofday)(const struct routine *r, size_t size); 104 + const struct function *functions; 105 + u64 (*do_cycles)(const struct function *r, size_t size); 106 + double (*do_gettimeofday)(const struct function *r, size_t size); 107 107 const char *const *usage; 108 108 }; 109 109 110 - static void __bench_mem_routine(struct bench_mem_info *info, int r_idx, size_t size, double size_total) 110 + static void __bench_mem_function(struct bench_mem_info *info, int r_idx, size_t size, double size_total) 111 111 { 112 - const struct routine *r = &info->routines[r_idx]; 112 + const struct function *r = &info->functions[r_idx]; 113 113 double result_bps = 0.0; 114 114 u64 result_cycles = 0; 115 115 116 - printf("# Routine '%s' (%s)\n", r->name, r->desc); 116 + printf("# function '%s' (%s)\n", r->name, r->desc); 117 117 118 118 if (bench_format == BENCH_FORMAT_DEFAULT) 119 119 printf("# Copying %s bytes ...\n\n", size_str); ··· 166 166 return 1; 167 167 } 168 168 169 - if (!strncmp(routine_str, "all", 3)) { 170 - for (i = 0; info->routines[i].name; i++) 171 - __bench_mem_routine(info, i, size, size_total); 169 + if (!strncmp(function_str, "all", 3)) { 170 + for (i = 0; info->functions[i].name; i++) 171 + __bench_mem_function(info, i, size, size_total); 172 172 return 0; 173 173 } 174 174 175 - for (i = 0; info->routines[i].name; i++) { 176 - if (!strcmp(info->routines[i].name, routine_str)) 175 + for (i = 0; info->functions[i].name; i++) { 176 + if (!strcmp(info->functions[i].name, function_str)) 177 177 break; 178 178 } 179 - if (!info->routines[i].name) { 180 - if (strcmp(routine_str, "help") && strcmp(routine_str, "h")) 181 - printf("Unknown routine: %s\n", routine_str); 182 - printf("Available routines:\n"); 183 - for (i = 0; info->routines[i].name; i++) { 179 + if (!info->functions[i].name) { 180 + if (strcmp(function_str, "help") && strcmp(function_str, "h")) 181 + printf("Unknown function: %s\n", function_str); 182 + printf("Available functions:\n"); 183 + for (i = 0; info->functions[i].name; i++) { 184 184 printf("\t%s ... %s\n", 185 - info->routines[i].name, info->routines[i].desc); 185 + info->functions[i].name, info->functions[i].desc); 186 186 } 187 187 return 1; 188 188 } 189 189 190 - __bench_mem_routine(info, i, size, size_total); 190 + __bench_mem_function(info, i, size, size_total); 191 191 192 192 return 0; 193 193 } ··· 206 206 memset(*src, 0, size); 207 207 } 208 208 209 - static u64 do_memcpy_cycles(const struct routine *r, size_t size) 209 + static u64 do_memcpy_cycles(const struct function *r, size_t size) 210 210 { 211 211 u64 cycle_start = 0ULL, cycle_end = 0ULL; 212 212 void *src = NULL, *dst = NULL; ··· 231 231 return cycle_end - cycle_start; 232 232 } 233 233 234 - static double do_memcpy_gettimeofday(const struct routine *r, size_t size) 234 + static double do_memcpy_gettimeofday(const struct function *r, size_t size) 235 235 { 236 236 struct timeval tv_start, tv_end, tv_diff; 237 237 memcpy_t fn = r->fn.memcpy; ··· 259 259 return (double)(((double)size * nr_loops) / timeval2double(&tv_diff)); 260 260 } 261 261 262 - struct routine memcpy_routines[] = { 262 + struct function memcpy_functions[] = { 263 263 { .name = "default", 264 264 .desc = "Default memcpy() provided by glibc", 265 265 .fn.memcpy = memcpy }, ··· 281 281 int bench_mem_memcpy(int argc, const char **argv, const char *prefix __maybe_unused) 282 282 { 283 283 struct bench_mem_info info = { 284 - .routines = memcpy_routines, 284 + .functions = memcpy_functions, 285 285 .do_cycles = do_memcpy_cycles, 286 286 .do_gettimeofday = do_memcpy_gettimeofday, 287 287 .usage = bench_mem_memcpy_usage, ··· 297 297 die("memory allocation failed - maybe size is too large?\n"); 298 298 } 299 299 300 - static u64 do_memset_cycles(const struct routine *r, size_t size) 300 + static u64 do_memset_cycles(const struct function *r, size_t size) 301 301 { 302 302 u64 cycle_start = 0ULL, cycle_end = 0ULL; 303 303 memset_t fn = r->fn.memset; ··· 321 321 return cycle_end - cycle_start; 322 322 } 323 323 324 - static double do_memset_gettimeofday(const struct routine *r, size_t size) 324 + static double do_memset_gettimeofday(const struct function *r, size_t size) 325 325 { 326 326 struct timeval tv_start, tv_end, tv_diff; 327 327 memset_t fn = r->fn.memset; ··· 352 352 NULL 353 353 }; 354 354 355 - static const struct routine memset_routines[] = { 355 + static const struct function memset_functions[] = { 356 356 { .name = "default", 357 357 .desc = "Default memset() provided by glibc", 358 358 .fn.memset = memset }, ··· 369 369 int bench_mem_memset(int argc, const char **argv, const char *prefix __maybe_unused) 370 370 { 371 371 struct bench_mem_info info = { 372 - .routines = memset_routines, 372 + .functions = memset_functions, 373 373 .do_cycles = do_memset_cycles, 374 374 .do_gettimeofday = do_memset_gettimeofday, 375 375 .usage = bench_mem_memset_usage,