forked from luck/tmp_suning_uos_patched
perf bench: Run inject-build-id with --buildid-all option too
For comparison, it now runs the benchmark twice - one if regular -b and another for --buildid-all. $ perf bench internals inject-build-id # Running 'internals/inject-build-id' benchmark: Average build-id injection took: 21.002 msec (+- 0.172 msec) Average time per event: 2.059 usec (+- 0.017 usec) Average memory usage: 8169 KB (+- 0 KB) Average build-id-all injection took: 19.543 msec (+- 0.124 msec) Average time per event: 1.916 usec (+- 0.012 usec) Average memory usage: 7348 KB (+- 0 KB) Signed-off-by: Namhyung Kim <namhyung@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Acked-by: Ian Rogers <irogers@google.com> Acked-by: Jiri Olsa <jolsa@redhat.com> Link: https://lore.kernel.org/r/20201012070214.2074921-7-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
27c9c3424f
commit
bf7ef5ddb0
|
@ -271,7 +271,7 @@ static void *data_reader(void *arg)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int setup_injection(struct bench_data *data)
|
static int setup_injection(struct bench_data *data, bool build_id_all)
|
||||||
{
|
{
|
||||||
int ready_pipe[2];
|
int ready_pipe[2];
|
||||||
int dev_null_fd;
|
int dev_null_fd;
|
||||||
|
@ -292,6 +292,7 @@ static int setup_injection(struct bench_data *data)
|
||||||
|
|
||||||
if (data->pid == 0) {
|
if (data->pid == 0) {
|
||||||
const char **inject_argv;
|
const char **inject_argv;
|
||||||
|
int inject_argc = 2;
|
||||||
|
|
||||||
close(data->input_pipe[1]);
|
close(data->input_pipe[1]);
|
||||||
close(data->output_pipe[0]);
|
close(data->output_pipe[0]);
|
||||||
|
@ -308,17 +309,22 @@ static int setup_injection(struct bench_data *data)
|
||||||
|
|
||||||
dup2(dev_null_fd, STDERR_FILENO);
|
dup2(dev_null_fd, STDERR_FILENO);
|
||||||
|
|
||||||
inject_argv = calloc(3, sizeof(*inject_argv));
|
if (build_id_all)
|
||||||
|
inject_argc++;
|
||||||
|
|
||||||
|
inject_argv = calloc(inject_argc + 1, sizeof(*inject_argv));
|
||||||
if (inject_argv == NULL)
|
if (inject_argv == NULL)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
inject_argv[0] = strdup("inject");
|
inject_argv[0] = strdup("inject");
|
||||||
inject_argv[1] = strdup("-b");
|
inject_argv[1] = strdup("-b");
|
||||||
|
if (build_id_all)
|
||||||
|
inject_argv[2] = strdup("--buildid-all");
|
||||||
|
|
||||||
/* signal that we're ready to go */
|
/* signal that we're ready to go */
|
||||||
close(ready_pipe[1]);
|
close(ready_pipe[1]);
|
||||||
|
|
||||||
cmd_inject(2, inject_argv);
|
cmd_inject(inject_argc, inject_argv);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
@ -377,27 +383,17 @@ static int inject_build_id(struct bench_data *data, u64 *max_rss)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_inject_loop(struct bench_data *data)
|
static void do_inject_loop(struct bench_data *data, bool build_id_all)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct stats time_stats, mem_stats;
|
struct stats time_stats, mem_stats;
|
||||||
double time_average, time_stddev;
|
double time_average, time_stddev;
|
||||||
double mem_average, mem_stddev;
|
double mem_average, mem_stddev;
|
||||||
|
|
||||||
srand(time(NULL));
|
|
||||||
init_stats(&time_stats);
|
init_stats(&time_stats);
|
||||||
init_stats(&mem_stats);
|
init_stats(&mem_stats);
|
||||||
symbol__init(NULL);
|
|
||||||
|
|
||||||
bench_sample_type = PERF_SAMPLE_IDENTIFIER | PERF_SAMPLE_IP;
|
pr_debug(" Build-id%s injection benchmark\n", build_id_all ? "-all" : "");
|
||||||
bench_sample_type |= PERF_SAMPLE_TID | PERF_SAMPLE_TIME;
|
|
||||||
bench_id_hdr_size = 32;
|
|
||||||
|
|
||||||
collect_dso();
|
|
||||||
if (nr_dsos == 0) {
|
|
||||||
printf(" Cannot collect DSOs for injection\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < iterations; i++) {
|
for (i = 0; i < iterations; i++) {
|
||||||
struct timeval start, end, diff;
|
struct timeval start, end, diff;
|
||||||
|
@ -405,7 +401,7 @@ static int do_inject_loop(struct bench_data *data)
|
||||||
|
|
||||||
pr_debug(" Iteration #%d\n", i+1);
|
pr_debug(" Iteration #%d\n", i+1);
|
||||||
|
|
||||||
if (setup_injection(data) < 0) {
|
if (setup_injection(data, build_id_all) < 0) {
|
||||||
printf(" Build-id injection setup failed\n");
|
printf(" Build-id injection setup failed\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -427,8 +423,8 @@ static int do_inject_loop(struct bench_data *data)
|
||||||
|
|
||||||
time_average = avg_stats(&time_stats) / USEC_PER_MSEC;
|
time_average = avg_stats(&time_stats) / USEC_PER_MSEC;
|
||||||
time_stddev = stddev_stats(&time_stats) / USEC_PER_MSEC;
|
time_stddev = stddev_stats(&time_stats) / USEC_PER_MSEC;
|
||||||
printf(" Average build-id injection took: %.3f msec (+- %.3f msec)\n",
|
printf(" Average build-id%s injection took: %.3f msec (+- %.3f msec)\n",
|
||||||
time_average, time_stddev);
|
build_id_all ? "-all" : "", time_average, time_stddev);
|
||||||
|
|
||||||
/* each iteration, it processes MMAP2 + BUILD_ID + nr_samples * SAMPLE */
|
/* each iteration, it processes MMAP2 + BUILD_ID + nr_samples * SAMPLE */
|
||||||
time_average = avg_stats(&time_stats) / (nr_mmaps * (nr_samples + 2));
|
time_average = avg_stats(&time_stats) / (nr_mmaps * (nr_samples + 2));
|
||||||
|
@ -440,6 +436,26 @@ static int do_inject_loop(struct bench_data *data)
|
||||||
mem_stddev = stddev_stats(&mem_stats);
|
mem_stddev = stddev_stats(&mem_stats);
|
||||||
printf(" Average memory usage: %.0f KB (+- %.0f KB)\n",
|
printf(" Average memory usage: %.0f KB (+- %.0f KB)\n",
|
||||||
mem_average, mem_stddev);
|
mem_average, mem_stddev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int do_inject_loops(struct bench_data *data)
|
||||||
|
{
|
||||||
|
|
||||||
|
srand(time(NULL));
|
||||||
|
symbol__init(NULL);
|
||||||
|
|
||||||
|
bench_sample_type = PERF_SAMPLE_IDENTIFIER | PERF_SAMPLE_IP;
|
||||||
|
bench_sample_type |= PERF_SAMPLE_TID | PERF_SAMPLE_TIME;
|
||||||
|
bench_id_hdr_size = 32;
|
||||||
|
|
||||||
|
collect_dso();
|
||||||
|
if (nr_dsos == 0) {
|
||||||
|
printf(" Cannot collect DSOs for injection\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
do_inject_loop(data, false);
|
||||||
|
do_inject_loop(data, true);
|
||||||
|
|
||||||
release_dso();
|
release_dso();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -455,6 +471,6 @@ int bench_inject_build_id(int argc, const char **argv)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return do_inject_loop(&data);
|
return do_inject_loops(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user