linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] perf report: Recognize hugetlb mapping as anon mapping
@ 2016-09-02 13:59 Wang Nan
  2016-09-02 13:59 ` [PATCH 1/3] perf tools: " Wang Nan
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Wang Nan @ 2016-09-02 13:59 UTC (permalink / raw)
  To: acme
  Cc: linux-kernel, lizefan, Wang Nan, Hou Pengyang, He Kuang,
	Arnaldo Carvalho de Melo

The requirement of this function is first proposed at 2015.
Please refer to

http://lkml.iu.edu/hypermail/linux/kernel/1506.2/02372.html
http://lkml.iu.edu/hypermail/linux/kernel/1506.3/02290.html
http://lkml.iu.edu/hypermail/linux/kernel/1506.3/03512.html

For systems which use hugetlbfs, if a sample is captured inside
hugetlbfs, perf should not resolve symbols from the file shown in
/prof/<pid>/mmap, because 'files' in hugetlbfs are constructed
during execution and not ELF files. If user knows positions of
symbols, he/she should provide /tmp/perf-<pid>.map file.

This 3 patches makes perf recognize hugetlbfs mapping as anon mapping.
Before this 3 patches user has no chance to use his/her own .map file
to resolve symbols because perf tries to use hugetlbfs file.

Wang Nan (3):
  perf tools: Recognize hugetlb mapping as anon mapping
  tools lib api fs: Add hugetlbfs filesystem detector
  perf record: Mark MAP_HUGETLB during synthesizing mmap events

 tools/lib/api/fs/fs.c   | 15 +++++++++++++++
 tools/lib/api/fs/fs.h   |  1 +
 tools/perf/util/event.c |  7 +++++++
 tools/perf/util/map.c   |  8 +++++---
 4 files changed, 28 insertions(+), 3 deletions(-)

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Hou Pengyang <houpengyang@huawei.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
-- 
1.8.3.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/3] perf tools: Recognize hugetlb mapping as anon mapping
  2016-09-02 13:59 [PATCH 0/3] perf report: Recognize hugetlb mapping as anon mapping Wang Nan
@ 2016-09-02 13:59 ` Wang Nan
  2016-09-03 15:55   ` Nilay Vaish
  2016-09-02 13:59 ` [PATCH 2/3] tools lib api fs: Add hugetlbfs filesystem detector Wang Nan
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Wang Nan @ 2016-09-02 13:59 UTC (permalink / raw)
  To: acme
  Cc: linux-kernel, lizefan, Wang Nan, Hou Pengyang, He Kuang,
	Arnaldo Carvalho de Melo

Hugetlbfs mapping should be recognized as anon mapping so user has
a chance to create /tmp/perf-<pid>.map file for symbol resolving. This
patch utilizes MAP_HUGETLB to identify hugetlb mapping.

After this patch, if perf is started before the program uses huge pages
starting, perf is able to recognize hugetlb mapping as anon mapping.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/map.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 728129a..a42010d 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -6,6 +6,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <sys/mman.h>
 #include "map.h"
 #include "thread.h"
 #include "strlist.h"
@@ -24,9 +25,10 @@ const char *map_type__name[MAP__NR_TYPES] = {
 	[MAP__VARIABLE] = "Variables",
 };
 
-static inline int is_anon_memory(const char *filename)
+static inline int is_anon_memory(const char *filename, u32 flags)
 {
-	return !strcmp(filename, "//anon") ||
+	return flags & MAP_HUGETLB ||
+	       !strcmp(filename, "//anon") ||
 	       !strncmp(filename, "/dev/zero", sizeof("/dev/zero") - 1) ||
 	       !strncmp(filename, "/anon_hugepage", sizeof("/anon_hugepage") - 1);
 }
@@ -155,7 +157,7 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
 		int anon, no_dso, vdso, android;
 
 		android = is_android_lib(filename);
-		anon = is_anon_memory(filename);
+		anon = is_anon_memory(filename, flags);
 		vdso = is_vdso_map(filename);
 		no_dso = is_no_dso_memory(filename);
 
