Commit a5a5ba72 authored by Don Zickus's avatar Don Zickus Committed by Jiri Olsa

Revert "perf: Disable PERF_RECORD_MMAP2 support"

This reverts commit 3090ffb5.

Re-enable the mmap2 interface as we will have a user soon.

Since things have changed since perf disabled mmap2, small tweaks
to the revert had to be done:

o commit 9d4ecc88 forced (n!=8) to become (n<7)
o a new libunwind test needed updating to use mmap2 interface
Signed-off-by: default avatarDon Zickus <dzickus@redhat.com>
Link: http://lkml.kernel.org/r/1401461382-209586-1-git-send-email-dzickus@redhat.comSigned-off-by: default avatarJiri Olsa <jolsa@kernel.org>
parent 7ef80703
...@@ -6929,10 +6929,6 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr, ...@@ -6929,10 +6929,6 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
if (ret) if (ret)
return -EFAULT; return -EFAULT;
/* disabled for now */
if (attr->mmap2)
return -EINVAL;
if (attr->__reserved_1) if (attr->__reserved_1)
return -EINVAL; return -EINVAL;
......
...@@ -15,7 +15,7 @@ static int mmap_handler(struct perf_tool *tool __maybe_unused, ...@@ -15,7 +15,7 @@ static int mmap_handler(struct perf_tool *tool __maybe_unused,
struct perf_sample *sample __maybe_unused, struct perf_sample *sample __maybe_unused,
struct machine *machine) struct machine *machine)
{ {
return machine__process_mmap_event(machine, event, NULL); return machine__process_mmap2_event(machine, event, NULL);
} }
static int init_live_machine(struct machine *machine) static int init_live_machine(struct machine *machine)
......
...@@ -179,13 +179,14 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool, ...@@ -179,13 +179,14 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
return -1; return -1;
} }
event->header.type = PERF_RECORD_MMAP; event->header.type = PERF_RECORD_MMAP2;
while (1) { while (1) {
char bf[BUFSIZ]; char bf[BUFSIZ];
char prot[5]; char prot[5];
char execname[PATH_MAX]; char execname[PATH_MAX];
char anonstr[] = "//anon"; char anonstr[] = "//anon";
unsigned int ino;
size_t size; size_t size;
ssize_t n; ssize_t n;
...@@ -196,15 +197,20 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool, ...@@ -196,15 +197,20 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
strcpy(execname, ""); strcpy(execname, "");
/* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */ /* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */
n = sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %*x:%*x %*u %s\n", n = sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %x:%x %u %s\n",
&event->mmap.start, &event->mmap.len, prot, &event->mmap2.start, &event->mmap2.len, prot,
&event->mmap.pgoff, &event->mmap2.pgoff, &event->mmap2.maj,
execname); &event->mmap2.min,
&ino, execname);
/* /*
* Anon maps don't have the execname. * Anon maps don't have the execname.
*/ */
if (n < 4) if (n < 7)
continue; continue;
event->mmap2.ino = (u64)ino;
/* /*
* Just like the kernel, see __perf_event_mmap in kernel/perf_event.c * Just like the kernel, see __perf_event_mmap in kernel/perf_event.c
*/ */
...@@ -239,15 +245,15 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool, ...@@ -239,15 +245,15 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
strcpy(execname, anonstr); strcpy(execname, anonstr);
size = strlen(execname) + 1; size = strlen(execname) + 1;
memcpy(event->mmap.filename, execname, size); memcpy(event->mmap2.filename, execname, size);
size = PERF_ALIGN(size, sizeof(u64)); size = PERF_ALIGN(size, sizeof(u64));
event->mmap.len -= event->mmap.start; event->mmap2.len -= event->mmap.start;
event->mmap.header.size = (sizeof(event->mmap) - event->mmap2.header.size = (sizeof(event->mmap2) -
(sizeof(event->mmap.filename) - size)); (sizeof(event->mmap2.filename) - size));
memset(event->mmap.filename + size, 0, machine->id_hdr_size); memset(event->mmap2.filename + size, 0, machine->id_hdr_size);
event->mmap.header.size += machine->id_hdr_size; event->mmap2.header.size += machine->id_hdr_size;
event->mmap.pid = tgid; event->mmap2.pid = tgid;
event->mmap.tid = pid; event->mmap2.tid = pid;
if (process(tool, event, &synth_sample, machine) != 0) { if (process(tool, event, &synth_sample, machine) != 0) {
rc = -1; rc = -1;
......
...@@ -659,6 +659,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) ...@@ -659,6 +659,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
perf_evsel__set_sample_bit(evsel, WEIGHT); perf_evsel__set_sample_bit(evsel, WEIGHT);
attr->mmap = track; attr->mmap = track;
attr->mmap2 = track && !perf_missing_features.mmap2;
attr->comm = track; attr->comm = track;
if (opts->sample_transaction) if (opts->sample_transaction)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment