@@ -152,8 +152,8 @@ static int perf_record__mmap_read(struct perf_record *rec,
}
md->prev = old;
- perf_mmap__write_tail(md, old);
-
+ if (!rec->opts.mmap_ro)
+ perf_mmap__write_tail(md, old);
out:
return rc;
}
@@ -226,7 +226,12 @@ static int perf_record__open(struct perf_record *rec)
goto out;
}
- if (perf_evlist__mmap(evlist, opts->mmap_pages, false) < 0) {
+try_again2:
+ if (perf_evlist__mmap(evlist, opts->mmap_pages, opts->mmap_ro) < 0) {
+ if (!opts->mmap_ro && errno == EACCES) {
+ opts->mmap_ro = true;
+ goto try_again2;
+ }
if (errno == EPERM) {
pr_err("Permission error mapping pages.\n"
"Consider increasing "
@@ -894,8 +894,12 @@ static int perf_top__start_counters(struct perf_top *top)
goto out_err;
}
}
-
- if (perf_evlist__mmap(evlist, opts->mmap_pages, false) < 0) {
+try_again2:
+ if (perf_evlist__mmap(evlist, opts->mmap_pages, opts->mmap_ro) < 0) {
+ if (!opts->mmap_ro && errno == EACCES) {
+ opts->mmap_ro = true;
+ goto try_again2;
+ }
ui__error("Failed to mmap with %d (%s)\n",
errno, strerror(errno));
goto out_err;
@@ -224,6 +224,7 @@ struct perf_record_opts {
bool sample_weight;
bool sample_time;
bool period;
+ bool mmap_ro;
unsigned int freq;
unsigned int mmap_pages;
unsigned int user_freq;