aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-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/top.h1
-rw-r--r--tools/perf/util/util.c2
5 files changed, 42 insertions, 18 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/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{