aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2013-11-12 14:46:16 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-11-12 14:51:03 -0500
commit602ad878d41ef097cc9aa2def7830d5bb27a15d8 (patch)
tree6383b40cf015a1fd74a51c4cbfadd8756cde8dee /tools
parent48095b721ca54ffa70427185c00473530f4aef06 (diff)
perf target: Shorten perf_target__ to target__
Getting unwieldly long, for this app domain should be descriptive enough and the use of __ to separate the class from the method names should help with avoiding clashes with other code bases. Reported-by: David Ahern <dsahern@gmail.com> Suggested-by: Ingo Molnar <mingo@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/20131112113427.GA4053@ghostprotocols.net Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-kvm.c6
-rw-r--r--tools/perf/builtin-record.c14
-rw-r--r--tools/perf/builtin-stat.c21
-rw-r--r--tools/perf/builtin-top.c14
-rw-r--r--tools/perf/builtin-trace.c10
-rw-r--r--tools/perf/perf.h2
-rw-r--r--tools/perf/tests/task-exit.c2
-rw-r--r--tools/perf/util/evlist.c12
-rw-r--r--tools/perf/util/evlist.h5
-rw-r--r--tools/perf/util/evsel.c9
-rw-r--r--tools/perf/util/evsel.h3
-rw-r--r--tools/perf/util/machine.c6
-rw-r--r--tools/perf/util/machine.h4
-rw-r--r--tools/perf/util/target.c54
-rw-r--r--tools/perf/util/target.h44
-rw-r--r--tools/perf/util/top.c2
16 files changed, 99 insertions, 109 deletions
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 346bb5909e3d..f8bf5f244d77 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1510,13 +1510,13 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
1510 /* 1510 /*
1511 * target related setups 1511 * target related setups
1512 */ 1512 */
1513 err = perf_target__validate(&kvm->opts.target); 1513 err = target__validate(&kvm->opts.target);
1514 if (err) { 1514 if (err) {
1515 perf_target__strerror(&kvm->opts.target, err, errbuf, BUFSIZ); 1515 target__strerror(&kvm->opts.target, err, errbuf, BUFSIZ);
1516 ui__warning("%s", errbuf); 1516 ui__warning("%s", errbuf);
1517 } 1517 }
1518 1518
1519 if (perf_target__none(&kvm->opts.target)) 1519 if (target__none(&kvm->opts.target))
1520 kvm->opts.target.system_wide = true; 1520 kvm->opts.target.system_wide = true;
1521 1521
1522 1522
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 880227eae20f..4d644fe2d5b7 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -506,7 +506,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
506 * (apart from group members) have enable_on_exec=1 set, 506 * (apart from group members) have enable_on_exec=1 set,
507 * so don't spoil it by prematurely enabling them. 507 * so don't spoil it by prematurely enabling them.
508 */ 508 */
509 if (!perf_target__none(&opts->target)) 509 if (!target__none(&opts->target))
510 perf_evlist__enable(evsel_list); 510 perf_evlist__enable(evsel_list);
511 511
512 /* 512 /*
@@ -535,7 +535,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
535 * die with the process and we wait for that. Thus no need to 535 * die with the process and we wait for that. Thus no need to
536 * disable events in this case. 536 * disable events in this case.
537 */ 537 */
538 if (done && !disabled && !perf_target__none(&opts->target)) { 538 if (done && !disabled && !target__none(&opts->target)) {
539 perf_evlist__disable(evsel_list); 539 perf_evlist__disable(evsel_list);
540 disabled = true; 540 disabled = true;
541 } 541 }
@@ -906,7 +906,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
906 906
907 argc = parse_options(argc, argv, record_options, record_usage, 907 argc = parse_options(argc, argv, record_options, record_usage,
908 PARSE_OPT_STOP_AT_NON_OPTION); 908 PARSE_OPT_STOP_AT_NON_OPTION);
909 if (!argc && perf_target__none(&rec->opts.target)) 909 if (!argc && target__none(&rec->opts.target))
910 usage_with_options(record_usage, record_options); 910 usage_with_options(record_usage, record_options);
911 911
912 if (nr_cgroups && !rec->opts.target.system_wide) { 912 if (nr_cgroups && !rec->opts.target.system_wide) {
@@ -936,17 +936,17 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
936 goto out_symbol_exit; 936 goto out_symbol_exit;
937 } 937 }
938 938
939 err = perf_target__validate(&rec->opts.target); 939 err = target__validate(&rec->opts.target);
940 if (err) { 940 if (err) {
941 perf_target__strerror(&rec->opts.target, err, errbuf, BUFSIZ); 941 target__strerror(&rec->opts.target, err, errbuf, BUFSIZ);
942 ui__warning("%s", errbuf); 942 ui__warning("%s", errbuf);
943 } 943 }
944 944
945 err = perf_target__parse_uid(&rec->opts.target); 945 err = target__parse_uid(&rec->opts.target);
946 if (err) { 946 if (err) {
947 int saved_errno = errno; 947 int saved_errno = errno;
948 948
949 perf_target__strerror(&rec->opts.target, err, errbuf, BUFSIZ); 949 target__strerror(&rec->opts.target, err, errbuf, BUFSIZ);
950 ui__error("%s", errbuf); 950 ui__error("%s", errbuf);
951 951
952 err = -saved_errno; 952 err = -saved_errno;
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 0fc1c941a73c..ee0d565f83e3 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -108,7 +108,7 @@ enum {
108 108
109static struct perf_evlist *evsel_list; 109static struct perf_evlist *evsel_list;
110 110
111static struct perf_target target = { 111static struct target target = {
112 .uid = UINT_MAX, 112 .uid = UINT_MAX,
113}; 113};
114 114
@@ -294,11 +294,10 @@ static int create_perf_stat_counter(struct perf_evsel *evsel)
294 294
295 attr->inherit = !no_inherit; 295 attr->inherit = !no_inherit;
296 296
297 if (perf_target__has_cpu(&target)) 297 if (target__has_cpu(&target))
298 return perf_evsel__open_per_cpu(evsel, perf_evsel__cpus(evsel)); 298 return perf_evsel__open_per_cpu(evsel, perf_evsel__cpus(evsel));
299 299
300 if (!perf_target__has_task(&target) && 300 if (!target__has_task(&target) && perf_evsel__is_group_leader(evsel)) {
301 perf_evsel__is_group_leader(evsel)) {
302 attr->disabled = 1; 301 attr->disabled = 1;
303 if (!initial_delay) 302 if (!initial_delay)
304 attr->enable_on_exec = 1; 303 attr->enable_on_exec = 1;
@@ -1236,7 +1235,7 @@ static void print_stat(int argc, const char **argv)
1236 fprintf(output, "\'system wide"); 1235 fprintf(output, "\'system wide");
1237 else if (target.cpu_list) 1236 else if (target.cpu_list)
1238 fprintf(output, "\'CPU(s) %s", target.cpu_list); 1237 fprintf(output, "\'CPU(s) %s", target.cpu_list);
1239 else if (!perf_target__has_task(&target)) { 1238 else if (!target__has_task(&target)) {
1240 fprintf(output, "\'%s", argv[0]); 1239 fprintf(output, "\'%s", argv[0]);
1241 for (i = 1; i < argc; i++) 1240 for (i = 1; i < argc; i++)
1242 fprintf(output, " %s", argv[i]); 1241 fprintf(output, " %s", argv[i]);
@@ -1667,7 +1666,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
1667 } else if (big_num_opt == 0) /* User passed --no-big-num */ 1666 } else if (big_num_opt == 0) /* User passed --no-big-num */
1668 big_num = false; 1667 big_num = false;
1669 1668
1670 if (!argc && perf_target__none(&target)) 1669 if (!argc && target__none(&target))
1671 usage_with_options(stat_usage, options); 1670 usage_with_options(stat_usage, options);
1672 1671
1673 if (run_count < 0) { 1672 if (run_count < 0) {
@@ -1680,8 +1679,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
1680 } 1679 }
1681 1680
1682 /* no_aggr, cgroup are for system-wide only */ 1681 /* no_aggr, cgroup are for system-wide only */
1683 if ((aggr_mode != AGGR_GLOBAL || nr_cgroups) 1682 if ((aggr_mode != AGGR_GLOBAL || nr_cgroups) &&
1684 && !perf_target__has_cpu(&target)) { 1683 !target__has_cpu(&target)) {
1685 fprintf(stderr, "both cgroup and no-aggregation " 1684 fprintf(stderr, "both cgroup and no-aggregation "
1686 "modes only available in system-wide mode\n"); 1685 "modes only available in system-wide mode\n");
1687 1686
@@ -1694,14 +1693,14 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
1694 if (add_default_attributes()) 1693 if (add_default_attributes())
1695 goto out; 1694 goto out;
1696 1695
1697 perf_target__validate(&target); 1696 target__validate(&target);
1698 1697
1699 if (perf_evlist__create_maps(evsel_list, &target) < 0) { 1698 if (perf_evlist__create_maps(evsel_list, &target) < 0) {
1700 if (perf_target__has_task(&target)) { 1699 if (target__has_task(&target)) {
1701 pr_err("Problems finding threads of monitor\n"); 1700 pr_err("Problems finding threads of monitor\n");
1702 parse_options_usage(stat_usage, options, "p", 1); 1701 parse_options_usage(stat_usage, options, "p", 1);
1703 parse_options_usage(NULL, options, "t", 1); 1702 parse_options_usage(NULL, options, "t", 1);
1704 } else if (perf_target__has_cpu(&target)) { 1703 } else if (target__has_cpu(&target)) {
1705 perror("failed to parse CPUs map"); 1704 perror("failed to parse CPUs map");
1706 parse_options_usage(stat_usage, options, "C", 1); 1705 parse_options_usage(stat_usage, options, "C", 1);
1707 parse_options_usage(NULL, options, "a", 1); 1706 parse_options_usage(NULL, options, "a", 1);
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 8c520d9fecfc..b8f8e29db332 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -967,7 +967,7 @@ static int __cmd_top(struct perf_top *top)
967 * XXX 'top' still doesn't start workloads like record, trace, but should, 967 * XXX 'top' still doesn't start workloads like record, trace, but should,
968 * so leave the check here. 968 * so leave the check here.
969 */ 969 */
970 if (!perf_target__none(&opts->target)) 970 if (!target__none(&opts->target))
971 perf_evlist__enable(top->evlist); 971 perf_evlist__enable(top->evlist);
972 972
973 /* Wait for a minimal set of events before starting the snapshot */ 973 /* Wait for a minimal set of events before starting the snapshot */
@@ -1053,7 +1053,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
1053 .sym_pcnt_filter = 5, 1053 .sym_pcnt_filter = 5,
1054 }; 1054 };
1055 struct perf_record_opts *opts = &top.record_opts; 1055 struct perf_record_opts *opts = &top.record_opts;
1056 struct perf_target *target = &opts->target; 1056 struct target *target = &opts->target;
1057 const struct option options[] = { 1057 const struct option options[] = {
1058 OPT_CALLBACK('e', "event", &top.evlist, "event", 1058 OPT_CALLBACK('e', "event", &top.evlist, "event",
1059 "event selector. use 'perf list' to list available events", 1059 "event selector. use 'perf list' to list available events",
@@ -1169,24 +1169,24 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
1169 1169
1170 setup_browser(false); 1170 setup_browser(false);
1171 1171
1172 status = perf_target__validate(target); 1172 status = target__validate(target);
1173 if (status) { 1173 if (status) {
1174 perf_target__strerror(target, status, errbuf, BUFSIZ); 1174 target__strerror(target, status, errbuf, BUFSIZ);
1175 ui__warning("%s", errbuf); 1175 ui__warning("%s", errbuf);
1176 } 1176 }
1177 1177
1178 status = perf_target__parse_uid(target); 1178 status = target__parse_uid(target);
1179 if (status) { 1179 if (status) {
1180 int saved_errno = errno; 1180 int saved_errno = errno;
1181 1181
1182 perf_target__strerror(target, status, errbuf, BUFSIZ); 1182 target__strerror(target, status, errbuf, BUFSIZ);
1183 ui__error("%s", errbuf); 1183 ui__error("%s", errbuf);
1184 1184
1185 status = -saved_errno; 1185 status = -saved_errno;
1186 goto out_delete_evlist; 1186 goto out_delete_evlist;
1187 } 1187 }
1188 1188
1189 if (perf_target__none(target)) 1189 if (target__none(target))
1190 target->system_wide = true; 1190 target->system_wide = true;
1191 1191
1192 if (perf_evlist__create_maps(top.evlist, target) < 0) 1192 if (perf_evlist__create_maps(top.evlist, target) < 0)
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index aa5702ffa2cb..6b230af940e2 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2327,21 +2327,21 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
2327 } 2327 }
2328 } 2328 }
2329 2329
2330 err = perf_target__validate(&trace.opts.target); 2330 err = target__validate(&trace.opts.target);
2331 if (err) { 2331 if (err) {
2332 perf_target__strerror(&trace.opts.target, err, bf, sizeof(bf)); 2332 target__strerror(&trace.opts.target, err, bf, sizeof(bf));
2333 fprintf(trace.output, "%s", bf); 2333 fprintf(trace.output, "%s", bf);
2334 goto out_close; 2334 goto out_close;
2335 } 2335 }
2336 2336
2337 err = perf_target__parse_uid(&trace.opts.target); 2337 err = target__parse_uid(&trace.opts.target);
2338 if (err) { 2338 if (err) {
2339 perf_target__strerror(&trace.opts.target, err, bf, sizeof(bf)); 2339 target__strerror(&trace.opts.target, err, bf, sizeof(bf));
2340 fprintf(trace.output, "%s", bf); 2340 fprintf(trace.output, "%s", bf);
2341 goto out_close; 2341 goto out_close;
2342 } 2342 }
2343 2343
2344 if (!argc && perf_target__none(&trace.opts.target)) 2344 if (!argc && target__none(&trace.opts.target))
2345 trace.opts.target.system_wide = true; 2345 trace.opts.target.system_wide = true;
2346 2346
2347 if (input_name) 2347 if (input_name)
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 6a587e84fdfe..b079304bd53d 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -248,7 +248,7 @@ enum perf_call_graph_mode {
248}; 248};
249 249
250struct perf_record_opts { 250struct perf_record_opts {
251 struct perf_target target; 251 struct target target;
252 int call_graph; 252 int call_graph;
253 bool group; 253 bool group;
254 bool inherit_stat; 254 bool inherit_stat;
diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c
index c33d95f9559a..d09ab579119e 100644
--- a/tools/perf/tests/task-exit.c
+++ b/tools/perf/tests/task-exit.c
@@ -28,7 +28,7 @@ int test__task_exit(void)
28 union perf_event *event; 28 union perf_event *event;
29 struct perf_evsel *evsel; 29 struct perf_evsel *evsel;
30 struct perf_evlist *evlist; 30 struct perf_evlist *evlist;
31 struct perf_target target = { 31 struct target target = {
32 .uid = UINT_MAX, 32 .uid = UINT_MAX,
33 .uses_mmap = true, 33 .uses_mmap = true,
34 }; 34 };
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index cb19044601bb..dc6fa3fbb180 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -811,8 +811,7 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
811 return perf_evlist__mmap_per_cpu(evlist, prot, mask); 811 return perf_evlist__mmap_per_cpu(evlist, prot, mask);
812} 812}
813 813
814int perf_evlist__create_maps(struct perf_evlist *evlist, 814int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
815 struct perf_target *target)
816{ 815{
817 evlist->threads = thread_map__new_str(target->pid, target->tid, 816 evlist->threads = thread_map__new_str(target->pid, target->tid,
818 target->uid); 817 target->uid);
@@ -820,9 +819,9 @@ int perf_evlist__create_maps(struct perf_evlist *evlist,
820 if (evlist->threads == NULL) 819 if (evlist->threads == NULL)
821 return -1; 820 return -1;
822 821
823 if (perf_target__has_task(target)) 822 if (target__has_task(target))
824 evlist->cpus = cpu_map__dummy_new(); 823 evlist->cpus = cpu_map__dummy_new();
825 else if (!perf_target__has_cpu(target) && !target->uses_mmap) 824 else if (!target__has_cpu(target) && !target->uses_mmap)
826 evlist->cpus = cpu_map__dummy_new(); 825 evlist->cpus = cpu_map__dummy_new();
827 else 826 else
828 evlist->cpus = cpu_map__new(target->cpu_list); 827 evlist->cpus = cpu_map__new(target->cpu_list);
@@ -1031,8 +1030,7 @@ out_err:
1031 return err; 1030 return err;
1032} 1031}
1033 1032
1034int perf_evlist__prepare_workload(struct perf_evlist *evlist, 1033int perf_evlist__prepare_workload(struct perf_evlist *evlist, struct target *target,
1035 struct perf_target *target,
1036 const char *argv[], bool pipe_output, 1034 const char *argv[], bool pipe_output,
1037 bool want_signal) 1035 bool want_signal)
1038{ 1036{
@@ -1084,7 +1082,7 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist,
1084 exit(-1); 1082 exit(-1);
1085 } 1083 }
1086 1084
1087 if (perf_target__none(target)) 1085 if (target__none(target))
1088 evlist->threads->map[0] = evlist->workload.pid; 1086 evlist->threads->map[0] = evlist->workload.pid;
1089 1087
1090 close(child_ready_pipe[1]); 1088 close(child_ready_pipe[1]);
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index ecaa582f40e2..649d6ea98a84 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -102,7 +102,7 @@ void perf_evlist__config(struct perf_evlist *evlist,
102int perf_record_opts__config(struct perf_record_opts *opts); 102int perf_record_opts__config(struct perf_record_opts *opts);
103 103
104int perf_evlist__prepare_workload(struct perf_evlist *evlist, 104int perf_evlist__prepare_workload(struct perf_evlist *evlist,
105 struct perf_target *target, 105 struct target *target,
106 const char *argv[], bool pipe_output, 106 const char *argv[], bool pipe_output,
107 bool want_signal); 107 bool want_signal);
108int perf_evlist__start_workload(struct perf_evlist *evlist); 108int perf_evlist__start_workload(struct perf_evlist *evlist);
@@ -134,8 +134,7 @@ static inline void perf_evlist__set_maps(struct perf_evlist *evlist,
134 evlist->threads = threads; 134 evlist->threads = threads;
135} 135}
136 136
137int perf_evlist__create_maps(struct perf_evlist *evlist, 137int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target);
138 struct perf_target *target);
139void perf_evlist__delete_maps(struct perf_evlist *evlist); 138void perf_evlist__delete_maps(struct perf_evlist *evlist);
140int perf_evlist__apply_filters(struct perf_evlist *evlist); 139int perf_evlist__apply_filters(struct perf_evlist *evlist);
141 140
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index f95653a639a6..18f7c188ff63 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -645,7 +645,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
645 } 645 }
646 } 646 }
647 647
648 if (perf_target__has_cpu(&opts->target)) 648 if (target__has_cpu(&opts->target))
649 perf_evsel__set_sample_bit(evsel, CPU); 649 perf_evsel__set_sample_bit(evsel, CPU);
650 650
651 if (opts->period) 651 if (opts->period)
@@ -653,7 +653,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
653 653
654 if (!perf_missing_features.sample_id_all && 654 if (!perf_missing_features.sample_id_all &&
655 (opts->sample_time || !opts->no_inherit || 655 (opts->sample_time || !opts->no_inherit ||
656 perf_target__has_cpu(&opts->target))) 656 target__has_cpu(&opts->target)))
657 perf_evsel__set_sample_bit(evsel, TIME); 657 perf_evsel__set_sample_bit(evsel, TIME);
658 658
659 if (opts->raw_samples) { 659 if (opts->raw_samples) {
@@ -696,7 +696,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
696 * Setting enable_on_exec for independent events and 696 * Setting enable_on_exec for independent events and
697 * group leaders for traced executed by perf. 697 * group leaders for traced executed by perf.
698 */ 698 */
699 if (perf_target__none(&opts->target) && perf_evsel__is_group_leader(evsel)) 699 if (target__none(&opts->target) && perf_evsel__is_group_leader(evsel))
700 attr->enable_on_exec = 1; 700 attr->enable_on_exec = 1;
701} 701}
702 702
@@ -2006,8 +2006,7 @@ bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
2006 return false; 2006 return false;
2007} 2007}
2008 2008
2009int perf_evsel__open_strerror(struct perf_evsel *evsel, 2009int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
2010 struct perf_target *target,
2011 int err, char *msg, size_t size) 2010 int err, char *msg, size_t size)
2012{ 2011{
2013 switch (err) { 2012 switch (err) {
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 0178233abd64..f5029653dcd7 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -318,8 +318,7 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,
318 318
319bool perf_evsel__fallback(struct perf_evsel *evsel, int err, 319bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
320 char *msg, size_t msgsize); 320 char *msg, size_t msgsize);
321int perf_evsel__open_strerror(struct perf_evsel *evsel, 321int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
322 struct perf_target *target,
323 int err, char *msg, size_t size); 322 int err, char *msg, size_t size);
324 323
325static inline int perf_evsel__group_idx(struct perf_evsel *evsel) 324static inline int perf_evsel__group_idx(struct perf_evsel *evsel)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 680700b6d779..0393912d8033 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1396,12 +1396,12 @@ int machine__for_each_thread(struct machine *machine,
1396} 1396}
1397 1397
1398int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool, 1398int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
1399 struct perf_target *target, struct thread_map *threads, 1399 struct target *target, struct thread_map *threads,
1400 perf_event__handler_t process, bool data_mmap) 1400 perf_event__handler_t process, bool data_mmap)
1401{ 1401{
1402 if (perf_target__has_task(target)) 1402 if (target__has_task(target))
1403 return perf_event__synthesize_thread_map(tool, threads, process, machine, data_mmap); 1403 return perf_event__synthesize_thread_map(tool, threads, process, machine, data_mmap);
1404 else if (perf_target__has_cpu(target)) 1404 else if (target__has_cpu(target))
1405 return perf_event__synthesize_threads(tool, process, machine, data_mmap); 1405 return perf_event__synthesize_threads(tool, process, machine, data_mmap);
1406 /* command specified */ 1406 /* command specified */
1407 return 0; 1407 return 0;
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index fedd1dfaf715..477133015440 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -180,10 +180,10 @@ int machine__for_each_thread(struct machine *machine,
180 void *priv); 180 void *priv);
181 181
182int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool, 182int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
183 struct perf_target *target, struct thread_map *threads, 183 struct target *target, struct thread_map *threads,
184 perf_event__handler_t process, bool data_mmap); 184 perf_event__handler_t process, bool data_mmap);
185static inline 185static inline
186int machine__synthesize_threads(struct machine *machine, struct perf_target *target, 186int machine__synthesize_threads(struct machine *machine, struct target *target,
187 struct thread_map *threads, bool data_mmap) 187 struct thread_map *threads, bool data_mmap)
188{ 188{
189 return __machine__synthesize_threads(machine, NULL, target, threads, 189 return __machine__synthesize_threads(machine, NULL, target, threads,
diff --git a/tools/perf/util/target.c b/tools/perf/util/target.c
index 065528b7563e..3c778a07b7cc 100644
--- a/tools/perf/util/target.c
+++ b/tools/perf/util/target.c
@@ -13,9 +13,9 @@
13#include <string.h> 13#include <string.h>
14 14
15 15
16enum perf_target_errno perf_target__validate(struct perf_target *target) 16enum target_errno target__validate(struct target *target)
17{ 17{
18 enum perf_target_errno ret = PERF_ERRNO_TARGET__SUCCESS; 18 enum target_errno ret = TARGET_ERRNO__SUCCESS;
19 19
20 if (target->pid) 20 if (target->pid)
21 target->tid = target->pid; 21 target->tid = target->pid;
@@ -23,42 +23,42 @@ enum perf_target_errno perf_target__validate(struct perf_target *target)
23 /* CPU and PID are mutually exclusive */ 23 /* CPU and PID are mutually exclusive */
24 if (target->tid && target->cpu_list) { 24 if (target->tid && target->cpu_list) {
25 target->cpu_list = NULL; 25 target->cpu_list = NULL;
26 if (ret == PERF_ERRNO_TARGET__SUCCESS) 26 if (ret == TARGET_ERRNO__SUCCESS)
27 ret = PERF_ERRNO_TARGET__PID_OVERRIDE_CPU; 27 ret = TARGET_ERRNO__PID_OVERRIDE_CPU;
28 } 28 }
29 29
30 /* UID and PID are mutually exclusive */ 30 /* UID and PID are mutually exclusive */
31 if (target->tid && target->uid_str) { 31 if (target->tid && target->uid_str) {
32 target->uid_str = NULL; 32 target->uid_str = NULL;
33 if (ret == PERF_ERRNO_TARGET__SUCCESS) 33 if (ret == TARGET_ERRNO__SUCCESS)
34 ret = PERF_ERRNO_TARGET__PID_OVERRIDE_UID; 34 ret = TARGET_ERRNO__PID_OVERRIDE_UID;
35 } 35 }
36 36
37 /* UID and CPU are mutually exclusive */ 37 /* UID and CPU are mutually exclusive */
38 if (target->uid_str && target->cpu_list) { 38 if (target->uid_str && target->cpu_list) {
39 target->cpu_list = NULL; 39 target->cpu_list = NULL;
40 if (ret == PERF_ERRNO_TARGET__SUCCESS) 40 if (ret == TARGET_ERRNO__SUCCESS)
41 ret = PERF_ERRNO_TARGET__UID_OVERRIDE_CPU; 41 ret = TARGET_ERRNO__UID_OVERRIDE_CPU;
42 } 42 }
43 43
44 /* PID and SYSTEM are mutually exclusive */ 44 /* PID and SYSTEM are mutually exclusive */
45 if (target->tid && target->system_wide) { 45 if (target->tid && target->system_wide) {
46 target->system_wide = false; 46 target->system_wide = false;
47 if (ret == PERF_ERRNO_TARGET__SUCCESS) 47 if (ret == TARGET_ERRNO__SUCCESS)
48 ret = PERF_ERRNO_TARGET__PID_OVERRIDE_SYSTEM; 48 ret = TARGET_ERRNO__PID_OVERRIDE_SYSTEM;
49 } 49 }
50 50
51 /* UID and SYSTEM are mutually exclusive */ 51 /* UID and SYSTEM are mutually exclusive */
52 if (target->uid_str && target->system_wide) { 52 if (target->uid_str && target->system_wide) {
53 target->system_wide = false; 53 target->system_wide = false;
54 if (ret == PERF_ERRNO_TARGET__SUCCESS) 54 if (ret == TARGET_ERRNO__SUCCESS)
55 ret = PERF_ERRNO_TARGET__UID_OVERRIDE_SYSTEM; 55 ret = TARGET_ERRNO__UID_OVERRIDE_SYSTEM;
56 } 56 }
57 57
58 return ret; 58 return ret;
59} 59}
60 60
61enum perf_target_errno perf_target__parse_uid(struct perf_target *target) 61enum target_errno target__parse_uid(struct target *target)
62{ 62{
63 struct passwd pwd, *result; 63 struct passwd pwd, *result;
64 char buf[1024]; 64 char buf[1024];
@@ -66,7 +66,7 @@ enum perf_target_errno perf_target__parse_uid(struct perf_target *target)
66 66
67 target->uid = UINT_MAX; 67 target->uid = UINT_MAX;
68 if (str == NULL) 68 if (str == NULL)
69 return PERF_ERRNO_TARGET__SUCCESS; 69 return TARGET_ERRNO__SUCCESS;
70 70
71 /* Try user name first */ 71 /* Try user name first */
72 getpwnam_r(str, &pwd, buf, sizeof(buf), &result); 72 getpwnam_r(str, &pwd, buf, sizeof(buf), &result);
@@ -79,22 +79,22 @@ enum perf_target_errno perf_target__parse_uid(struct perf_target *target)
79 int uid = strtol(str, &endptr, 10); 79 int uid = strtol(str, &endptr, 10);
80 80
81 if (*endptr != '\0') 81 if (*endptr != '\0')
82 return PERF_ERRNO_TARGET__INVALID_UID; 82 return TARGET_ERRNO__INVALID_UID;
83 83
84 getpwuid_r(uid, &pwd, buf, sizeof(buf), &result); 84 getpwuid_r(uid, &pwd, buf, sizeof(buf), &result);
85 85
86 if (result == NULL) 86 if (result == NULL)
87 return PERF_ERRNO_TARGET__USER_NOT_FOUND; 87 return TARGET_ERRNO__USER_NOT_FOUND;
88 } 88 }
89 89
90 target->uid = result->pw_uid; 90 target->uid = result->pw_uid;
91 return PERF_ERRNO_TARGET__SUCCESS; 91 return TARGET_ERRNO__SUCCESS;
92} 92}
93 93
94/* 94/*
95 * This must have a same ordering as the enum perf_target_errno. 95 * This must have a same ordering as the enum target_errno.
96 */ 96 */
97static const char *perf_target__error_str[] = { 97static const char *target__error_str[] = {
98 "PID/TID switch overriding CPU", 98 "PID/TID switch overriding CPU",
99 "PID/TID switch overriding UID", 99 "PID/TID switch overriding UID",
100 "UID switch overriding CPU", 100 "UID switch overriding CPU",
@@ -104,7 +104,7 @@ static const char *perf_target__error_str[] = {
104 "Problems obtaining information for user %s", 104 "Problems obtaining information for user %s",
105}; 105};
106 106
107int perf_target__strerror(struct perf_target *target, int errnum, 107int target__strerror(struct target *target, int errnum,
108 char *buf, size_t buflen) 108 char *buf, size_t buflen)
109{ 109{
110 int idx; 110 int idx;
@@ -124,21 +124,19 @@ int perf_target__strerror(struct perf_target *target, int errnum,
124 return 0; 124 return 0;
125 } 125 }
126 126
127 if (errnum < __PERF_ERRNO_TARGET__START || 127 if (errnum < __TARGET_ERRNO__START || errnum >= __TARGET_ERRNO__END)
128 errnum >= __PERF_ERRNO_TARGET__END)
129 return -1; 128 return -1;
130 129
131 idx = errnum - __PERF_ERRNO_TARGET__START; 130 idx = errnum - __TARGET_ERRNO__START;
132 msg = perf_target__error_str[idx]; 131 msg = target__error_str[idx];
133 132
134 switch (errnum) { 133 switch (errnum) {
135 case PERF_ERRNO_TARGET__PID_OVERRIDE_CPU 134 case TARGET_ERRNO__PID_OVERRIDE_CPU ... TARGET_ERRNO__UID_OVERRIDE_SYSTEM:
136 ... PERF_ERRNO_TARGET__UID_OVERRIDE_SYSTEM:
137 snprintf(buf, buflen, "%s", msg); 135 snprintf(buf, buflen, "%s", msg);
138 break; 136 break;
139 137
140 case PERF_ERRNO_TARGET__INVALID_UID: 138 case TARGET_ERRNO__INVALID_UID:
141 case PERF_ERRNO_TARGET__USER_NOT_FOUND: 139 case TARGET_ERRNO__USER_NOT_FOUND:
142 snprintf(buf, buflen, msg, target->uid_str); 140 snprintf(buf, buflen, msg, target->uid_str);
143 break; 141 break;
144 142
diff --git a/tools/perf/util/target.h b/tools/perf/util/target.h
index a4be8575fda5..89bab7129de4 100644
--- a/tools/perf/util/target.h
+++ b/tools/perf/util/target.h
@@ -4,7 +4,7 @@
4#include <stdbool.h> 4#include <stdbool.h>
5#include <sys/types.h> 5#include <sys/types.h>
6 6
7struct perf_target { 7struct target {
8 const char *pid; 8 const char *pid;
9 const char *tid; 9 const char *tid;
10 const char *cpu_list; 10 const char *cpu_list;
@@ -14,8 +14,8 @@ struct perf_target {
14 bool uses_mmap; 14 bool uses_mmap;
15}; 15};
16 16
17enum perf_target_errno { 17enum target_errno {
18 PERF_ERRNO_TARGET__SUCCESS = 0, 18 TARGET_ERRNO__SUCCESS = 0,
19 19
20 /* 20 /*
21 * Choose an arbitrary negative big number not to clash with standard 21 * Choose an arbitrary negative big number not to clash with standard
@@ -24,42 +24,40 @@ enum perf_target_errno {
24 * 24 *
25 * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html 25 * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
26 */ 26 */
27 __PERF_ERRNO_TARGET__START = -10000, 27 __TARGET_ERRNO__START = -10000,
28 28
29 /* for target__validate() */
30 TARGET_ERRNO__PID_OVERRIDE_CPU = __TARGET_ERRNO__START,
31 TARGET_ERRNO__PID_OVERRIDE_UID,
32 TARGET_ERRNO__UID_OVERRIDE_CPU,
33 TARGET_ERRNO__PID_OVERRIDE_SYSTEM,
34 TARGET_ERRNO__UID_OVERRIDE_SYSTEM,
29 35
30 /* for perf_target__validate() */ 36 /* for target__parse_uid() */
31 PERF_ERRNO_TARGET__PID_OVERRIDE_CPU = __PERF_ERRNO_TARGET__START, 37 TARGET_ERRNO__INVALID_UID,
32 PERF_ERRNO_TARGET__PID_OVERRIDE_UID, 38 TARGET_ERRNO__USER_NOT_FOUND,
33 PERF_ERRNO_TARGET__UID_OVERRIDE_CPU,
34 PERF_ERRNO_TARGET__PID_OVERRIDE_SYSTEM,
35 PERF_ERRNO_TARGET__UID_OVERRIDE_SYSTEM,
36 39
37 /* for perf_target__parse_uid() */ 40 __TARGET_ERRNO__END,
38 PERF_ERRNO_TARGET__INVALID_UID,
39 PERF_ERRNO_TARGET__USER_NOT_FOUND,
40
41 __PERF_ERRNO_TARGET__END,
42}; 41};
43 42
44enum perf_target_errno perf_target__validate(struct perf_target *target); 43enum target_errno target__validate(struct target *target);
45enum perf_target_errno perf_target__parse_uid(struct perf_target *target); 44enum target_errno target__parse_uid(struct target *target);
46 45
47int perf_target__strerror(struct perf_target *target, int errnum, char *buf, 46int target__strerror(struct target *target, int errnum, char *buf, size_t buflen);
48 size_t buflen);
49 47
50static inline bool perf_target__has_task(struct perf_target *target) 48static inline bool target__has_task(struct target *target)
51{ 49{
52 return target->tid || target->pid || target->uid_str; 50 return target->tid || target->pid || target->uid_str;
53} 51}
54 52
55static inline bool perf_target__has_cpu(struct perf_target *target) 53static inline bool target__has_cpu(struct target *target)
56{ 54{
57 return target->system_wide || target->cpu_list; 55 return target->system_wide || target->cpu_list;
58} 56}
59 57
60static inline bool perf_target__none(struct perf_target *target) 58static inline bool target__none(struct target *target)
61{ 59{
62 return !perf_target__has_task(target) && !perf_target__has_cpu(target); 60 return !target__has_task(target) && !target__has_cpu(target);
63} 61}
64 62
65#endif /* _PERF_TARGET_H */ 63#endif /* _PERF_TARGET_H */
diff --git a/tools/perf/util/top.c b/tools/perf/util/top.c
index f857b51b6bde..ce793c7dd23c 100644
--- a/tools/perf/util/top.c
+++ b/tools/perf/util/top.c
@@ -27,7 +27,7 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size)
27 float ksamples_per_sec; 27 float ksamples_per_sec;
28 float esamples_percent; 28 float esamples_percent;
29 struct perf_record_opts *opts = &top->record_opts; 29 struct perf_record_opts *opts = &top->record_opts;
30 struct perf_target *target = &opts->target; 30 struct target *target = &opts->target;
31 size_t ret = 0; 31 size_t ret = 0;
32 32
33 if (top->samples) { 33 if (top->samples) {