summaryrefslogtreecommitdiffstats
path: root/tools/lib/api
diff options
context:
space:
mode:
authorWang Nan <wangnan0@huawei.com>2016-09-06 00:58:28 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-09-08 11:34:43 -0400
commit5e7be3e1f9d71ed03fac27df25e143815be662d2 (patch)
tree8a6292fead423d86f694a18bc2cde680b3d305aa /tools/lib/api
parent0ac3348e502423cf2fe86beca83b8835a2e6d289 (diff)
tools lib api fs: Add hugetlbfs filesystem detector
Detect hugetlbfs. hugetlbfs__mountpoint() will be used during recording to help identifying hugetlb mmaps: which should be recognized as anon mapping. Signed-off-by: Wang Nan <wangnan0@huawei.com> Reviewed-by: Nilay Vaish <nilayvaish@gmail.com> Cc: He Kuang <hekuang@huawei.com> Cc: Hou Pengyang <houpengyang@huawei.com> Cc: Zefan Li <lizefan@huawei.com> Link: http://lkml.kernel.org/r/1473137909-142064-3-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/api')
-rw-r--r--tools/lib/api/fs/fs.c15
-rw-r--r--tools/lib/api/fs/fs.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index ba7094b945ff..f99f49e4a31e 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -34,6 +34,10 @@
34#define TRACEFS_MAGIC 0x74726163 34#define TRACEFS_MAGIC 0x74726163
35#endif 35#endif
36 36
37#ifndef HUGETLBFS_MAGIC
38#define HUGETLBFS_MAGIC 0x958458f6
39#endif
40
37static const char * const sysfs__fs_known_mountpoints[] = { 41static const char * const sysfs__fs_known_mountpoints[] = {
38 "/sys", 42 "/sys",
39 0, 43 0,
@@ -67,6 +71,10 @@ static const char * const tracefs__known_mountpoints[] = {
67 0, 71 0,
68}; 72};
69 73
74static const char * const hugetlbfs__known_mountpoints[] = {
75 0,
76};
77
70struct fs { 78struct fs {
71 const char *name; 79 const char *name;
72 const char * const *mounts; 80 const char * const *mounts;
@@ -80,6 +88,7 @@ enum {
80 FS__PROCFS = 1, 88 FS__PROCFS = 1,
81 FS__DEBUGFS = 2, 89 FS__DEBUGFS = 2,
82 FS__TRACEFS = 3, 90 FS__TRACEFS = 3,
91 FS__HUGETLBFS = 4,
83}; 92};
84 93
85#ifndef TRACEFS_MAGIC 94#ifndef TRACEFS_MAGIC
@@ -107,6 +116,11 @@ static struct fs fs__entries[] = {
107 .mounts = tracefs__known_mountpoints, 116 .mounts = tracefs__known_mountpoints,
108 .magic = TRACEFS_MAGIC, 117 .magic = TRACEFS_MAGIC,
109 }, 118 },
119 [FS__HUGETLBFS] = {
120 .name = "hugetlbfs",
121 .mounts = hugetlbfs__known_mountpoints,
122 .magic = HUGETLBFS_MAGIC,
123 },
110}; 124};
111 125
112static bool fs__read_mounts(struct fs *fs) 126static bool fs__read_mounts(struct fs *fs)
@@ -265,6 +279,7 @@ FS(sysfs, FS__SYSFS);
265FS(procfs, FS__PROCFS); 279FS(procfs, FS__PROCFS);
266FS(debugfs, FS__DEBUGFS); 280FS(debugfs, FS__DEBUGFS);
267FS(tracefs, FS__TRACEFS); 281FS(tracefs, FS__TRACEFS);
282FS(hugetlbfs, FS__HUGETLBFS);
268 283
269int filename__read_int(const char *filename, int *value) 284int filename__read_int(const char *filename, int *value)
270{ 285{
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index 16c9c2ed7c5b..a63269f5d20c 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -21,6 +21,7 @@ FS(sysfs)
21FS(procfs) 21FS(procfs)
22FS(debugfs) 22FS(debugfs)
23FS(tracefs) 23FS(tracefs)
24FS(hugetlbfs)
24 25
25#undef FS 26#undef FS
26 27