From cb4b9e6813f9243095932c867ff16a7dffa02102 Mon Sep 17 00:00:00 2001 From: Changbin Du Date: Thu, 2 Mar 2023 11:11:45 +0800 Subject: [PATCH] perf record: Reuse target::initial_delay This just simply replace record_opts::initial_delay with target::initial_delay. Nothing else is changed. Signed-off-by: Changbin Du Acked-by: Namhyung Kim Cc: Alexander Shishkin Cc: Hui Wang Cc: Ingo Molnar Cc: Jiri Olsa Cc: Mark Rutland Cc: Peter Zijlstra Link: https://lore.kernel.org/r/20230302031146.2801588-3-changbin.du@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-record.c | 12 ++++++------ tools/perf/builtin-trace.c | 8 ++++---- tools/perf/util/evlist.c | 6 +++--- tools/perf/util/evsel.c | 2 +- tools/perf/util/record.h | 1 - 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index be7c0c29d15b..fb8aab0cedd0 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1292,7 +1292,7 @@ static int record__open(struct record *rec) * dummy event so that we can track PERF_RECORD_MMAP to cover the delay * of waiting or event synthesis. */ - if (opts->initial_delay || target__has_cpu(&opts->target) || + if (opts->target.initial_delay || target__has_cpu(&opts->target) || perf_pmu__has_hybrid()) { pos = evlist__get_tracking_event(evlist); if (!evsel__is_dummy_event(pos)) { @@ -1307,7 +1307,7 @@ static int record__open(struct record *rec) * Enable the dummy event when the process is forked for * initial_delay, immediately for system wide. */ - if (opts->initial_delay && !pos->immediate && + if (opts->target.initial_delay && !pos->immediate && !target__has_cpu(&opts->target)) pos->core.attr.enable_on_exec = 1; else @@ -2522,7 +2522,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) * (apart from group members) have enable_on_exec=1 set, * so don't spoil it by prematurely enabling them. */ - if (!target__none(&opts->target) && !opts->initial_delay) + if (!target__none(&opts->target) && !opts->target.initial_delay) evlist__enable(rec->evlist); /* @@ -2574,10 +2574,10 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) evlist__start_workload(rec->evlist); } - if (opts->initial_delay) { + if (opts->target.initial_delay) { pr_info(EVLIST_DISABLED_MSG); - if (opts->initial_delay > 0) { - usleep(opts->initial_delay * USEC_PER_MSEC); + if (opts->target.initial_delay > 0) { + usleep(opts->target.initial_delay * USEC_PER_MSEC); evlist__enable(rec->evlist); pr_info(EVLIST_ENABLED_MSG); } diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 610fb60b1c0d..b363c609818b 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -3993,14 +3993,14 @@ static int trace__run(struct trace *trace, int argc, const char **argv) if (err < 0) goto out_error_mmap; - if (!target__none(&trace->opts.target) && !trace->opts.initial_delay) + if (!target__none(&trace->opts.target) && !trace->opts.target.initial_delay) evlist__enable(evlist); if (forks) evlist__start_workload(evlist); - if (trace->opts.initial_delay) { - usleep(trace->opts.initial_delay * 1000); + if (trace->opts.target.initial_delay) { + usleep(trace->opts.target.initial_delay * 1000); evlist__enable(evlist); } @@ -4788,7 +4788,7 @@ int cmd_trace(int argc, const char **argv) "per thread proc mmap processing timeout in ms"), OPT_CALLBACK('G', "cgroup", &trace, "name", "monitor event in cgroup name only", trace__parse_cgroups), - OPT_INTEGER('D', "delay", &trace.opts.initial_delay, + OPT_INTEGER('D', "delay", &trace.opts.target.initial_delay, "ms to wait before starting measurement after program " "start"), OPTS_EVSWITCH(&trace.evswitch), diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 817df2504a1e..9e4b2bb0e6fa 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -2262,8 +2262,8 @@ int evlist__parse_event_enable_time(struct evlist *evlist, struct record_opts *o if (unset) return 0; - opts->initial_delay = str_to_delay(str); - if (opts->initial_delay) + opts->target.initial_delay = str_to_delay(str); + if (opts->target.initial_delay) return 0; ret = parse_event_enable_times(str, NULL); @@ -2306,7 +2306,7 @@ int evlist__parse_event_enable_time(struct evlist *evlist, struct record_opts *o eet->evlist = evlist; evlist->eet = eet; - opts->initial_delay = eet->times[0].start; + opts->target.initial_delay = eet->times[0].start; return 0; diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 51e8ce6edddc..462cc0673cee 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1334,7 +1334,7 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts, * group leaders for traced executed by perf. */ if (target__none(&opts->target) && evsel__is_group_leader(evsel) && - !opts->initial_delay) + !opts->target.initial_delay) attr->enable_on_exec = 1; if (evsel->immediate) { diff --git a/tools/perf/util/record.h b/tools/perf/util/record.h index 46212bf020cf..a6566134e09e 100644 --- a/tools/perf/util/record.h +++ b/tools/perf/util/record.h @@ -65,7 +65,6 @@ struct record_opts { const char *auxtrace_snapshot_opts; const char *auxtrace_sample_opts; bool sample_transaction; - int initial_delay; bool use_clockid; clockid_t clockid; u64 clockid_res_ns;