Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1228453 > unrolled thread

[PATCH] tools lib api fs: Store tracing mountpoint for better error message

Started byJiri Olsa <jolsa@kernel.org>
First post2015-09-19 16:50 +0200
Last post2015-09-19 17:30 +0200
Articles 5 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] tools lib api fs: Store tracing mountpoint for better error message Jiri Olsa <jolsa@kernel.org> - 2015-09-19 16:50 +0200
    Re: [PATCH] tools lib api fs: Store tracing mountpoint for better  error message David Ahern <dsahern@gmail.com> - 2015-09-19 17:00 +0200
      Re: [PATCH] tools lib api fs: Store tracing mountpoint for better  error message Jiri Olsa <jolsa@redhat.com> - 2015-09-19 17:10 +0200
        Re: [PATCH] tools lib api fs: Store tracing mountpoint for better  error message Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-19 17:30 +0200
    Re: [PATCH] tools lib api fs: Store tracing mountpoint for better  error message Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-19 17:30 +0200

#1228453 — [PATCH] tools lib api fs: Store tracing mountpoint for better error message

FromJiri Olsa <jolsa@kernel.org>
Date2015-09-19 16:50 +0200
Subject[PATCH] tools lib api fs: Store tracing mountpoint for better error message
Message-ID<qarCF-4ku-3@gated-at.bofh.it>
Storing the actual tracing path mountpoint to display correct
error message hint ('Hint:' line). The error hint rediscovers
mountpoints, but it could be different from what we actually
used in tracing path.

Before we'd display debugfs mount even though tracefs was used:
  $ perf record -e sched:sched_krava ls
  event syntax error: 'sched:sched_krava'
                       \___ can't access trace events

  Error:  No permissions to read /sys/kernel/debug/tracing/events/sched/sched_krava
  Hint:   Try 'sudo mount -o remount,mode=755 /sys/kernel/debug'
  ...

After this change, correct mountpoint is displayed:
  $ perf record -e sched:sched_krava ls
  event syntax error: 'sched:sched_krava'
                       \___ can't access trace events

  Error:  No permissions to read /sys/kernel/debug/tracing/events/sched/sched_krava
  Hint:   Try 'sudo mount -o remount,mode=755 /sys/kernel/debug/tracing'
  ...

Link: http://lkml.kernel.org/n/tip-xw7mf64ie0svh6m449vbyh0m@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/lib/api/fs/tracing_path.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
index 38aca2dd1946..0406a7d5c891 100644
--- a/tools/lib/api/fs/tracing_path.c
+++ b/tools/lib/api/fs/tracing_path.c
@@ -12,12 +12,14 @@
 #include "tracing_path.h"
 
 
+char tracing_mnt[PATH_MAX + 1]         = "/sys/kernel/debug";
 char tracing_path[PATH_MAX + 1]        = "/sys/kernel/debug/tracing";
 char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events";
 
 
 static void __tracing_path_set(const char *tracing, const char *mountpoint)
 {
+	snprintf(tracing_mnt, sizeof(tracing_mnt), "%s", mountpoint);
 	snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
 		 mountpoint, tracing);
 	snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
@@ -109,19 +111,10 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
 			 "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
 		break;
 	case EACCES: {
-		const char *mountpoint = debugfs__mountpoint();
-
-		if (!access(mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
-			const char *tracefs_mntpoint = tracefs__mountpoint();
-
-			if (tracefs_mntpoint)
-				mountpoint = tracefs__mountpoint();
-		}
-
 		snprintf(buf, size,
 			 "Error:\tNo permissions to read %s/%s\n"
 			 "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
-			 tracing_events_path, filename, mountpoint);
+			 tracing_events_path, filename, tracing_mnt);
 	}
 		break;
 	default:
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1228455 — Re: [PATCH] tools lib api fs: Store tracing mountpoint for better error message

FromDavid Ahern <dsahern@gmail.com>
Date2015-09-19 17:00 +0200
SubjectRe: [PATCH] tools lib api fs: Store tracing mountpoint for better error message
Message-ID<qarMm-4vU-9@gated-at.bofh.it>
In reply to#1228453
On 9/19/15 8:47 AM, Jiri Olsa wrote:

> diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
> index 38aca2dd1946..0406a7d5c891 100644
> --- a/tools/lib/api/fs/tracing_path.c
> +++ b/tools/lib/api/fs/tracing_path.c
> @@ -12,12 +12,14 @@
>   #include "tracing_path.h"
>
>
> +char tracing_mnt[PATH_MAX + 1]         = "/sys/kernel/debug";
>   char tracing_path[PATH_MAX + 1]        = "/sys/kernel/debug/tracing";
>   char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events";

why all the +1s? null terminator has to fit within PATH_MAX as well.

>
>
>   static void __tracing_path_set(const char *tracing, const char *mountpoint)
>   {
> +	snprintf(tracing_mnt, sizeof(tracing_mnt), "%s", mountpoint);
>   	snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
>   		 mountpoint, tracing);
>   	snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
> @@ -109,19 +111,10 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
>   			 "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
>   		break;
>   	case EACCES: {
> -		const char *mountpoint = debugfs__mountpoint();
> -
> -		if (!access(mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
> -			const char *tracefs_mntpoint = tracefs__mountpoint();
> -
> -			if (tracefs_mntpoint)
> -				mountpoint = tracefs__mountpoint();
> -		}
> -
>   		snprintf(buf, size,
>   			 "Error:\tNo permissions to read %s/%s\n"
>   			 "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
> -			 tracing_events_path, filename, mountpoint);
> +			 tracing_events_path, filename, tracing_mnt);
>   	}
>   		break;
>   	default:
>

LGTM.

David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1228458 — Re: [PATCH] tools lib api fs: Store tracing mountpoint for better error message

FromJiri Olsa <jolsa@redhat.com>
Date2015-09-19 17:10 +0200
SubjectRe: [PATCH] tools lib api fs: Store tracing mountpoint for better error message
Message-ID<qarW1-4WN-9@gated-at.bofh.it>
In reply to#1228455
On Sat, Sep 19, 2015 at 08:50:19AM -0600, David Ahern wrote:
> On 9/19/15 8:47 AM, Jiri Olsa wrote:
> 
> >diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
> >index 38aca2dd1946..0406a7d5c891 100644
> >--- a/tools/lib/api/fs/tracing_path.c
> >+++ b/tools/lib/api/fs/tracing_path.c
> >@@ -12,12 +12,14 @@
> >  #include "tracing_path.h"
> >
> >
> >+char tracing_mnt[PATH_MAX + 1]         = "/sys/kernel/debug";
> >  char tracing_path[PATH_MAX + 1]        = "/sys/kernel/debug/tracing";
> >  char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events";
> 
> why all the +1s? null terminator has to fit within PATH_MAX as well.

good question.. can't see a reason ATM

jirka

> 
> >
> >
> >  static void __tracing_path_set(const char *tracing, const char *mountpoint)
> >  {
> >+	snprintf(tracing_mnt, sizeof(tracing_mnt), "%s", mountpoint);
> >  	snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
> >  		 mountpoint, tracing);
> >  	snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
> >@@ -109,19 +111,10 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
> >  			 "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
> >  		break;
> >  	case EACCES: {
> >-		const char *mountpoint = debugfs__mountpoint();
> >-
> >-		if (!access(mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
> >-			const char *tracefs_mntpoint = tracefs__mountpoint();
> >-
> >-			if (tracefs_mntpoint)
> >-				mountpoint = tracefs__mountpoint();
> >-		}
> >-
> >  		snprintf(buf, size,
> >  			 "Error:\tNo permissions to read %s/%s\n"
> >  			 "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
> >-			 tracing_events_path, filename, mountpoint);
> >+			 tracing_events_path, filename, tracing_mnt);
> >  	}
> >  		break;
> >  	default:
> >
> 
> LGTM.
> 
> David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1228461 — Re: [PATCH] tools lib api fs: Store tracing mountpoint for better error message

FromRaphaël Beamonte <raphael.beamonte@gmail.com>
Date2015-09-19 17:30 +0200
SubjectRe: [PATCH] tools lib api fs: Store tracing mountpoint for better error message
Message-ID<qasfn-5j7-9@gated-at.bofh.it>
In reply to#1228458
2015-09-19 11:00 GMT-04:00 Jiri Olsa <jolsa@redhat.com>:
> On Sat, Sep 19, 2015 at 08:50:19AM -0600, David Ahern wrote:
>> On 9/19/15 8:47 AM, Jiri Olsa wrote:
>>
>> >diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
>> >index 38aca2dd1946..0406a7d5c891 100644
>> >--- a/tools/lib/api/fs/tracing_path.c
>> >+++ b/tools/lib/api/fs/tracing_path.c
>> >@@ -12,12 +12,14 @@
>> >  #include "tracing_path.h"
>> >
>> >
>> >+char tracing_mnt[PATH_MAX + 1]         = "/sys/kernel/debug";
>> >  char tracing_path[PATH_MAX + 1]        = "/sys/kernel/debug/tracing";
>> >  char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events";
>>
>> why all the +1s? null terminator has to fit within PATH_MAX as well.
>
> good question.. can't see a reason ATM

It is quite weird actually, it seems there is multiple occurrences of
that, without any comment to explain why that +1, even if the #define
of PATH_MAX in limits.h specify that that size also counts nul.
Most of these occurrences are linked to perf though, but there's also
fs/ocfs2/aops.c, scripts/docproc.c and usr/gen_init_cpio.c.
Perhaps a mistake that started somewhere and that was propagated
looking at the original mistake?

> jirka
>
>>
>> >
>> >
>> >  static void __tracing_path_set(const char *tracing, const char *mountpoint)
>> >  {
>> >+    snprintf(tracing_mnt, sizeof(tracing_mnt), "%s", mountpoint);
>> >     snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
>> >              mountpoint, tracing);
>> >     snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
>> >@@ -109,19 +111,10 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
>> >                      "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
>> >             break;
>> >     case EACCES: {
>> >-            const char *mountpoint = debugfs__mountpoint();
>> >-
>> >-            if (!access(mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
>> >-                    const char *tracefs_mntpoint = tracefs__mountpoint();
>> >-
>> >-                    if (tracefs_mntpoint)
>> >-                            mountpoint = tracefs__mountpoint();
>> >-            }
>> >-
>> >             snprintf(buf, size,
>> >                      "Error:\tNo permissions to read %s/%s\n"
>> >                      "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
>> >-                     tracing_events_path, filename, mountpoint);
>> >+                     tracing_events_path, filename, tracing_mnt);
>> >     }
>> >             break;
>> >     default:
>> >
>>
>> LGTM.
>>
>> David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1228460 — Re: [PATCH] tools lib api fs: Store tracing mountpoint for better error message

FromRaphaël Beamonte <raphael.beamonte@gmail.com>
Date2015-09-19 17:30 +0200
SubjectRe: [PATCH] tools lib api fs: Store tracing mountpoint for better error message
Message-ID<qasfn-5j7-11@gated-at.bofh.it>
In reply to#1228453
2015-09-19 10:47 GMT-04:00 Jiri Olsa <jolsa@kernel.org>:
> Storing the actual tracing path mountpoint to display correct
> error message hint ('Hint:' line). The error hint rediscovers
> mountpoints, but it could be different from what we actually
> used in tracing path.
>
> Before we'd display debugfs mount even though tracefs was used:
>   $ perf record -e sched:sched_krava ls
>   event syntax error: 'sched:sched_krava'
>                        \___ can't access trace events
>
>   Error:  No permissions to read /sys/kernel/debug/tracing/events/sched/sched_krava
>   Hint:   Try 'sudo mount -o remount,mode=755 /sys/kernel/debug'
>   ...
>
> After this change, correct mountpoint is displayed:
>   $ perf record -e sched:sched_krava ls
>   event syntax error: 'sched:sched_krava'
>                        \___ can't access trace events
>
>   Error:  No permissions to read /sys/kernel/debug/tracing/events/sched/sched_krava
>   Hint:   Try 'sudo mount -o remount,mode=755 /sys/kernel/debug/tracing'
>   ...
>
> Link: http://lkml.kernel.org/n/tip-xw7mf64ie0svh6m449vbyh0m@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/lib/api/fs/tracing_path.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
> index 38aca2dd1946..0406a7d5c891 100644
> --- a/tools/lib/api/fs/tracing_path.c
> +++ b/tools/lib/api/fs/tracing_path.c
> @@ -12,12 +12,14 @@
>  #include "tracing_path.h"
>
>
> +char tracing_mnt[PATH_MAX + 1]         = "/sys/kernel/debug";
>  char tracing_path[PATH_MAX + 1]        = "/sys/kernel/debug/tracing";
>  char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events";
>
>
>  static void __tracing_path_set(const char *tracing, const char *mountpoint)
>  {
> +       snprintf(tracing_mnt, sizeof(tracing_mnt), "%s", mountpoint);
>         snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
>                  mountpoint, tracing);
>         snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
> @@ -109,19 +111,10 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
>                          "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
>                 break;
>         case EACCES: {
> -               const char *mountpoint = debugfs__mountpoint();
> -
> -               if (!access(mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
> -                       const char *tracefs_mntpoint = tracefs__mountpoint();
> -
> -                       if (tracefs_mntpoint)
> -                               mountpoint = tracefs__mountpoint();
> -               }
> -
>                 snprintf(buf, size,
>                          "Error:\tNo permissions to read %s/%s\n"
>                          "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
> -                        tracing_events_path, filename, mountpoint);
> +                        tracing_events_path, filename, tracing_mnt);
>         }
>                 break;
>         default:
> --
> 2.4.3
>

Reviewed-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web