qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@gmail.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 3/3] trace: Try using tracefs first
Date: Wed,  8 Nov 2017 00:31:36 +0900	[thread overview]
Message-ID: <20171107153136.19426-3-namhyung@gmail.com> (raw)
In-Reply-To: <20171107153136.19426-1-namhyung@gmail.com>

Recent Linux kernel provides separate tracefs which doesn't need to be
mounted on the debugfs.  Although most systems mount it at the
traditional place on the debugfs, it'd be safer to check tracefs first.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 trace/ftrace.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/trace/ftrace.c b/trace/ftrace.c
index 213cb2205f..61692a8682 100644
--- a/trace/ftrace.c
+++ b/trace/ftrace.c
@@ -42,12 +42,18 @@ bool ftrace_init(void)
 {
     char mount_point[PATH_MAX];
     char path[PATH_MAX];
-    int debugfs_found;
+    int tracefs_found;
     int trace_fd = -1;
+    const char *subdir = "";
 
-    debugfs_found = find_mount(mount_point, "debugfs");
-    if (debugfs_found) {
-        snprintf(path, PATH_MAX, "%s/tracing/tracing_on", mount_point);
+    tracefs_found = find_mount(mount_point, "tracefs");
+    if (!tracefs_found) {
+        tracefs_found = find_mount(mount_point, "debugfs");
+        subdir = "/tracing";
+    }
+
+    if (tracefs_found) {
+        snprintf(path, PATH_MAX, "%s%s/tracing_on", mount_point, subdir);
         trace_fd = open(path, O_WRONLY);
         if (trace_fd < 0) {
             if (errno == EACCES) {
@@ -66,14 +72,14 @@ bool ftrace_init(void)
             }
             close(trace_fd);
         }
-        snprintf(path, PATH_MAX, "%s/tracing/trace_marker", mount_point);
+        snprintf(path, PATH_MAX, "%s%s/trace_marker", mount_point, subdir);
         trace_marker_fd = open(path, O_WRONLY);
         if (trace_marker_fd < 0) {
             perror("Could not open ftrace 'trace_marker' file");
             return false;
         }
     } else {
-        fprintf(stderr, "debugfs is not mounted\n");
+        fprintf(stderr, "tracefs is not mounted\n");
         return false;
     }
 
-- 
2.14.3

  parent reply	other threads:[~2017-11-07 15:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07 15:31 [Qemu-devel] [PATCH 1/3] trace: Simplify find_debugfs() Namhyung Kim
2017-11-07 15:31 ` [Qemu-devel] [PATCH 2/3] trace: Generalize searching for debugfs Namhyung Kim
2017-11-07 15:31 ` Namhyung Kim [this message]
2017-11-09 10:42 ` [Qemu-devel] [PATCH 1/3] trace: Simplify find_debugfs() Stefan Hajnoczi
2017-11-09 14:35   ` Namhyung Kim

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=20171107153136.19426-3-namhyung@gmail.com \
    --to=namhyung@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).