perf tools: Correctly identify anon_hugepage when generating map (v2)
authorYannick Brosseau <[email protected]>
Thu, 26 Nov 2015 11:42:32 +0000 (03:42 -0800)
committerArnaldo Carvalho de Melo <[email protected]>
Thu, 26 Nov 2015 17:08:17 +0000 (14:08 -0300)
When parsing /proc/xxx/maps, the sscanf in perf_event__synthesize_mmap_events
truncate the map name at the space in "/anon_hugepage (deleted)".

is_anon_memory() then only receives the string "/anon_hugepage" and does
not detect it.  We change is_anon_memory() to only compare the first
part of the string, effectively ignoring if " (deleted)" is there.

Signed-off-by: Yannick Brosseau <[email protected]>
Tested-by: Arnaldo Carvalho de Melo <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Joshua Zhu <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/util/map.c

index afc6b56cf749b687c297018dcae986fef977859c..93d9f1ce3baa4f1d2cdb2d26dfb15bdbe0771557 100644 (file)
@@ -26,8 +26,8 @@ const char *map_type__name[MAP__NR_TYPES] = {
 static inline int is_anon_memory(const char *filename)
 {
        return !strcmp(filename, "//anon") ||
-              !strcmp(filename, "/dev/zero (deleted)") ||
-              !strcmp(filename, "/anon_hugepage (deleted)");
+              !strncmp(filename, "/dev/zero", sizeof("/dev/zero") - 1) ||
+              !strncmp(filename, "/anon_hugepage", sizeof("/anon_hugepage") - 1);
 }
 
 static inline int is_no_dso_memory(const char *filename)