[PATCH 02/16] perf tools: Fix MMAP event synthesis broken by MAP_HUGETLB change

From: Adrian Hunter
Date: Fri Sep 23 2016 - 10:43:39 EST


Patch "perf record: Mark MAP_HUGETLB when synthesizing mmap events") breaks
MMAP event synthesis. The executable name comparison will match any name
if the length is zero, resulting in all the user space maps becoming
anonymous. This is particularly noticeable with system-wide traces.
Example:

perf record -a sleep 1
perf script --show-mmap-events

Signed-off-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>
---
tools/perf/util/event.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 2880e2226fdb..8ab0d7da956b 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -346,7 +346,8 @@ out:
if (!strcmp(execname, ""))
strcpy(execname, anonstr);

- if (!strncmp(execname, hugetlbfs_mnt, hugetlbfs_mnt_len)) {
+ if (hugetlbfs_mnt_len &&
+ !strncmp(execname, hugetlbfs_mnt, hugetlbfs_mnt_len)) {
strcpy(execname, anonstr);
event->mmap2.flags |= MAP_HUGETLB;
}
--
1.9.1