From: Chris Wilson <chris@chris-wilson.co.uk> To: intel-gfx@lists.freedesktop.org Cc: igt-dev@lists.freedesktop.org Subject: [PATCH igt 2/2] lib: Cache the debugfs mountpoint Date: Mon, 19 Feb 2018 22:18:20 +0000 [thread overview] Message-ID: <20180219221820.18898-2-chris@chris-wilson.co.uk> (raw) In-Reply-To: <20180219221820.18898-1-chris@chris-wilson.co.uk> 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> --- lib/igt_debugfs.c | 26 ++++++++++++++++++-------- 1 file 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; } /** -- 2.16.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
WARNING: multiple messages have this Message-ID (diff)
From: Chris Wilson <chris@chris-wilson.co.uk> To: intel-gfx@lists.freedesktop.org Cc: igt-dev@lists.freedesktop.org Subject: [igt-dev] [PATCH igt 2/2] lib: Cache the debugfs mountpoint Date: Mon, 19 Feb 2018 22:18:20 +0000 [thread overview] Message-ID: <20180219221820.18898-2-chris@chris-wilson.co.uk> (raw) In-Reply-To: <20180219221820.18898-1-chris@chris-wilson.co.uk> 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> --- lib/igt_debugfs.c | 26 ++++++++++++++++++-------- 1 file 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; } /** -- 2.16.1 _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2018-02-19 22:18 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-02-19 22:18 [PATCH igt 1/2] igt/gem_sync: Exercise and measure idle requests Chris Wilson 2018-02-19 22:18 ` [Intel-gfx] " Chris Wilson 2018-02-19 22:18 ` Chris Wilson [this message] 2018-02-19 22:18 ` [igt-dev] [PATCH igt 2/2] lib: Cache the debugfs mountpoint Chris Wilson 2018-02-19 23:18 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [1/2] igt/gem_sync: Exercise and measure idle requests Patchwork 2018-02-20 2:44 ` [igt-dev] ✗ Fi.CI.IGT: warning " Patchwork -- strict thread matches above, loose matches on Subject: below -- 2018-02-19 22:18 [PATCH igt 1/2] " Chris Wilson 2018-02-19 22:18 ` [PATCH igt 2/2] lib: Cache the debugfs mountpoint Chris Wilson 2018-02-20 8:52 ` Joonas Lahtinen
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20180219221820.18898-2-chris@chris-wilson.co.uk \ --to=chris@chris-wilson.co.uk \ --cc=igt-dev@lists.freedesktop.org \ --cc=intel-gfx@lists.freedesktop.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.