diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2018-02-19 22:14:33 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2018-02-20 08:56:45 +0000 |
commit | d7c14aa2d74475f9de9eccf350df204da8f10442 (patch) | |
tree | 6f96a4098000efe3073ec5a3339b1e57d4aea02b | |
parent | 20a156f4d8afc6776a4e0d9198c3e6cb2545d710 (diff) |
lib: Cache the debugfs mountpoint
When using igt_debugfs_*() inside a tight loop, the overhead of calling
xstat64 (from is_mountpoint()) creeps up in the profiles. Eliminate it
by caching the resultant path for finding/mounting debugfs.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
-rw-r--r-- | lib/igt_debugfs.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c index 4a119985..09d42ea0 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -110,6 +110,20 @@ static bool is_mountpoint(const char *path) return dev != st.st_dev; } +static const char *__igt_debugfs_mount(void) +{ + if (is_mountpoint("/sys/kernel/debug")) + return "/sys/kernel/debug"; + + if (is_mountpoint("/debug")) + return "/debug"; + + if (mount("debug", "/sys/kernel/debug", "debugfs", 0, 0)) + return NULL; + + return "/sys/kernel/debug"; +} + /** * igt_debugfs_mount: * @@ -121,16 +135,12 @@ static bool is_mountpoint(const char *path) */ const char *igt_debugfs_mount(void) { - if (is_mountpoint("/sys/kernel/debug")) - return "/sys/kernel/debug"; + static const char *path; - if (is_mountpoint("/debug")) - return "/debug"; + if (!path) + path = __igt_debugfs_mount(); - if (mount("debug", "/sys/kernel/debug", "debugfs", 0, 0)) - return NULL; - - return "/sys/kernel/debug"; + return path; } /** |