aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-record.c4
-rw-r--r--tools/perf/builtin-stat.c12
-rw-r--r--tools/perf/builtin-top.c2
-rw-r--r--tools/perf/util/evlist.c10
-rw-r--r--tools/perf/util/evsel.c8
-rw-r--r--tools/perf/util/target.h15
6 files changed, 31 insertions, 20 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index c8bf6ea000da..42e24149c791 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -843,9 +843,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
843 843
844 argc = parse_options(argc, argv, record_options, record_usage, 844 argc = parse_options(argc, argv, record_options, record_usage,
845 PARSE_OPT_STOP_AT_NON_OPTION); 845 PARSE_OPT_STOP_AT_NON_OPTION);
846 if (!argc && !rec->opts.target.pid && !rec->opts.target.tid && 846 if (!argc && perf_target__none(&rec->opts.target))
847 !rec->opts.target.system_wide && !rec->opts.target.cpu_list &&
848 !rec->opts.target.uid_str)
849 usage_with_options(record_usage, record_options); 847 usage_with_options(record_usage, record_options);
850 848
851 if (rec->force && rec->append_file) { 849 if (rec->force && rec->append_file) {
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index bb7723221c0d..d9ff24637eeb 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -290,10 +290,10 @@ static int create_perf_stat_counter(struct perf_evsel *evsel,
290 290
291 attr->inherit = !no_inherit; 291 attr->inherit = !no_inherit;
292 292
293 if (target.system_wide) 293 if (!perf_target__no_cpu(&target))
294 return perf_evsel__open_per_cpu(evsel, evsel_list->cpus, 294 return perf_evsel__open_per_cpu(evsel, evsel_list->cpus,
295 group, group_fd); 295 group, group_fd);
296 if (!target.pid && !target.tid && (!group || evsel == first)) { 296 if (perf_target__no_task(&target) && (!group || evsel == first)) {
297 attr->disabled = 1; 297 attr->disabled = 1;
298 attr->enable_on_exec = 1; 298 attr->enable_on_exec = 1;
299 } 299 }
@@ -443,7 +443,7 @@ static int run_perf_stat(int argc __used, const char **argv)
443 exit(-1); 443 exit(-1);
444 } 444 }
445 445
446 if (!target.tid && !target.pid && !target.system_wide) 446 if (perf_target__none(&target))
447 evsel_list->threads->map[0] = child_pid; 447 evsel_list->threads->map[0] = child_pid;
448 448
449 /* 449 /*
@@ -965,7 +965,7 @@ static void print_stat(int argc, const char **argv)
965 if (!csv_output) { 965 if (!csv_output) {
966 fprintf(output, "\n"); 966 fprintf(output, "\n");
967 fprintf(output, " Performance counter stats for "); 967 fprintf(output, " Performance counter stats for ");
968 if (!target.pid && !target.tid) { 968 if (perf_target__no_task(&target)) {
969 fprintf(output, "\'%s", argv[0]); 969 fprintf(output, "\'%s", argv[0]);
970 for (i = 1; i < argc; i++) 970 for (i = 1; i < argc; i++)
971 fprintf(output, " %s", argv[i]); 971 fprintf(output, " %s", argv[i]);
@@ -1187,13 +1187,13 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
1187 } else if (big_num_opt == 0) /* User passed --no-big-num */ 1187 } else if (big_num_opt == 0) /* User passed --no-big-num */
1188 big_num = false; 1188 big_num = false;
1189 1189
1190 if (!argc && !target.pid && !target.tid) 1190 if (!argc && perf_target__no_task(&target))
1191 usage_with_options(stat_usage, options); 1191 usage_with_options(stat_usage, options);
1192 if (run_count <= 0) 1192 if (run_count <= 0)
1193 usage_with_options(stat_usage, options); 1193 usage_with_options(stat_usage, options);
1194 1194
1195 /* no_aggr, cgroup are for system-wide only */ 1195 /* no_aggr, cgroup are for system-wide only */
1196 if ((no_aggr || nr_cgroups) && !target.system_wide) { 1196 if ((no_aggr || nr_cgroups) && perf_target__no_cpu(&target)) {
1197 fprintf(stderr, "both cgroup and no-aggregation " 1197 fprintf(stderr, "both cgroup and no-aggregation "
1198 "modes only available in system-wide mode\n"); 1198 "modes only available in system-wide mode\n");
1199 1199
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 7ba0f03c0132..e4ca827f6879 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1016,7 +1016,7 @@ static int __cmd_top(struct perf_top *top)
1016 if (ret) 1016 if (ret)
1017 goto out_delete; 1017 goto out_delete;
1018 1018
1019 if (top->target.tid || top->target.uid != UINT_MAX) 1019 if (!perf_target__no_task(&top->target))
1020 perf_event__synthesize_thread_map(&top->tool, top->evlist->threads, 1020 perf_event__synthesize_thread_map(&top->tool, top->evlist->threads,
1021 perf_event__process, 1021 perf_event__process,
1022 &top->session->host_machine); 1022 &top->session->host_machine);
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 183b199b0d09..1201daf71719 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -609,12 +609,10 @@ int perf_evlist__create_maps(struct perf_evlist *evlist,
609 if (evlist->threads == NULL) 609 if (evlist->threads == NULL)
610 return -1; 610 return -1;
611 611
612 if (target->uid != UINT_MAX || target->tid) 612 if (!perf_target__no_cpu(target))
613 evlist->cpus = cpu_map__dummy_new();
614 else if (!target->system_wide && target->cpu_list == NULL)
615 evlist->cpus = cpu_map__dummy_new();
616 else
617 evlist->cpus = cpu_map__new(target->cpu_list); 613 evlist->cpus = cpu_map__new(target->cpu_list);
614 else
615 evlist->cpus = cpu_map__dummy_new();
618 616
619 if (evlist->cpus == NULL) 617 if (evlist->cpus == NULL)
620 goto out_delete_threads; 618 goto out_delete_threads;
@@ -831,7 +829,7 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist,
831 exit(-1); 829 exit(-1);
832 } 830 }
833 831
834 if (!opts->target.system_wide && !opts->target.tid && !opts->target.pid) 832 if (perf_target__none(&opts->target))
835 evlist->threads->map[0] = evlist->workload.pid; 833 evlist->threads->map[0] = evlist->workload.pid;
836 834
837 close(child_ready_pipe[1]); 835 close(child_ready_pipe[1]);
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index bb785a098ced..21eaab240396 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -114,8 +114,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts,
114 attr->sample_type |= PERF_SAMPLE_PERIOD; 114 attr->sample_type |= PERF_SAMPLE_PERIOD;
115 115
116 if (!opts->sample_id_all_missing && 116 if (!opts->sample_id_all_missing &&
117 (opts->sample_time || opts->target.system_wide || 117 (opts->sample_time || !opts->no_inherit ||
118 !opts->no_inherit || opts->target.cpu_list)) 118 !perf_target__no_cpu(&opts->target)))
119 attr->sample_type |= PERF_SAMPLE_TIME; 119 attr->sample_type |= PERF_SAMPLE_TIME;
120 120
121 if (opts->raw_samples) { 121 if (opts->raw_samples) {
@@ -136,8 +136,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts,
136 attr->mmap = track; 136 attr->mmap = track;
137 attr->comm = track; 137 attr->comm = track;
138 138
139 if (!opts->target.pid && !opts->target.tid && 139 if (perf_target__none(&opts->target) &&
140 !opts->target.system_wide && (!opts->group || evsel == first)) { 140 (!opts->group || evsel == first)) {
141 attr->disabled = 1; 141 attr->disabled = 1;
142 attr->enable_on_exec = 1; 142 attr->enable_on_exec = 1;
143 } 143 }
diff --git a/tools/perf/util/target.h b/tools/perf/util/target.h
index 6fcd01c440a9..127cff3f8ced 100644
--- a/tools/perf/util/target.h
+++ b/tools/perf/util/target.h
@@ -46,4 +46,19 @@ enum perf_target_errno perf_target__parse_uid(struct perf_target *target);
46int perf_target__strerror(struct perf_target *target, int errnum, char *buf, 46int perf_target__strerror(struct perf_target *target, int errnum, char *buf,
47 size_t buflen); 47 size_t buflen);
48 48
49static inline bool perf_target__no_task(struct perf_target *target)
50{
51 return !target->pid && !target->tid && !target->uid_str;
52}
53
54static inline bool perf_target__no_cpu(struct perf_target *target)
55{
56 return !target->system_wide && !target->cpu_list;
57}
58
59static inline bool perf_target__none(struct perf_target *target)
60{
61 return perf_target__no_task(target) && perf_target__no_cpu(target);
62}
63
49#endif /* _PERF_TARGET_H */ 64#endif /* _PERF_TARGET_H */