-- 
1.8.3.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/3] tools lib api fs: Add hugetlbfs filesystem detector
  2016-09-02 13:59 [PATCH 0/3] perf report: Recognize hugetlb mapping as anon mapping Wang Nan
  2016-09-02 13:59 ` [PATCH 1/3] perf tools: " Wang Nan
@ 2016-09-02 13:59 ` Wang Nan
  2016-09-02 13:59 ` [PATCH 3/3] perf record: Mark MAP_HUGETLB during synthesizing mmap events Wang Nan
  2016-09-03 15:59 ` [PATCH 0/3] perf report: Recognize hugetlb mapping as anon mapping Nilay Vaish
  3 siblings, 0 replies; 9+ messages in thread
From: Wang Nan @ 2016-09-02 13:59 UTC (permalink / raw)
  To: acme
  Cc: linux-kernel, lizefan, Wang Nan, Hou Pengyang, He Kuang,
	Arnaldo Carvalho de Melo

Detect hugetlbfs. hugetlbfs__mountpoint() will be used during recording
to help recorder identifying hugetlb mmaps: which should be recognized
as anon mapping.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Hou Pengyang <houpengyang@huawei.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/api/fs/fs.c | 15 +++++++++++++++
 tools/lib/api/fs/fs.h |  1 +
 2 files changed, 16 insertions(+)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index ba7094b..f99f49e4 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -34,6 +34,10 @@
 #define TRACEFS_MAGIC          0x74726163
 #endif
 
