aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/builtin-record.c29
-rw-r--r--tools/perf/builtin-top.c23
-rw-r--r--tools/perf/perf.h1
-rw-r--r--tools/perf/util/top.h1
4 files changed, 39 insertions, 15 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 08ed24b66ffe..d6c10e8ff6b6 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -205,6 +205,9 @@ static void perf_record__open(struct perf_record *rec)
205 205
206 if (opts->group && pos != first) 206 if (opts->group && pos != first)
207 group_fd = first->fd; 207 group_fd = first->fd;
208fallback_missing_features:
209 if (opts->exclude_guest_missing)
210 attr->exclude_guest = attr->exclude_host = 0;
208retry_sample_id: 211retry_sample_id:
209 attr->sample_id_all = opts->sample_id_all_avail ? 1 : 0; 212 attr->sample_id_all = opts->sample_id_all_avail ? 1 : 0;
210try_again: 213try_again:
@@ -218,15 +221,23 @@ try_again:
218 } else if (err == ENODEV && opts->cpu_list) { 221 } else if (err == ENODEV && opts->cpu_list) {
219 die("No such device - did you specify" 222 die("No such device - did you specify"
220 " an out-of-range profile CPU?\n"); 223 " an out-of-range profile CPU?\n");
221 } else if (err == EINVAL && opts->sample_id_all_avail) { 224 } else if (err == EINVAL) {
222 /* 225 if (!opts->exclude_guest_missing &&
223 * Old kernel, no attr->sample_id_type_all field 226 (attr->exclude_guest || attr->exclude_host)) {
224 */ 227 pr_debug("Old kernel, cannot exclude "
225 opts->sample_id_all_avail = false; 228 "guest or host samples.\n");
226 if (!opts->sample_time && !opts->raw_samples && !time_needed) 229 opts->exclude_guest_missing = true;
227 attr->sample_type &= ~PERF_SAMPLE_TIME; 230 goto fallback_missing_features;
228 231 } else if (opts->sample_id_all_avail) {
229 goto retry_sample_id; 232 /*
233 * Old kernel, no attr->sample_id_type_all field
234 */
235 opts->sample_id_all_avail = false;
236 if (!opts->sample_time && !opts->raw_samples && !time_needed)
237 attr->sample_type &= ~PERF_SAMPLE_TIME;
238
239 goto retry_sample_id;
240 }
230 } 241 }
231 242
232 /* 243 /*
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 5a88c0dadf15..02e11ff5a729 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -872,6 +872,9 @@ static void perf_top__start_counters(struct perf_top *top)
872 attr->mmap = 1; 872 attr->mmap = 1;
873 attr->comm = 1; 873 attr->comm = 1;
874 attr->inherit = top->inherit; 874 attr->inherit = top->inherit;
875fallback_missing_features:
876 if (top->exclude_guest_missing)
877 attr->exclude_guest = attr->exclude_host = 0;
875retry_sample_id: 878retry_sample_id:
876 attr->sample_id_all = top->sample_id_all_avail ? 1 : 0; 879 attr->sample_id_all = top->sample_id_all_avail ? 1 : 0;
877try_again: 880try_again:
@@ -883,12 +886,20 @@ try_again:
883 if (err == EPERM || err == EACCES) { 886 if (err == EPERM || err == EACCES) {
884 ui__error_paranoid(); 887 ui__error_paranoid();
885 goto out_err; 888 goto out_err;
886 } else if (err == EINVAL && top->sample_id_all_avail) { 889 } else if (err == EINVAL) {
887 /* 890 if (!top->exclude_guest_missing &&
888 * Old kernel, no attr->sample_id_type_all field 891 (attr->exclude_guest || attr->exclude_host)) {
889 */ 892 pr_debug("Old kernel, cannot exclude "
890 top->sample_id_all_avail = false; 893 "guest or host samples.\n");
891 goto retry_sample_id; 894 top->exclude_guest_missing = true;
895 goto fallback_missing_features;
896 } else if (top->sample_id_all_avail) {
897 /*
898 * Old kernel, no attr->sample_id_type_all field
899 */
900 top->sample_id_all_avail = false;
901 goto retry_sample_id;
902 }
892 } 903 }
893 /* 904 /*
894 * If it's cycles then fall back to hrtimer 905 * If it's cycles then fall back to hrtimer
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 03a045618148..8b9c43635f4d 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 49eb8481f19f..7dea8912aa97 100644
--- a/tools/perf/util/top.h
+++ b/tools/perf/util/top.h
@@ -35,6 +35,7 @@ struct perf_top {
35 bool inherit; 35 bool inherit;
36 bool group; 36 bool group;
37 bool sample_id_all_avail; 37 bool sample_id_all_avail;
38 bool exclude_guest_missing;
38 bool dump_symtab; 39 bool dump_symtab;
39 const char *cpu_list; 40 const char *cpu_list;
40 struct hist_entry *sym_filter_entry; 41 struct hist_entry *sym_filter_entry;