diff options
| author | Wang Nan <wangnan0@huawei.com> | 2016-09-06 00:58:28 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-09-08 11:34:43 -0400 |
| commit | 5e7be3e1f9d71ed03fac27df25e143815be662d2 (patch) | |
| tree | 8a6292fead423d86f694a18bc2cde680b3d305aa /tools/lib | |
| parent | 0ac3348e502423cf2fe86beca83b8835a2e6d289 (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')
| -rw-r--r-- | tools/lib/api/fs/fs.c | 15 | ||||
| -rw-r--r-- | tools/lib/api/fs/fs.h | 1 |
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 | |||
| 37 | static const char * const sysfs__fs_known_mountpoints[] = { | 41 | static 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 | ||
| 74 | static const char * const hugetlbfs__known_mountpoints[] = { | ||
| 75 | 0, | ||
| 76 | }; | ||
| 77 | |||
| 70 | struct fs { | 78 | struct 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 | ||
| 112 | static bool fs__read_mounts(struct fs *fs) | 126 | static bool fs__read_mounts(struct fs *fs) |
| @@ -265,6 +279,7 @@ FS(sysfs, FS__SYSFS); | |||
| 265 | FS(procfs, FS__PROCFS); | 279 | FS(procfs, FS__PROCFS); |
| 266 | FS(debugfs, FS__DEBUGFS); | 280 | FS(debugfs, FS__DEBUGFS); |
| 267 | FS(tracefs, FS__TRACEFS); | 281 | FS(tracefs, FS__TRACEFS); |
| 282 | FS(hugetlbfs, FS__HUGETLBFS); | ||
| 268 | 283 | ||
| 269 | int filename__read_int(const char *filename, int *value) | 284 | int 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) | |||
| 21 | FS(procfs) | 21 | FS(procfs) |
| 22 | FS(debugfs) | 22 | FS(debugfs) |
| 23 | FS(tracefs) | 23 | FS(tracefs) |
| 24 | FS(hugetlbfs) | ||
| 24 | 25 | ||
| 25 | #undef FS | 26 | #undef FS |
| 26 | 27 | ||