+#ifndef HUGETLBFS_MAGIC
+#define HUGETLBFS_MAGIC        0x958458f6
+#endif
+
 static const char * const sysfs__fs_known_mountpoints[] = {
 	"/sys",
 	0,
@@ -67,6 +71,10 @@ static const char * const tracefs__known_mountpoints[] = {
 	0,
 };
 
+static const char * const hugetlbfs__known_mountpoints[] = {
+	0,
+};
+
 struct fs {
 	const char		*name;
 	const char * const	*mounts;
@@ -80,6 +88,7 @@ enum {
 	FS__PROCFS  = 1,
 	FS__DEBUGFS = 2,
 	FS__TRACEFS = 3,
+	FS__HUGETLBFS = 4,
 };
 
 #ifndef TRACEFS_MAGIC
@@ -107,6 +116,11 @@ static struct fs fs__entries[] = {
 		.mounts	= tracefs__known_mountpoints,
 		.magic	= TRACEFS_MAGIC,
 	},
+	[FS__HUGETLBFS] = {
+		.name	= "hugetlbfs",
+		.mounts = hugetlbfs__known_mountpoints,
+		.magic	= HUGETLBFS_MAGIC,
+	},
 };
 
 static bool fs__read_mounts(struct fs *fs)
@@ -265,6 +279,7 @@ FS(sysfs,   FS__SYSFS);
 FS(procfs,  FS__PROCFS);
 FS(debugfs, FS__DEBUGFS);
 FS(tracefs, FS__TRACEFS);
+FS(hugetlbfs, FS__HUGETLBFS);
 
 int filename__read_int(const char *filename, int *value)
 {
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index 16c9c2e..a63269f 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -21,6 +21,7 @@ FS(sysfs)
 FS(procfs)
 FS(debugfs)
 FS(tracefs)
+FS(hugetlbfs)
 
 #undef FS
 
-- 
1.8.3.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/3] perf record: Mark MAP_HUGETLB during synthesizing mmap events
  2016-09-02 13:59 [PATCH 0/3] perf report: Recognize hugetlb mapping as anon mapping Wang Nan
  2016-09-02 13:59 ` [PATCH 1/3] perf tools: " Wang Nan
  2016-09-02 13:59 ` [PATCH 2/3] tools lib api fs: Add hugetlbfs filesystem detector Wang Nan
@ 2016-09-02 13:59 ` Wang Nan
  2016-09-03 15:59 ` [PATCH 0/3] perf report: Recognize hugetlb mapping as anon mapping Nilay Vaish
  3 siblings, 0 replies; 9+ messages in thread
From: Wang Nan @ 2016-09-02 13:59 UTC (permalink / raw)
  To: acme
  Cc: linux-kernel, lizefan, Wang Nan, Hou Pengyang, He Kuang,
	Arnaldo Carvalho de Melo

During synthesizing mmap events, add MAP_HUGETLB map flag if the
source of mapping is file in hugetlbfs.

After this patch, perf can identify hugetlb mapping even if perf
is started after the mapping of huge pages (like perf top).

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Hou Pengyang <houpengyang@huawei.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/event.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index e20438b..4c2abdf 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1,5 +1,6 @@
 #include <linux/types.h>
 #include <sys/mman.h>
+#include <api/fs/fs.h>
 #include "event.h"
 #include "debug.h"
 #include "hist.h"
@@ -248,6 +249,8 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
 	bool truncation = false;
 	unsigned long long timeout = proc_map_timeout * 1000000ULL;
 	int rc = 0;
+	const char *hugetlbfs_mnt = hugetlbfs__mountpoint();
+	int hugetlbfs_mnt_len = hugetlbfs_mnt ? strlen(hugetlbfs_mnt) : 0;
 
 	if (machine__is_default_guest(machine))
 		return 0;
@@ -342,6 +345,10 @@ out:
 
 		if (!strcmp(execname, ""))
 			strcpy(execname, anonstr);
+		if (!strncmp(execname, hugetlbfs_mnt, hugetlbfs_mnt_len)) {
+			strcpy(execname, anonstr);
+			event->mmap2.flags |= MAP_HUGETLB;
+		}
 
 		size = strlen(execname) + 1;
 		memcpy(event->mmap2.filename, execname, size);
-- 
1.8.3.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] perf tools: Recognize hugetlb mapping as anon mapping
  2016-09-02 13:59 ` [PATCH 1/3] perf tools: " Wang Nan
@ 2016-09-03 15:55   ` Nilay Vaish
  2016-09-04  5:04     ` [PATCH 1/3 (fix commit message)] " Wang Nan
  0 siblings, 1 reply; 9+ messages in thread
From: Nilay Vaish @ 2016-09-03 15:55 UTC (permalink / raw)
  To: Wang Nan
  Cc: Arnaldo Carvalho de Melo, Linux Kernel list, lizefan,
	Hou Pengyang, He Kuang, Arnaldo Carvalho de Melo

On 2 September 2016 at 08:59, Wang Nan <wangnan0@huawei.com> wrote:
> Hugetlbfs mapping should be recognized as anon mapping so user has
> a chance to create /tmp/perf-<pid>.map file for symbol resolving. This
> patch utilizes MAP_HUGETLB to identify hugetlb mapping.
>
> After this patch, if perf is started before the program uses huge pages
> starting, perf is able to recognize hugetlb mapping as anon mapping.

Wang, everything in the patch series looks good to me.  Just a slight
change that I would suggest for the summary above:  replace "program
uses huge pages starting" with "program starts using huge pages".

--
Nilay

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] perf report: Recognize hugetlb mapping as anon mapping
  2016-09-02 13:59 [PATCH 0/3] perf report: Recognize hugetlb mapping as anon mapping Wang Nan
                   ` (2 preceding siblings ...)
  2016-09-02 13:59 ` [PATCH 3/3] perf record: Mark MAP_HUGETLB during synthesizing mmap events Wang Nan
@ 2016-09-03 15:59 ` Nilay Vaish
  3 siblings, 0 replies; 9+ messages in thread
From: Nilay Vaish @ 2016-09-03 15:59 UTC (permalink / raw)
  To: Wang Nan
  Cc: Arnaldo Carvalho de Melo, Linux Kernel list, lizefan,
	Hou Pengyang, He Kuang, Arnaldo Carvalho de Melo

