Commit 26b7254f authored by Yang Jihong's avatar Yang Jihong Committed by Arnaldo Carvalho de Melo

perf kwork: Set default events list if not specified in setup_event_list()

Currently when no kwork event is specified, all events are configured by
default. Now set to default event list string, which is more flexible and
supports subsequent function extension.

Also put setup_event_list() into each subcommand for different settings.
Reviewed-by: default avatarIan Rogers <irogers@google.com>
Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Sandipan Das <sandipan.das@amd.com>
Link: https://lore.kernel.org/r/20230812084917.169338-7-yangjihong1@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 86c67c8a
......@@ -1623,8 +1623,11 @@ static void setup_event_list(struct perf_kwork *kwork,
struct kwork_class *class;
char *tmp, *tok, *str;
/*
* set default events list if not specified
*/
if (kwork->event_list_str == NULL)
goto null_event_list_str;
kwork->event_list_str = "irq, softirq, workqueue";
str = strdup(kwork->event_list_str);
for (tok = strtok_r(str, ", ", &tmp);
......@@ -1643,17 +1646,6 @@ static void setup_event_list(struct perf_kwork *kwork,
}
free(str);
null_event_list_str:
/*
* config all kwork events if not specified
*/
if (list_empty(&kwork->class_list)) {
for (i = 0; i < KWORK_CLASS_MAX; i++) {
list_add_tail(&kwork_class_supported_list[i]->list,
&kwork->class_list);
}
}
pr_debug("Config event list:");
list_for_each_entry(class, &kwork->class_list, list)
pr_debug(" %s", class->name);
......@@ -1835,12 +1827,12 @@ int cmd_kwork(int argc, const char **argv)
if (!argc)
usage_with_options(kwork_usage, kwork_options);
setup_event_list(&kwork, kwork_options, kwork_usage);
sort_dimension__add(&kwork, "id", &kwork.cmp_id);
if (strlen(argv[0]) > 2 && strstarts("record", argv[0]))
if (strlen(argv[0]) > 2 && strstarts("record", argv[0])) {
setup_event_list(&kwork, kwork_options, kwork_usage);
return perf_kwork__record(&kwork, argc, argv);
else if (strlen(argv[0]) > 2 && strstarts("report", argv[0])) {
} else if (strlen(argv[0]) > 2 && strstarts("report", argv[0])) {
kwork.sort_order = default_report_sort_order;
if (argc > 1) {
argc = parse_options(argc, argv, report_options, report_usage, 0);
......@@ -1849,6 +1841,7 @@ int cmd_kwork(int argc, const char **argv)
}
kwork.report = KWORK_REPORT_RUNTIME;
setup_sorting(&kwork, report_options, report_usage);
setup_event_list(&kwork, kwork_options, kwork_usage);
return perf_kwork__report(&kwork);
} else if (strlen(argv[0]) > 2 && strstarts("latency", argv[0])) {
kwork.sort_order = default_latency_sort_order;
......@@ -1859,6 +1852,7 @@ int cmd_kwork(int argc, const char **argv)
}
kwork.report = KWORK_REPORT_LATENCY;
setup_sorting(&kwork, latency_options, latency_usage);
setup_event_list(&kwork, kwork_options, kwork_usage);
return perf_kwork__report(&kwork);
} else if (strlen(argv[0]) > 2 && strstarts("timehist", argv[0])) {
if (argc > 1) {
......@@ -1867,6 +1861,7 @@ int cmd_kwork(int argc, const char **argv)
usage_with_options(timehist_usage, timehist_options);
}
kwork.report = KWORK_REPORT_TIMEHIST;
setup_event_list(&kwork, kwork_options, kwork_usage);
return perf_kwork__timehist(&kwork);
} else
usage_with_options(kwork_usage, kwork_options);
......
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