[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250616052223.723982-9-ankur.a.arora@oracle.com>
Date: Sun, 15 Jun 2025 22:22:18 -0700
From: Ankur Arora <ankur.a.arora@...cle.com>
To: linux-kernel@...r.kernel.org, linux-mm@...ck.org, x86@...nel.org
Cc: akpm@...ux-foundation.org, bp@...en8.de, dave.hansen@...ux.intel.com,
hpa@...or.com, mingo@...hat.com, mjguzik@...il.com, luto@...nel.org,
peterz@...radead.org, acme@...nel.org, namhyung@...nel.org,
tglx@...utronix.de, willy@...radead.org, jon.grimm@....com,
bharata@....com, raghavendra.kt@....com, boris.ostrovsky@...cle.com,
konrad.wilk@...cle.com, ankur.a.arora@...cle.com
Subject: [PATCH v4 08/13] perf bench mem: Refactor mem_options
Split mem benchmark options into common and memset/memcpy specific.
Signed-off-by: Ankur Arora <ankur.a.arora@...cle.com>
---
tools/perf/bench/mem-functions.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/tools/perf/bench/mem-functions.c b/tools/perf/bench/mem-functions.c
index 412d18f2cb2e..8a37da149327 100644
--- a/tools/perf/bench/mem-functions.c
+++ b/tools/perf/bench/mem-functions.c
@@ -41,7 +41,7 @@ static unsigned int nr_loops = 1;
static bool use_cycles;
static int cycles_fd;
-static const struct option options[] = {
+static const struct option bench_common_options[] = {
OPT_STRING('s', "size", &size_str, "1MB",
"Specify the size of the memory buffers. "
"Available units: B, KB, MB, GB and TB (case insensitive)"),
@@ -50,10 +50,6 @@ static const struct option options[] = {
"Specify page-size for mapping memory buffers. "
"Available sizes: 4KB, 2MB, 1GB (case insensitive)"),
- OPT_STRING('k', "chunk", &chunk_size_str, "0",
- "Specify the chunk-size for each invocation. "
- "Available units: B, KB, MB, GB and TB (case insensitive)"),
-
OPT_STRING('f', "function", &function_str, "all",
"Specify the function to run, \"all\" runs all available functions, \"help\" lists them"),
@@ -66,6 +62,14 @@ static const struct option options[] = {
OPT_END()
};
+static const struct option bench_mem_options[] = {
+ OPT_STRING('k', "chunk", &chunk_size_str, "0",
+ "Specify the chunk-size for each invocation. "
+ "Available units: B, KB, MB, GB and TB (case insensitive)"),
+ OPT_PARENT(bench_common_options),
+ OPT_END()
+};
+
union bench_clock {
u64 cycles;
struct timeval tv;
@@ -84,6 +88,7 @@ struct bench_mem_info {
int (*do_op)(const struct function *r, struct bench_params *p,
void *src, void *dst, union bench_clock *rt);
const char *const *usage;
+ const struct option *options;
bool alloc_src;
};
@@ -230,7 +235,7 @@ static int bench_mem_common(int argc, const char **argv, struct bench_mem_info *
struct bench_params p = { 0 };
unsigned int page_size;
- argc = parse_options(argc, argv, options, info->usage, 0);
+ argc = parse_options(argc, argv, info->options, info->usage, 0);
if (use_cycles) {
i = init_cycles();
@@ -396,6 +401,7 @@ int bench_mem_memcpy(int argc, const char **argv)
.functions = memcpy_functions,
.do_op = do_memcpy,
.usage = bench_mem_memcpy_usage,
+ .options = bench_mem_options,
.alloc_src = true,
};
@@ -453,6 +459,7 @@ int bench_mem_memset(int argc, const char **argv)
.functions = memset_functions,
.do_op = do_memset,
.usage = bench_mem_memset_usage,
+ .options = bench_mem_options,
};
return bench_mem_common(argc, argv, &info);
--
2.31.1
Powered by blists - more mailing lists