On 2 September 2016 at 08:59, Wang Nan <wangnan0@huawei.com> wrote:
> The requirement of this function is first proposed at 2015.
> Please refer to
>
> http://lkml.iu.edu/hypermail/linux/kernel/1506.2/02372.html
> http://lkml.iu.edu/hypermail/linux/kernel/1506.3/02290.html
> http://lkml.iu.edu/hypermail/linux/kernel/1506.3/03512.html
>
> For systems which use hugetlbfs, if a sample is captured inside
> hugetlbfs, perf should not resolve symbols from the file shown in
> /prof/<pid>/mmap, because 'files' in hugetlbfs are constructed
> during execution and not ELF files. If user knows positions of
> symbols, he/she should provide /tmp/perf-<pid>.map file.
>
> This 3 patches makes perf recognize hugetlbfs mapping as anon mapping.
> Before this 3 patches user has no chance to use his/her own .map file
> to resolve symbols because perf tries to use hugetlbfs file.
>
> Wang Nan (3):
>   perf tools: Recognize hugetlb mapping as anon mapping
>   tools lib api fs: Add hugetlbfs filesystem detector
>   perf record: Mark MAP_HUGETLB during synthesizing mmap events
>
>  tools/lib/api/fs/fs.c   | 15 +++++++++++++++
>  tools/lib/api/fs/fs.h   |  1 +
>  tools/perf/util/event.c |  7 +++++++
>  tools/perf/util/map.c   |  8 +++++---
>  4 files changed, 28 insertions(+), 3 deletions(-)
>
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Cc: Hou Pengyang <houpengyang@huawei.com>
> Cc: He Kuang <hekuang@huawei.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>


Reviewed-by: Nilay Vaish <nilayvaish@gmail.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/3 (fix commit message)] perf tools: Recognize hugetlb mapping as anon mapping
  2016-09-03 15:55   ` Nilay Vaish
@ 2016-09-04  5:04     ` Wang Nan
  2016-09-05 19:18       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 9+ messages in thread
From: Wang Nan @ 2016-09-04  5:04 UTC (permalink / raw)
  To: nilayvaish, acme
  Cc: linux-kernel, lizefan, Wang Nan, Hou Pengyang, He Kuang,
	Arnaldo Carvalho de Melo

Hugetlbfs mapping should be recognized as anon mapping so user has
a chance to create /tmp/perf-<pid>.map file for symbol resolving. This
patch utilizes MAP_HUGETLB to identify hugetlb mapping.

After this patch, if perf is started before the program starts using
huge pages (so perf gets MMAP2 events from kernel), perf is able to
recognize hugetlb mapping as anon mapping.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Nilay Vaish <nilayvaish@gmail.com>
---
 tools/perf/util/map.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 728129a..a42010d 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -6,6 +6,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <sys/mman.h>
 #include "map.h"
 #include "thread.h"
 #include "strlist.h"
@@ -24,9 +25,10 @@ const char *map_type__name[MAP__NR_TYPES] = {
 	[MAP__VARIABLE] = "Variables",
 };
 
-static inline int is_anon_memory(const char *filename)
+static inline int is_anon_memory(const char *filename, u32 flags)
 {
-	return !strcmp(filename, "//anon") ||
+	return flags & MAP_HUGETLB ||
+	       !strcmp(filename, "//anon") ||
 	       !strncmp(filename, "/dev/zero", sizeof("/dev/zero") - 1) ||
 	       !strncmp(filename, "/anon_hugepage", sizeof("/anon_hugepage") - 1);
 }
@@ -155,7 +157,7 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
 		int anon, no_dso, vdso, android;
 
 		android = is_android_lib(filename);
-		anon = is_anon_memory(filename);
+		anon = is_anon_memory(filename, flags);
 		vdso = is_vdso_map(filename);
 		no_dso = is_no_dso_memory(filename);
 
