perf evlist: Use the right prefix for 'struct evlist' 'workload' methods

perf_evlist__ is for 'struct perf_evlist' methods, in tools/lib/perf/,
go on completing this split.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent a622eafa
...@@ -67,7 +67,7 @@ static void sig_handler(int sig __maybe_unused) ...@@ -67,7 +67,7 @@ static void sig_handler(int sig __maybe_unused)
} }
/* /*
* perf_evlist__prepare_workload will send a SIGUSR1 if the fork fails, since * evlist__prepare_workload will send a SIGUSR1 if the fork fails, since
* we asked by setting its exec_error to the function below, * we asked by setting its exec_error to the function below,
* ftrace__workload_exec_failed_signal. * ftrace__workload_exec_failed_signal.
* *
...@@ -600,9 +600,8 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) ...@@ -600,9 +600,8 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
if (write_tracing_file("trace", "0") < 0) if (write_tracing_file("trace", "0") < 0)
goto out; goto out;
if (argc && perf_evlist__prepare_workload(ftrace->evlist, if (argc && evlist__prepare_workload(ftrace->evlist, &ftrace->target, argv, false,
&ftrace->target, argv, false, ftrace__workload_exec_failed_signal) < 0) {
ftrace__workload_exec_failed_signal) < 0) {
goto out; goto out;
} }
...@@ -644,7 +643,7 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) ...@@ -644,7 +643,7 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
} }
} }
perf_evlist__start_workload(ftrace->evlist); evlist__start_workload(ftrace->evlist);
if (ftrace->initial_delay) { if (ftrace->initial_delay) {
usleep(ftrace->initial_delay * 1000); usleep(ftrace->initial_delay * 1000);
......
...@@ -1333,7 +1333,7 @@ record__switch_output(struct record *rec, bool at_exit) ...@@ -1333,7 +1333,7 @@ record__switch_output(struct record *rec, bool at_exit)
static volatile int workload_exec_errno; static volatile int workload_exec_errno;
/* /*
* perf_evlist__prepare_workload will send a SIGUSR1 * evlist__prepare_workload will send a SIGUSR1
* if the fork fails, since we asked by setting its * if the fork fails, since we asked by setting its
* want_signal to true. * want_signal to true.
*/ */
...@@ -1689,9 +1689,8 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) ...@@ -1689,9 +1689,8 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
record__init_features(rec); record__init_features(rec);
if (forks) { if (forks) {
err = perf_evlist__prepare_workload(rec->evlist, &opts->target, err = evlist__prepare_workload(rec->evlist, &opts->target, argv, data->is_pipe,
argv, data->is_pipe, workload_exec_failed_signal);
workload_exec_failed_signal);
if (err < 0) { if (err < 0) {
pr_err("Couldn't run the workload!\n"); pr_err("Couldn't run the workload!\n");
status = err; status = err;
...@@ -1835,7 +1834,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) ...@@ -1835,7 +1834,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
machine); machine);
free(event); free(event);
perf_evlist__start_workload(rec->evlist); evlist__start_workload(rec->evlist);
} }
if (evlist__initialize_ctlfd(rec->evlist, opts->ctl_fd, opts->ctl_fd_ack)) if (evlist__initialize_ctlfd(rec->evlist, opts->ctl_fd, opts->ctl_fd_ack))
...@@ -2413,7 +2412,7 @@ static bool dry_run; ...@@ -2413,7 +2412,7 @@ static bool dry_run;
* XXX Will stay a global variable till we fix builtin-script.c to stop messing * XXX Will stay a global variable till we fix builtin-script.c to stop messing
* with it and switch to use the library functions in perf_evlist that came * with it and switch to use the library functions in perf_evlist that came
* from builtin-record.c, i.e. use record_opts, * from builtin-record.c, i.e. use record_opts,
* perf_evlist__prepare_workload, etc instead of fork+exec'in 'perf record', * evlist__prepare_workload, etc instead of fork+exec'in 'perf record',
* using pipes, etc. * using pipes, etc.
*/ */
static struct option __record_options[] = { static struct option __record_options[] = {
......
...@@ -534,7 +534,7 @@ static void disable_counters(void) ...@@ -534,7 +534,7 @@ static void disable_counters(void)
static volatile int workload_exec_errno; static volatile int workload_exec_errno;
/* /*
* perf_evlist__prepare_workload will send a SIGUSR1 * evlist__prepare_workload will send a SIGUSR1
* if the fork fails, since we asked by setting its * if the fork fails, since we asked by setting its
* want_signal to true. * want_signal to true.
*/ */
...@@ -724,8 +724,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) ...@@ -724,8 +724,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
bool second_pass = false; bool second_pass = false;
if (forks) { if (forks) {
if (perf_evlist__prepare_workload(evsel_list, &target, argv, is_pipe, if (evlist__prepare_workload(evsel_list, &target, argv, is_pipe, workload_exec_failed_signal) < 0) {
workload_exec_failed_signal) < 0) {
perror("failed to prepare workload"); perror("failed to prepare workload");
return -1; return -1;
} }
...@@ -876,7 +875,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) ...@@ -876,7 +875,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
clock_gettime(CLOCK_MONOTONIC, &ref_time); clock_gettime(CLOCK_MONOTONIC, &ref_time);
if (forks) { if (forks) {
perf_evlist__start_workload(evsel_list); evlist__start_workload(evsel_list);
enable_counters(); enable_counters();
if (interval || timeout || evlist__ctlfd_initialized(evsel_list)) if (interval || timeout || evlist__ctlfd_initialized(evsel_list))
......
...@@ -3680,7 +3680,7 @@ static int trace__set_filter_pids(struct trace *trace) ...@@ -3680,7 +3680,7 @@ static int trace__set_filter_pids(struct trace *trace)
* Better not use !target__has_task() here because we need to cover the * Better not use !target__has_task() here because we need to cover the
* case where no threads were specified in the command line, but a * case where no threads were specified in the command line, but a
* workload was, and in that case we will fill in the thread_map when * workload was, and in that case we will fill in the thread_map when
* we fork the workload in perf_evlist__prepare_workload. * we fork the workload in evlist__prepare_workload.
*/ */
if (trace->filter_pids.nr > 0) { if (trace->filter_pids.nr > 0) {
err = perf_evlist__append_tp_filter_pids(trace->evlist, trace->filter_pids.nr, err = perf_evlist__append_tp_filter_pids(trace->evlist, trace->filter_pids.nr,
...@@ -3969,8 +3969,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv) ...@@ -3969,8 +3969,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
if (forks) { if (forks) {
err = perf_evlist__prepare_workload(evlist, &trace->opts.target, err = evlist__prepare_workload(evlist, &trace->opts.target, argv, false, NULL);
argv, false, NULL);
if (err < 0) { if (err < 0) {
fprintf(trace->output, "Couldn't run the workload!\n"); fprintf(trace->output, "Couldn't run the workload!\n");
goto out_delete_evlist; goto out_delete_evlist;
...@@ -4043,7 +4042,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv) ...@@ -4043,7 +4042,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
evlist__enable(evlist); evlist__enable(evlist);
if (forks) if (forks)
perf_evlist__start_workload(evlist); evlist__start_workload(evlist);
if (trace->opts.initial_delay) { if (trace->opts.initial_delay) {
usleep(trace->opts.initial_delay * 1000); usleep(trace->opts.initial_delay * 1000);
......
...@@ -32,7 +32,7 @@ static int attach__enable_on_exec(struct evlist *evlist) ...@@ -32,7 +32,7 @@ static int attach__enable_on_exec(struct evlist *evlist)
return err; return err;
} }
err = perf_evlist__prepare_workload(evlist, &target, argv, false, NULL); err = evlist__prepare_workload(evlist, &target, argv, false, NULL);
if (err < 0) { if (err < 0) {
pr_debug("Couldn't run the workload!\n"); pr_debug("Couldn't run the workload!\n");
return err; return err;
...@@ -47,7 +47,7 @@ static int attach__enable_on_exec(struct evlist *evlist) ...@@ -47,7 +47,7 @@ static int attach__enable_on_exec(struct evlist *evlist)
return err; return err;
} }
return perf_evlist__start_workload(evlist) == 1 ? TEST_OK : TEST_FAIL; return evlist__start_workload(evlist) == 1 ? TEST_OK : TEST_FAIL;
} }
static int detach__enable_on_exec(struct evlist *evlist) static int detach__enable_on_exec(struct evlist *evlist)
......
...@@ -81,7 +81,7 @@ int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unus ...@@ -81,7 +81,7 @@ int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unus
/* /*
* Create maps of threads and cpus to monitor. In this case * Create maps of threads and cpus to monitor. In this case
* we start with all threads and cpus (-1, -1) but then in * we start with all threads and cpus (-1, -1) but then in
* perf_evlist__prepare_workload we'll fill in the only thread * evlist__prepare_workload we'll fill in the only thread
* we're monitoring, the one forked there. * we're monitoring, the one forked there.
*/ */
err = perf_evlist__create_maps(evlist, &opts.target); err = perf_evlist__create_maps(evlist, &opts.target);
...@@ -92,11 +92,11 @@ int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unus ...@@ -92,11 +92,11 @@ int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unus
/* /*
* Prepare the workload in argv[] to run, it'll fork it, and then wait * Prepare the workload in argv[] to run, it'll fork it, and then wait
* for perf_evlist__start_workload() to exec it. This is done this way * for evlist__start_workload() to exec it. This is done this way
* so that we have time to open the evlist (calling sys_perf_event_open * so that we have time to open the evlist (calling sys_perf_event_open
* on all the fds) and then mmap them. * on all the fds) and then mmap them.
*/ */
err = perf_evlist__prepare_workload(evlist, &opts.target, argv, false, NULL); err = evlist__prepare_workload(evlist, &opts.target, argv, false, NULL);
if (err < 0) { if (err < 0) {
pr_debug("Couldn't run the workload!\n"); pr_debug("Couldn't run the workload!\n");
goto out_delete_evlist; goto out_delete_evlist;
...@@ -161,7 +161,7 @@ int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unus ...@@ -161,7 +161,7 @@ int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unus
/* /*
* Now! * Now!
*/ */
perf_evlist__start_workload(evlist); evlist__start_workload(evlist);
while (1) { while (1) {
int before = total_events; int before = total_events;
......
...@@ -23,7 +23,7 @@ static void sig_handler(int sig __maybe_unused) ...@@ -23,7 +23,7 @@ static void sig_handler(int sig __maybe_unused)
} }
/* /*
* perf_evlist__prepare_workload will send a SIGUSR1 if the fork fails, since * evlist__prepare_workload will send a SIGUSR1 if the fork fails, since
* we asked by setting its exec_error to this handler. * we asked by setting its exec_error to this handler.
*/ */
static void workload_exec_failed_signal(int signo __maybe_unused, static void workload_exec_failed_signal(int signo __maybe_unused,
...@@ -67,7 +67,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused ...@@ -67,7 +67,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
/* /*
* Create maps of threads and cpus to monitor. In this case * Create maps of threads and cpus to monitor. In this case
* we start with all threads and cpus (-1, -1) but then in * we start with all threads and cpus (-1, -1) but then in
* perf_evlist__prepare_workload we'll fill in the only thread * evlist__prepare_workload we'll fill in the only thread
* we're monitoring, the one forked there. * we're monitoring, the one forked there.
*/ */
cpus = perf_cpu_map__dummy_new(); cpus = perf_cpu_map__dummy_new();
...@@ -83,8 +83,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused ...@@ -83,8 +83,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
cpus = NULL; cpus = NULL;
threads = NULL; threads = NULL;
err = perf_evlist__prepare_workload(evlist, &target, argv, false, err = evlist__prepare_workload(evlist, &target, argv, false, workload_exec_failed_signal);
workload_exec_failed_signal);
if (err < 0) { if (err < 0) {
pr_debug("Couldn't run the workload!\n"); pr_debug("Couldn't run the workload!\n");
goto out_delete_evlist; goto out_delete_evlist;
...@@ -116,7 +115,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused ...@@ -116,7 +115,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
goto out_delete_evlist; goto out_delete_evlist;
} }
perf_evlist__start_workload(evlist); evlist__start_workload(evlist);
retry: retry:
md = &evlist->mmap[0]; md = &evlist->mmap[0];
......
...@@ -1315,9 +1315,8 @@ int evlist__open(struct evlist *evlist) ...@@ -1315,9 +1315,8 @@ int evlist__open(struct evlist *evlist)
return err; return err;
} }
int perf_evlist__prepare_workload(struct evlist *evlist, struct target *target, int evlist__prepare_workload(struct evlist *evlist, struct target *target, const char *argv[],
const char *argv[], bool pipe_output, bool pipe_output, void (*exec_error)(int signo, siginfo_t *info, void *ucontext))
void (*exec_error)(int signo, siginfo_t *info, void *ucontext))
{ {
int child_ready_pipe[2], go_pipe[2]; int child_ready_pipe[2], go_pipe[2];
char bf; char bf;
...@@ -1362,7 +1361,7 @@ int perf_evlist__prepare_workload(struct evlist *evlist, struct target *target, ...@@ -1362,7 +1361,7 @@ int perf_evlist__prepare_workload(struct evlist *evlist, struct target *target,
/* /*
* The parent will ask for the execvp() to be performed by * The parent will ask for the execvp() to be performed by
* writing exactly one byte, in workload.cork_fd, usually via * writing exactly one byte, in workload.cork_fd, usually via
* perf_evlist__start_workload(). * evlist__start_workload().
* *
* For cancelling the workload without actually running it, * For cancelling the workload without actually running it,
* the parent will just close workload.cork_fd, without writing * the parent will just close workload.cork_fd, without writing
...@@ -1429,7 +1428,7 @@ int perf_evlist__prepare_workload(struct evlist *evlist, struct target *target, ...@@ -1429,7 +1428,7 @@ int perf_evlist__prepare_workload(struct evlist *evlist, struct target *target,
return -1; return -1;
} }
int perf_evlist__start_workload(struct evlist *evlist) int evlist__start_workload(struct evlist *evlist)
{ {
if (evlist->workload.cork_fd > 0) { if (evlist->workload.cork_fd > 0) {
char bf = 0; char bf = 0;
......
...@@ -182,12 +182,10 @@ void perf_evlist__config(struct evlist *evlist, struct record_opts *opts, ...@@ -182,12 +182,10 @@ void perf_evlist__config(struct evlist *evlist, struct record_opts *opts,
struct callchain_param *callchain); struct callchain_param *callchain);
int record_opts__config(struct record_opts *opts); int record_opts__config(struct record_opts *opts);
int perf_evlist__prepare_workload(struct evlist *evlist, int evlist__prepare_workload(struct evlist *evlist, struct target *target,
struct target *target, const char *argv[], bool pipe_output,
const char *argv[], bool pipe_output, void (*exec_error)(int signo, siginfo_t *info, void *ucontext));
void (*exec_error)(int signo, siginfo_t *info, int evlist__start_workload(struct evlist *evlist);
void *ucontext));
int perf_evlist__start_workload(struct evlist *evlist);
struct option; struct option;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment