All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH igt 2/2] lib: Cache the debugfs mountpoint
Date: Mon, 19 Feb 2018 22:18:07 +0000	[thread overview]
Message-ID: <20180219221807.18842-2-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20180219221807.18842-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

  reply	other threads:[~2018-02-19 22:18 UTC|newest]

Thread overview: 7+ 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 ` Chris Wilson [this message]
2018-02-20  8:52   ` [PATCH igt 2/2] lib: Cache the debugfs mountpoint Joonas Lahtinen
2018-02-19 23:01 ` ✓ Fi.CI.BAT: success for series starting with [1/2] igt/gem_sync: Exercise and measure idle requests Patchwork
2018-02-20  2:10 ` ✗ Fi.CI.IGT: warning " Patchwork
2018-02-20  8:51 ` [PATCH igt 1/2] " Joonas Lahtinen
2018-02-19 22:18 Chris Wilson
2018-02-19 22:18 ` [PATCH igt 2/2] lib: Cache the debugfs mountpoint Chris Wilson

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=20180219221807.18842-2-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --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: link
Be 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.