-- 
1.8.3.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3 (fix commit message)] perf tools: Recognize hugetlb mapping as anon mapping
  2016-09-04  5:04     ` [PATCH 1/3 (fix commit message)] " Wang Nan
@ 2016-09-05 19:18       ` Arnaldo Carvalho de Melo
  2016-09-06  1:22         ` Wangnan (F)
  0 siblings, 1 reply; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-09-05 19:18 UTC (permalink / raw)
  To: Wang Nan
  Cc: nilayvaish, linux-kernel, lizefan, Hou Pengyang, He Kuang,
	Arnaldo Carvalho de Melo

Em Sun, Sep 04, 2016 at 05:04:38AM +0000, Wang Nan escreveu:
> Hugetlbfs mapping should be recognized as anon mapping so user has
> a chance to create /tmp/perf-<pid>.map file for symbol resolving. This
> patch utilizes MAP_HUGETLB to identify hugetlb mapping.
> 
> After this patch, if perf is started before the program starts using
> huge pages (so perf gets MMAP2 events from kernel), perf is able to
> recognize hugetlb mapping as anon mapping.

Fixing build on older distros (Centos5, Ubuntu 12.04.5, etc)


  CC       /tmp/build/perf/arch/x86/util/perf_regs.o
util/event.c: In function 'perf_event__synthesize_mmap_events':
util/event.c:350: error: 'MAP_HUGETLB' undeclared (first use in this function)
util/event.c:350: error: (Each undeclared identifier is reported only once
util/event.c:350: error: for each function it appears in.)

 
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
> Cc: He Kuang <hekuang@huawei.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Nilay Vaish <nilayvaish@gmail.com>
> ---
>  tools/perf/util/map.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
> index 728129a..a42010d 100644
> --- a/tools/perf/util/map.c
> +++ b/tools/perf/util/map.c
> @@ -6,6 +6,7 @@
>  #include <string.h>
>  #include <stdio.h>
>  #include <unistd.h>
> +#include <sys/mman.h>
>  #include "map.h"
>  #include "thread.h"
>  #include "strlist.h"
> @@ -24,9 +25,10 @@ const char *map_type__name[MAP__NR_TYPES] = {
>  	[MAP__VARIABLE] = "Variables",
>  };
>  
> -static inline int is_anon_memory(const char *filename)
> +static inline int is_anon_memory(const char *filename, u32 flags)
>  {
> -	return !strcmp(filename, "//anon") ||
> +	return flags & MAP_HUGETLB ||
> +	       !strcmp(filename, "//anon") ||
>  	       !strncmp(filename, "/dev/zero", sizeof("/dev/zero") - 1) ||
>  	       !strncmp(filename, "/anon_hugepage", sizeof("/anon_hugepage") - 1);
>  }
> @@ -155,7 +157,7 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
>  		int anon, no_dso, vdso, android;
>  
>  		android = is_android_lib(filename);
> -		anon = is_anon_memory(filename);
> +		anon = is_anon_memory(filename, flags);
>  		vdso = is_vdso_map(filename);
>  		no_dso = is_no_dso_memory(filename);
>  
> -- 
> 1.8.3.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3 (fix commit message)] perf tools: Recognize hugetlb mapping as anon mapping
  2016-09-05 19:18       ` Arnaldo Carvalho de Melo
