Skip to content

Commit c3047f9

Browse files
terminusacmel
authored andcommitted
perf bench mem: Refactor mem_options
Split mem benchmark options into common and memset/memcpy specific. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: David Hildenbrand <david@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Mateusz Guzik <mjguzik@gmail.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Raghavendra K T <raghavendra.kt@amd.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent fd1d882 commit c3047f9

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

tools/perf/bench/mem-functions.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static unsigned int nr_loops = 1;
4141
static bool use_cycles;
4242
static int cycles_fd;
4343

44-
static const struct option options[] = {
44+
static const struct option bench_common_options[] = {
4545
OPT_STRING('s', "size", &size_str, "1MB",
4646
"Specify the size of the memory buffers. "
4747
"Available units: B, KB, MB, GB and TB (case insensitive)"),
@@ -50,10 +50,6 @@ static const struct option options[] = {
5050
"Specify page-size for mapping memory buffers. "
5151
"Available sizes: 4KB, 2MB, 1GB (case insensitive)"),
5252

53-
OPT_STRING('k', "chunk", &chunk_size_str, "0",
54-
"Specify the chunk-size for each invocation. "
55-
"Available units: B, KB, MB, GB and TB (case insensitive)"),
56-
5753
OPT_STRING('f', "function", &function_str, "all",
5854
"Specify the function to run, \"all\" runs all available functions, \"help\" lists them"),
5955

@@ -66,6 +62,14 @@ static const struct option options[] = {
6662
OPT_END()
6763
};
6864

65+
static const struct option bench_mem_options[] = {
66+
OPT_STRING('k', "chunk", &chunk_size_str, "0",
67+
"Specify the chunk-size for each invocation. "
68+
"Available units: B, KB, MB, GB and TB (case insensitive)"),
69+
OPT_PARENT(bench_common_options),
70+
OPT_END()
71+
};
72+
6973
union bench_clock {
7074
u64 cycles;
7175
struct timeval tv;
@@ -84,6 +88,7 @@ struct bench_mem_info {
8488
int (*do_op)(const struct function *r, struct bench_params *p,
8589
void *src, void *dst, union bench_clock *rt);
8690
const char *const *usage;
91+
const struct option *options;
8792
bool alloc_src;
8893
};
8994

@@ -230,7 +235,7 @@ static int bench_mem_common(int argc, const char **argv, struct bench_mem_info *
230235
struct bench_params p = { 0 };
231236
unsigned int page_size;
232237

233-
argc = parse_options(argc, argv, options, info->usage, 0);
238+
argc = parse_options(argc, argv, info->options, info->usage, 0);
234239

235240
if (use_cycles) {
236241
i = init_cycles();
@@ -397,6 +402,7 @@ int bench_mem_memcpy(int argc, const char **argv)
397402
.functions = memcpy_functions,
398403
.do_op = do_memcpy,
399404
.usage = bench_mem_memcpy_usage,
405+
.options = bench_mem_options,
400406
.alloc_src = true,
401407
};
402408

@@ -454,6 +460,7 @@ int bench_mem_memset(int argc, const char **argv)
454460
.functions = memset_functions,
455461
.do_op = do_memset,
456462
.usage = bench_mem_memset_usage,
463+
.options = bench_mem_options,
457464
};
458465

459466
return bench_mem_common(argc, argv, &info);

0 commit comments

Comments
 (0)