aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-record.c33
-rw-r--r--tools/perf/builtin-top.c23
-rw-r--r--tools/perf/perf.h1
-rw-r--r--tools/perf/util/event.c1
-rw-r--r--tools/perf/util/evlist.c4
-rw-r--r--tools/perf/util/probe-event.c6
-rw-r--r--tools/perf/util/probe-finder.c12
-rw-r--r--tools/perf/util/top.h1
-rw-r--r--tools/perf/util/util.c2
9 files changed, 64 insertions, 19 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 0abfb18b911f..227b6ae99785 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -204,6 +204,9 @@ static void perf_record__open(struct perf_record *rec)
204 204
205 if (opts->group && pos != first) 205 if (opts->group && pos != first)
206 group_fd = first->fd; 206 group_fd = first->fd;
207fallback_missing_features:
208 if (opts->exclude_guest_missing)
209 attr->exclude_guest = attr->exclude_host = 0;
207retry_sample_id: 210retry_sample_id:
208 attr->sample_id_all = opts->sample_id_all_avail ? 1 : 0; 211 attr->sample_id_all = opts->sample_id_all_avail ? 1 : 0;
209try_again: 212try_again:
@@ -217,15 +220,23 @@ try_again:
217 } else if (err == ENODEV && opts->cpu_list) { 220 } else if (err == ENODEV && opts->cpu_list) {
218 die("No such device - did you specify" 221 die("No such device - did you specify"
219 " an out-of-range profile CPU?\n"); 222 " an out-of-range profile CPU?\n");
220 } else if (err == EINVAL && opts->sample_id_all_avail) { 223 } else if (err == EINVAL) {
221 /* 224 if (!opts->exclude_guest_missing &&
222 * Old kernel, no attr->sample_id_type_all field 225 (attr->exclude_guest || attr->exclude_host)) {
223 */ 226 pr_debug("Old kernel, cannot exclude "
224 opts->sample_id_all_avail = false; 227 "guest or host samples.\n");
225 if (!opts->sample_time && !opts->raw_samples && !time_needed) 228 opts->exclude_guest_missing = true;
226 attr->sample_type &= ~PERF_SAMPLE_TIME; 229 goto fallback_missing_features;
227 230 } else if (opts->sample_id_all_avail) {
228 goto retry_sample_id; 231 /*
232 * Old kernel, no attr->sample_id_type_all field
233 */
234 opts->sample_id_all_avail = false;
235 if (!opts->sample_time && !opts->raw_samples && !time_needed)
236 attr->sample_type &= ~PERF_SAMPLE_TIME;
237
238 goto retry_sample_id;
239 }
229 } 240 }
230 241
231 /* 242 /*
@@ -503,9 +514,9 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
503 return err; 514 return err;
504 } 515 }
505 516
506 if (!!rec->no_buildid 517 if (!rec->no_buildid
507 && !perf_header__has_feat(&session->header, HEADER_BUILD_ID)) { 518 && !perf_header__has_feat(&session->header, HEADER_BUILD_ID)) {
508 pr_err("Couldn't generating buildids. " 519 pr_err("Couldn't generate buildids. "
509 "Use --no-buildid to profile anyway.\n"); 520 "Use --no-buildid to profile anyway.\n");
510 return -1; 521 return -1;
511 } 522 }
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index dd162aa24baa..ecff31257eb3 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -857,6 +857,9 @@ static void perf_top__start_counters(struct perf_top *top)
857 attr->mmap = 1; 857 attr->mmap = 1;
858 attr->comm = 1; 858 attr->comm = 1;
859 attr->inherit = top->inherit; 859 attr->inherit = top->inherit;
860fallback_missing_features:
861 if (top->exclude_guest_missing)
862 attr->exclude_guest = attr->exclude_host = 0;
860retry_sample_id: 863retry_sample_id:
861 attr->sample_id_all = top->sample_id_all_avail ? 1 : 0; 864 attr->sample_id_all = top->sample_id_all_avail ? 1 : 0;
862try_again: 865try_again:
@@ -868,12 +871,20 @@ try_again:
868 if (err == EPERM || err == EACCES) { 871 if (err == EPERM || err == EACCES) {
869 ui__error_paranoid(); 872 ui__error_paranoid();
870 goto out_err; 873 goto out_err;
871 } else if (err == EINVAL && top->sample_id_all_avail) { 874 } else if (err == EINVAL) {
872 /* 875 if (!top->exclude_guest_missing &&
873 * Old kernel, no attr->sample_id_type_all field 876 (attr->exclude_guest || attr->exclude_host)) {
874 */ 877 pr_debug("Old kernel, cannot exclude "
875 top->sample_id_all_avail = false; 878 "guest or host samples.\n");
876 goto retry_sample_id; 879 top->exclude_guest_missing = true;
880 goto fallback_missing_features;
881 } else if (top->sample_id_all_avail) {
882 /*
883 * Old kernel, no attr->sample_id_type_all field
884 */
885 top->sample_id_all_avail = false;
886 goto retry_sample_id;
887 }
877 } 888 }
878 /* 889 /*
879 * If it's cycles then fall back to hrtimer 890 * If it's cycles then fall back to hrtimer
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 64f8bee31ced..16e7d20eee83 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -199,6 +199,7 @@ struct perf_record_opts {
199 bool sample_address; 199 bool sample_address;
200 bool sample_time; 200 bool sample_time;
201 bool sample_id_all_avail; 201 bool sample_id_all_avail;
202 bool exclude_guest_missing;
202 bool system_wide; 203 bool system_wide;
203 bool period; 204 bool period;
204 unsigned int freq; 205 unsigned int freq;
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 2044324b755a..2a6f33cd888c 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -74,6 +74,7 @@ static pid_t perf_event__get_comm_tgid(pid_t pid, char *comm, size_t len)
74 if (size >= len) 74 if (size >= len)
75 size = len - 1; 75 size = len - 1;
76 memcpy(comm, name, size); 76 memcpy(comm, name, size);
77 comm[size] = '\0';
77 78
78 } else if (memcmp(bf, "Tgid:", 5) == 0) { 79 } else if (memcmp(bf, "Tgid:", 5) == 0) {
79 char *tgids = bf + 5; 80 char *tgids = bf + 5;
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 3f16e08a5c8d..ea32a061f1c8 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -349,6 +349,10 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id)
349 hlist_for_each_entry(sid, pos, head, node) 349 hlist_for_each_entry(sid, pos, head, node)
350 if (sid->id == id) 350 if (sid->id == id)
351 return sid->evsel; 351 return sid->evsel;
352
353 if (!perf_evlist__sample_id_all(evlist))
354 return list_entry(evlist->entries.next, struct perf_evsel, node);
355
352 return NULL; 356 return NULL;
353} 357}
354 358
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 29cb65459811..e33554a562b3 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1867,6 +1867,12 @@ static int convert_to_probe_trace_events(struct perf_probe_event *pev,
1867 tev->point.symbol); 1867 tev->point.symbol);
1868 ret = -ENOENT; 1868 ret = -ENOENT;
1869 goto error; 1869 goto error;
1870 } else if (tev->point.offset > sym->end - sym->start) {
1871 pr_warning("Offset specified is greater than size of %s\n",
1872 tev->point.symbol);
1873 ret = -ENOENT;
1874 goto error;
1875
1870 } 1876 }
1871 1877
1872 return 1; 1878 return 1;
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 5d732621a462..74bd2e63c4b4 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -672,7 +672,7 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf)
672static int convert_to_trace_point(Dwarf_Die *sp_die, Dwarf_Addr paddr, 672static int convert_to_trace_point(Dwarf_Die *sp_die, Dwarf_Addr paddr,
673 bool retprobe, struct probe_trace_point *tp) 673 bool retprobe, struct probe_trace_point *tp)
674{ 674{
675 Dwarf_Addr eaddr; 675 Dwarf_Addr eaddr, highaddr;
676 const char *name; 676 const char *name;
677 677
678 /* Copy the name of probe point */ 678 /* Copy the name of probe point */
@@ -683,6 +683,16 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwarf_Addr paddr,
683 dwarf_diename(sp_die)); 683 dwarf_diename(sp_die));
684 return -ENOENT; 684 return -ENOENT;
685 } 685 }
686 if (dwarf_highpc(sp_die, &highaddr) != 0) {
687 pr_warning("Failed to get end address of %s\n",
688 dwarf_diename(sp_die));
689 return -ENOENT;
690 }
691 if (paddr > highaddr) {
692 pr_warning("Offset specified is greater than size of %s\n",
693 dwarf_diename(sp_die));
694 return -EINVAL;
695 }
686 tp->symbol = strdup(name); 696 tp->symbol = strdup(name);
687 if (tp->symbol == NULL) 697 if (tp->symbol == NULL)
688 return -ENOMEM; 698 return -ENOMEM;
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h
index a248f3c2c60d..f2eab81435ae 100644
--- a/tools/perf/util/top.h
+++ b/tools/perf/util/top.h
@@ -34,6 +34,7 @@ struct perf_top {
34 bool inherit; 34 bool inherit;
35 bool group; 35 bool group;
36 bool sample_id_all_avail; 36 bool sample_id_all_avail;
37 bool exclude_guest_missing;
37 bool dump_symtab; 38 bool dump_symtab;
38 const char *cpu_list; 39 const char *cpu_list;
39 struct hist_entry *sym_filter_entry; 40 struct hist_entry *sym_filter_entry;
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 813141047fc2..fb25d1329218 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -6,7 +6,7 @@
6 * XXX We need to find a better place for these things... 6 * XXX We need to find a better place for these things...
7 */ 7 */
8bool perf_host = true; 8bool perf_host = true;
9bool perf_guest = true; 9bool perf_guest = false;
10 10
11void event_attr_init(struct perf_event_attr *attr) 11void event_attr_init(struct perf_event_attr *attr)
12{ 12{