perf: fix core dump for "perf bench all"
PATCH 1/1 perf: fix core dump for "perf bench all"
When numa for perf bench is compiled will have core dump.
| #./perf bench numa all | # Running numa/mem benchmark... | | Segmentation fault (core dumped) | # ./perf bench all | # Running numa/mem benchmark... | | Segmentation fault (core dumped)
Fix it by adding own handler for numa bench. all_suite() will search and find handler call it first, if can not find it, will fallback the old way.
Also fix argv setting in that function, we should use [0] as argc is 1.
Signed-off-by Yinghai Lu <[email protected]>
--- tools/perf/bench/bench.h | 1 + tools/perf/bench/numa.c | 5 +++-- tools/perf/builtin-bench.c | 19 +++++++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-)
tools/perf/bench/bench.h +1 -0
@@ -26,6 +26,7 @@#endif extern int bench_numa (int argc,const char **argv,const char *prefix); +int bench_numa_all (int argc,const char **argv,const char *prefix);extern int bench_sched_messaging (int argc,const char **argv,const char *prefix);extern int bench_sched_pipe (int argc,const char **argv,const char *prefix); extern int bench_mem_memcpy(int argc, const char **argv,
tools/perf/bench/numa.c +3 -2
@@ -1691,7 +1691,8 @@ static const char *tests[][MAX_ARGS] = { "mem", "-p", "2", "-t", "16", "-T", "192", OPT_BW_NOTHP }, }; -static int bench_all(void) +int bench_numa_all(int argc __maybe_unused, const char **argv __maybe_unused, + const char *prefix __maybe_unused) {int nr =ARRAY_SIZE (tests);int ret;
@@ -1718,7 +1719,7 @@ int bench_numa(int argc, const char **ar goto err;if (p0.run_all) -return bench_all (); +return bench_numa_all (argc, argv, prefix);if (__bench_numa (NULL )) goto err;
tools/perf/builtin-bench.c +17 -2
@@ -40,7 +40,7 @@ static struct bench_suite numa_suites[] {"mem" ,"Benchmark for NUMA workloads" , bench_numa }, - suite_all, + { "all", "Test all benchmark suites", bench_numa_all }, { NULL,NULL , NULL }
@@ -166,6 +166,21 @@ static void all_suite(struct bench_subsystruct bench_suite *suites = subsys->suites; argv[1 ] =NULL ; + +/* own all handling ? */ +for (i =0 ; suites[i].fn; i++) { +if (!strcmp ("all" , suites[i].name)) { +printf ("# Running %s/%s benchmark...\n" , + subsys->name, + suites[i].name); +fflush (stdout); + + argv[0 ] = suites[i].name; + suites[i].fn (1 , argv,NULL ); +return ; + } + } +/* * TODO: * preparing preset parameters for
@@ -178,7 +193,7 @@ static void all_suite(struct bench_subsy suites[i].name);fflush (stdout); - argv[1 ] = suites[i].name; + argv[0 ] = suites[i].name; suites[i].fn (1 , argv,NULL );printf ("\n" ); }