@ 2016-09-06  1:22         ` Wangnan (F)
  0 siblings, 0 replies; 9+ messages in thread
From: Wangnan (F) @ 2016-09-06  1:22 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: nilayvaish, linux-kernel, lizefan, Hou Pengyang, He Kuang,
	Arnaldo Carvalho de Melo



On 2016/9/6 3:18, Arnaldo Carvalho de Melo wrote:
> Em Sun, Sep 04, 2016 at 05:04:38AM +0000, Wang Nan escreveu:
>> Hugetlbfs mapping should be recognized as anon mapping so user has
>> a chance to create /tmp/perf-<pid>.map file for symbol resolving. This
>> patch utilizes MAP_HUGETLB to identify hugetlb mapping.
>>
>> After this patch, if perf is started before the program starts using
>> huge pages (so perf gets MMAP2 events from kernel), perf is able to
>> recognize hugetlb mapping as anon mapping.
> Fixing build on older distros (Centos5, Ubuntu 12.04.5, etc)
>
>
>    CC       /tmp/build/perf/arch/x86/util/perf_regs.o
> util/event.c: In function 'perf_event__synthesize_mmap_events':
> util/event.c:350: error: 'MAP_HUGETLB' undeclared (first use in this function)
> util/event.c:350: error: (Each undeclared identifier is reported only once
> util/event.c:350: error: for each function it appears in.)
>
>   

Fixing MAP_HUGETLB is not as easy as it seems to be. Its value
is different in each arch:

./arch/powerpc/include/uapi/asm/mman.h:#define MAP_HUGETLB 0x40000    
     /* create a huge page mapping */
./arch/alpha/include/uapi/asm/mman.h:#define MAP_HUGETLB 0x100000    /* 
create a huge page mapping */
./arch/xtensa/include/uapi/asm/mman.h:#define MAP_HUGETLB 0x80000        
/* create a huge page mapping */
./arch/tile/include/uapi/asm/mman.h:#define MAP_HUGETLB    0x4000     /* 
create a huge page mapping */
./arch/parisc/include/uapi/asm/mman.h:#define MAP_HUGETLB 0x80000        
/* create a huge page mapping */
./arch/sparc/include/uapi/asm/mman.h:#define MAP_HUGETLB 0x40000        
/* create a huge page mapping */
./arch/mips/include/uapi/asm/mman.h:#define MAP_HUGETLB 0x80000        
/* create a huge page mapping */
./include/uapi/asm-generic/mman.h:#define MAP_HUGETLB    0x40000     /* 
create a huge page mapping */

So we need to introduce another header into tools for this macro. Sigh...

Thank you.

>> Signed-off-by: Wang Nan <wangnan0@huawei.com>
>> Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
>> Cc: He Kuang <hekuang@huawei.com>
>> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
>> Cc: Nilay Vaish <nilayvaish@gmail.com>
>> ---
>>   tools/perf/util/map.c | 8 +++++---
>>   1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
>> index 728129a..a42010d 100644
>> --- a/tools/perf/util/map.c
>> +++ b/tools/perf/util/map.c
>> @@ -6,6 +6,7 @@
>>   #include <string.h>
>>   #include <stdio.h>
>>   #include <unistd.h>
>> +#include <sys/mman.h>
>>   #include "map.h"
>>   #include "thread.h"
>>   #include "strlist.h"
>> @@ -24,9 +25,10 @@ const char *map_type__name[MAP__NR_TYPES] = {
>>   	[MAP__VARIABLE] = "Variables",
>>   };
>>   
>> -static inline int is_anon_memory(const char *filename)
>> +static inline int is_anon_memory(const char *filename, u32 flags)
>>   {
>> -	return !strcmp(filename, "//anon") ||
>> +	return flags & MAP_HUGETLB ||
>> +	       !strcmp(filename, "//anon") ||
>>   	       !strncmp(filename, "/dev/zero", sizeof("/dev/zero") - 1) ||
>>   	       !strncmp(filename, "/anon_hugepage", sizeof("/anon_hugepage") - 1);
>>   }
>> @@ -155,7 +157,7 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
>>   		int anon, no_dso, vdso, android;
>>   
>>   		android = is_android_lib(filename);
>> -		anon = is_anon_memory(filename);
>> +		anon = is_anon_memory(filename, flags);
>>   		vdso = is_vdso_map(filename);
>>   		no_dso = is_no_dso_memory(filename);
>>   
>> -- 
>> 1.8.3.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-09-06  1:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-02 13:59 [PATCH 0/3] perf report: Recognize hugetlb mapping as anon mapping Wang Nan
2016-09-02 13:59 ` [PATCH 1/3] perf tools: " Wang Nan
2016-09-03 15:55   ` Nilay Vaish
2016-09-04  5:04     ` [PATCH 1/3 (fix commit message)] " Wang Nan
2016-09-05 19:18       ` Arnaldo Carvalho de Melo
2016-09-06  1:22         ` Wangnan (F)
2016-09-02 13:59 ` [PATCH 2/3] tools lib api fs: Add hugetlbfs filesystem detector Wang Nan
2016-09-02 13:59 ` [PATCH 3/3] perf record: Mark MAP_HUGETLB during synthesizing mmap events Wang Nan
2016-09-03 15:59 ` [PATCH 0/3] perf report: Recognize hugetlb mapping as anon mapping Nilay Vaish

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).