Skip to content

Commit b5a6325

Browse files
Dave Martinacmel
authored andcommitted
perf events: Fix mmap offset determination
Fix buggy-looking code which unnecessarily adjusts the file offset fields read from /proc/*/maps. This may have gone unnoticed since the offset is usually 0 (and the logic in util/symbol.c may work incorrectly for other offset values). Commiter note: This fixes a bug introduced in 4af8b35, there is no need to shift pgoff twice, the show_map_vma routine in fs/proc/task_mmu.c already converts it from the number of pages to the size in bytes, and that is what appears in /proc/PID/map. Cc: Nicolas Pitre <nicolas.pitre@linaro.org> Cc: Will Deacon <Will.Deacon@arm.com> LKML-Reference: <1280836116-6654-2-git-send-email-dave.martin@linaro.org> Signed-off-by: Dave Martin <dave.martin@linaro.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 12a81c8 commit b5a6325

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

‎tools/perf/util/event.c‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid,
151151
continue;
152152
pbf += n + 3;
153153
if (*pbf == 'x') { /* vm_exec */
154-
u64 vm_pgoff;
155154
char *execname = strchr(bf, '/');
156155

157156
/* Catch VDSO */
@@ -162,12 +161,7 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid,
162161
continue;
163162

164163
pbf += 3;
165-
n = hex2u64(pbf, &vm_pgoff);
166-
/* pgoff is in bytes, not pages */
167-
if (n >= 0)
168-
ev.mmap.pgoff = vm_pgoff << getpagesize();
169-
else
170-
ev.mmap.pgoff = 0;
164+
n = hex2u64(pbf, &ev.mmap.pgoff);
171165

172166
size = strlen(execname);
173167
execname[size - 1] = '\0'; /* Remove \n */

0 commit comments

Comments
 (0)