diff options
author | Don Zickus <dzickus@redhat.com> | 2014-05-30 10:49:42 -0400 |
---|---|---|
committer | Jiri Olsa <jolsa@kernel.org> | 2014-06-09 07:34:46 -0400 |
commit | a5a5ba72843dd05f991184d6cb9a4471acce1005 (patch) | |
tree | de974e4ab2d80e120d76ce1bb0cce1b83aa87500 | |
parent | 7ef807034ef33f8afe33fa7957c73954e8e4f89c (diff) |
Revert "perf: Disable PERF_RECORD_MMAP2 support"
This reverts commit 3090ffb5a2515990182f3f55b0688a7817325488.
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: Don Zickus <dzickus@redhat.com>
Link: http://lkml.kernel.org/r/1401461382-209586-1-git-send-email-dzickus@redhat.com
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
-rw-r--r-- | kernel/events/core.c | 4 | ||||
-rw-r--r-- | tools/perf/tests/dwarf-unwind.c | 2 | ||||
-rw-r--r-- | tools/perf/util/event.c | 34 | ||||
-rw-r--r-- | tools/perf/util/evsel.c | 1 |
4 files changed, 22 insertions, 19 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index eea1955c7868..cd28335b3d28 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -6929,10 +6929,6 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr, | |||
6929 | if (ret) | 6929 | if (ret) |
6930 | return -EFAULT; | 6930 | return -EFAULT; |
6931 | 6931 | ||
6932 | /* disabled for now */ | ||
6933 | if (attr->mmap2) | ||
6934 | return -EINVAL; | ||
6935 | |||
6936 | if (attr->__reserved_1) | 6932 | if (attr->__reserved_1) |
6937 | return -EINVAL; | 6933 | return -EINVAL; |
6938 | 6934 | ||
diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c index 108f0cd49f4e..96adb730b744 100644 --- a/tools/perf/tests/dwarf-unwind.c +++ b/tools/perf/tests/dwarf-unwind.c | |||
@@ -15,7 +15,7 @@ static int mmap_handler(struct perf_tool *tool __maybe_unused, | |||
15 | struct perf_sample *sample __maybe_unused, | 15 | struct perf_sample *sample __maybe_unused, |
16 | struct machine *machine) | 16 | struct machine *machine) |
17 | { | 17 | { |
18 | return machine__process_mmap_event(machine, event, NULL); | 18 | return machine__process_mmap2_event(machine, event, NULL); |
19 | } | 19 | } |
20 | 20 | ||
21 | static int init_live_machine(struct machine *machine) | 21 | static int init_live_machine(struct machine *machine) |
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index ce43cbae3bd5..d0281bdfa582 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -179,13 +179,14 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool, | |||
179 | return -1; | 179 | return -1; |
180 | } | 180 | } |
181 | 181 | ||
182 | event->header.type = PERF_RECORD_MMAP; | 182 | event->header.type = PERF_RECORD_MMAP2; |
183 | 183 | ||
184 | while (1) { | 184 | while (1) { |
185 | char bf[BUFSIZ]; | 185 | char bf[BUFSIZ]; |
186 | char prot[5]; | 186 | char prot[5]; |
187 | char execname[PATH_MAX]; | 187 | char execname[PATH_MAX]; |
188 | char anonstr[] = "//anon"; | 188 | char anonstr[] = "//anon"; |
189 | unsigned int ino; | ||
189 | size_t size; | 190 | size_t size; |
190 | ssize_t n; | 191 | ssize_t n; |
191 | 192 | ||
@@ -196,15 +197,20 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool, | |||
196 | strcpy(execname, ""); | 197 | strcpy(execname, ""); |
197 | 198 | ||
198 | /* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */ | 199 | /* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */ |
199 | n = sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %*x:%*x %*u %s\n", | 200 | n = sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %x:%x %u %s\n", |
200 | &event->mmap.start, &event->mmap.len, prot, | 201 | &event->mmap2.start, &event->mmap2.len, prot, |
201 | &event->mmap.pgoff, | 202 | &event->mmap2.pgoff, &event->mmap2.maj, |
202 | execname); | 203 | &event->mmap2.min, |
204 | &ino, execname); | ||
205 | |||
203 | /* | 206 | /* |
204 | * Anon maps don't have the execname. | 207 | * Anon maps don't have the execname. |
205 | */ | 208 | */ |
206 | if (n < 4) | 209 | if (n < 7) |
207 | continue; | 210 | continue; |
211 | |||
212 | event->mmap2.ino = (u64)ino; | ||
213 | |||
208 | /* | 214 | /* |
209 | * Just like the kernel, see __perf_event_mmap in kernel/perf_event.c | 215 | * Just like the kernel, see __perf_event_mmap in kernel/perf_event.c |
210 | */ | 216 | */ |
@@ -239,15 +245,15 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool, | |||
239 | strcpy(execname, anonstr); | 245 | strcpy(execname, anonstr); |
240 | 246 | ||
241 | size = strlen(execname) + 1; | 247 | size = strlen(execname) + 1; |
242 | memcpy(event->mmap.filename, execname, size); | 248 | memcpy(event->mmap2.filename, execname, size); |
243 | size = PERF_ALIGN(size, sizeof(u64)); | 249 | size = PERF_ALIGN(size, sizeof(u64)); |
244 | event->mmap.len -= event->mmap.start; | 250 | event->mmap2.len -= event->mmap.start; |
245 | event->mmap.header.size = (sizeof(event->mmap) - | 251 | event->mmap2.header.size = (sizeof(event->mmap2) - |
246 | (sizeof(event->mmap.filename) - size)); | 252 | (sizeof(event->mmap2.filename) - size)); |
247 | memset(event->mmap.filename + size, 0, machine->id_hdr_size); | 253 | memset(event->mmap2.filename + size, 0, machine->id_hdr_size); |
248 | event->mmap.header.size += machine->id_hdr_size; | 254 | event->mmap2.header.size += machine->id_hdr_size; |
249 | event->mmap.pid = tgid; | 255 | event->mmap2.pid = tgid; |
250 | event->mmap.tid = pid; | 256 | event->mmap2.tid = pid; |
251 | 257 | ||
252 | if (process(tool, event, &synth_sample, machine) != 0) { | 258 | if (process(tool, event, &synth_sample, machine) != 0) { |
253 | rc = -1; | 259 | rc = -1; |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 5c28d82b76c4..21154dabc5fa 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -659,6 +659,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) | |||
659 | perf_evsel__set_sample_bit(evsel, WEIGHT); | 659 | perf_evsel__set_sample_bit(evsel, WEIGHT); |
660 | 660 | ||
661 | attr->mmap = track; | 661 | attr->mmap = track; |
662 | attr->mmap2 = track && !perf_missing_features.mmap2; | ||
662 | attr->comm = track; | 663 | attr->comm = track; |
663 | 664 | ||
664 | if (opts->sample_transaction) | 665 | if (opts->sample_transaction) |