Re: [PATCH perf/core ] perf-probe: Warn if given uprobe event accesses memory on older kernel

2015-02-28 Thread Arnaldo Carvalho de Melo
Em Sat, Feb 28, 2015 at 12:21:05PM +0900, Masami Hiramatsu escreveu:
> (2015/02/28 11:53), Masami Hiramatsu wrote:
> > Warn if given uprobe event accesses memory on older kernel.
> > Until 3.14, uprobe event only supports accessing registers
> > so this warns to upgrade kernel if uprobe-event returns
> > -EINVAL and an argument of the event accesses memory ($stack,
> > @+offset, and +|-offs() symtax).
> > 
> > With this patch (on 3.10.0-123.13.2.el7.x86_64);
> >   -
> >   # ./perf probe -x ./perf warn_uprobe_event_compat stack=-0\(%sp\)
> >   Added new event:
> >   Failed to write event: Invalid argument
> >   Please upgrade your kernel to at least 3.14 to have access to feature 
> > -0(%sp)
> > Error: Failed to add events.
> >   -
> > 
> 
> Oops,
> 
> Suggested-by: Arnaldo Carvalho de Melo 

:-)

Thanks for considering my suggestion and coming up with a patch so
quickly!

I'll test it and merge,

- Arnaldo
 
> Thanks,
> 
> > Signed-off-by: Masami Hiramatsu 
> > ---
> >  tools/perf/util/probe-event.c |   23 +++
> >  1 file changed, 23 insertions(+)
> > 
> > diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> > index 7c0e765..1c570c2fa7 100644
> > --- a/tools/perf/util/probe-event.c
> > +++ b/tools/perf/util/probe-event.c
> > @@ -2199,6 +2199,27 @@ static int get_new_event_name(char *buf, size_t len, 
> > const char *base,
> > return ret;
> >  }
> >  
> > +/* Warn if the current kernel's uprobe implementation is old */
> > +static void warn_uprobe_event_compat(struct probe_trace_event *tev)
> > +{
> > +   int i;
> > +   char *buf = synthesize_probe_trace_command(tev);
> > +
> > +   /* Old uprobe event doesn't support memory dereference */
> > +   if (!tev->uprobes || tev->nargs == 0 || !buf)
> > +   goto out;
> > +
> > +   for (i = 0; i < tev->nargs; i++)
> > +   if (strglobmatch(tev->args[i].value, "[$@+-]*")) {
> > +   pr_warning("Please upgrade your kernel to at least "
> > +  "3.14 to have access to feature %s\n",
> > +  tev->args[i].value);
> > +   break;
> > +   }
> > +out:
> > +   free(buf);
> > +}
> > +
> >  static int __add_probe_trace_events(struct perf_probe_event *pev,
> >  struct probe_trace_event *tevs,
> >  int ntevs, bool allow_suffix)
> > @@ -2295,6 +2316,8 @@ static int __add_probe_trace_events(struct 
> > perf_probe_event *pev,
> >  */
> > allow_suffix = true;
> > }
> > +   if (ret == -EINVAL && pev->uprobes)
> > +   warn_uprobe_event_compat(tev);
> >  
> > /* Note that it is possible to skip all events because of blacklist */
> > if (ret >= 0 && tev->event) {
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majord...@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at  http://www.tux.org/lkml/
> > 
> > 
> > 
> 
> 
> -- 
> Masami HIRAMATSU
> Software Platform Research Dept. Linux Technology Research Center
> Hitachi, Ltd., Yokohama Research Laboratory
> E-mail: masami.hiramatsu...@hitachi.com
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH perf/core ] perf-probe: Warn if given uprobe event accesses memory on older kernel

2015-02-28 Thread Arnaldo Carvalho de Melo
Em Sat, Feb 28, 2015 at 12:21:05PM +0900, Masami Hiramatsu escreveu:
 (2015/02/28 11:53), Masami Hiramatsu wrote:
  Warn if given uprobe event accesses memory on older kernel.
  Until 3.14, uprobe event only supports accessing registers
  so this warns to upgrade kernel if uprobe-event returns
  -EINVAL and an argument of the event accesses memory ($stack,
  @+offset, and +|-offs() symtax).
  
  With this patch (on 3.10.0-123.13.2.el7.x86_64);
-
# ./perf probe -x ./perf warn_uprobe_event_compat stack=-0\(%sp\)
Added new event:
Failed to write event: Invalid argument
Please upgrade your kernel to at least 3.14 to have access to feature 
  -0(%sp)
  Error: Failed to add events.
-
  
 
 Oops,
 
 Suggested-by: Arnaldo Carvalho de Melo a...@kernel.org

:-)

Thanks for considering my suggestion and coming up with a patch so
quickly!

I'll test it and merge,

- Arnaldo
 
 Thanks,
 
  Signed-off-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com
  ---
   tools/perf/util/probe-event.c |   23 +++
   1 file changed, 23 insertions(+)
  
  diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
  index 7c0e765..1c570c2fa7 100644
  --- a/tools/perf/util/probe-event.c
  +++ b/tools/perf/util/probe-event.c
  @@ -2199,6 +2199,27 @@ static int get_new_event_name(char *buf, size_t len, 
  const char *base,
  return ret;
   }
   
  +/* Warn if the current kernel's uprobe implementation is old */
  +static void warn_uprobe_event_compat(struct probe_trace_event *tev)
  +{
  +   int i;
  +   char *buf = synthesize_probe_trace_command(tev);
  +
  +   /* Old uprobe event doesn't support memory dereference */
  +   if (!tev-uprobes || tev-nargs == 0 || !buf)
  +   goto out;
  +
  +   for (i = 0; i  tev-nargs; i++)
  +   if (strglobmatch(tev-args[i].value, [$@+-]*)) {
  +   pr_warning(Please upgrade your kernel to at least 
  +  3.14 to have access to feature %s\n,
  +  tev-args[i].value);
  +   break;
  +   }
  +out:
  +   free(buf);
  +}
  +
   static int __add_probe_trace_events(struct perf_probe_event *pev,
   struct probe_trace_event *tevs,
   int ntevs, bool allow_suffix)
  @@ -2295,6 +2316,8 @@ static int __add_probe_trace_events(struct 
  perf_probe_event *pev,
   */
  allow_suffix = true;
  }
  +   if (ret == -EINVAL  pev-uprobes)
  +   warn_uprobe_event_compat(tev);
   
  /* Note that it is possible to skip all events because of blacklist */
  if (ret = 0  tev-event) {
  
  --
  To unsubscribe from this list: send the line unsubscribe linux-kernel in
  the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
  Please read the FAQ at  http://www.tux.org/lkml/
  
  
  
 
 
 -- 
 Masami HIRAMATSU
 Software Platform Research Dept. Linux Technology Research Center
 Hitachi, Ltd., Yokohama Research Laboratory
 E-mail: masami.hiramatsu...@hitachi.com
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH perf/core ] perf-probe: Warn if given uprobe event accesses memory on older kernel

2015-02-27 Thread Masami Hiramatsu
(2015/02/28 11:53), Masami Hiramatsu wrote:
> Warn if given uprobe event accesses memory on older kernel.
> Until 3.14, uprobe event only supports accessing registers
> so this warns to upgrade kernel if uprobe-event returns
> -EINVAL and an argument of the event accesses memory ($stack,
> @+offset, and +|-offs() symtax).
> 
> With this patch (on 3.10.0-123.13.2.el7.x86_64);
>   -
>   # ./perf probe -x ./perf warn_uprobe_event_compat stack=-0\(%sp\)
>   Added new event:
>   Failed to write event: Invalid argument
>   Please upgrade your kernel to at least 3.14 to have access to feature 
> -0(%sp)
> Error: Failed to add events.
>   -
> 

Oops,

Suggested-by: Arnaldo Carvalho de Melo 

Thanks,

> Signed-off-by: Masami Hiramatsu 
> ---
>  tools/perf/util/probe-event.c |   23 +++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 7c0e765..1c570c2fa7 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -2199,6 +2199,27 @@ static int get_new_event_name(char *buf, size_t len, 
> const char *base,
>   return ret;
>  }
>  
> +/* Warn if the current kernel's uprobe implementation is old */
> +static void warn_uprobe_event_compat(struct probe_trace_event *tev)
> +{
> + int i;
> + char *buf = synthesize_probe_trace_command(tev);
> +
> + /* Old uprobe event doesn't support memory dereference */
> + if (!tev->uprobes || tev->nargs == 0 || !buf)
> + goto out;
> +
> + for (i = 0; i < tev->nargs; i++)
> + if (strglobmatch(tev->args[i].value, "[$@+-]*")) {
> + pr_warning("Please upgrade your kernel to at least "
> +"3.14 to have access to feature %s\n",
> +tev->args[i].value);
> + break;
> + }
> +out:
> + free(buf);
> +}
> +
>  static int __add_probe_trace_events(struct perf_probe_event *pev,
>struct probe_trace_event *tevs,
>int ntevs, bool allow_suffix)
> @@ -2295,6 +2316,8 @@ static int __add_probe_trace_events(struct 
> perf_probe_event *pev,
>*/
>   allow_suffix = true;
>   }
> + if (ret == -EINVAL && pev->uprobes)
> + warn_uprobe_event_compat(tev);
>  
>   /* Note that it is possible to skip all events because of blacklist */
>   if (ret >= 0 && tev->event) {
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 
> 
> 


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu...@hitachi.com


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


[PATCH perf/core ] perf-probe: Warn if given uprobe event accesses memory on older kernel

2015-02-27 Thread Masami Hiramatsu
Warn if given uprobe event accesses memory on older kernel.
Until 3.14, uprobe event only supports accessing registers
so this warns to upgrade kernel if uprobe-event returns
-EINVAL and an argument of the event accesses memory ($stack,
@+offset, and +|-offs() symtax).

With this patch (on 3.10.0-123.13.2.el7.x86_64);
  -
  # ./perf probe -x ./perf warn_uprobe_event_compat stack=-0\(%sp\)
  Added new event:
  Failed to write event: Invalid argument
  Please upgrade your kernel to at least 3.14 to have access to feature -0(%sp)
Error: Failed to add events.
  -

Signed-off-by: Masami Hiramatsu 
---
 tools/perf/util/probe-event.c |   23 +++
 1 file changed, 23 insertions(+)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 7c0e765..1c570c2fa7 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2199,6 +2199,27 @@ static int get_new_event_name(char *buf, size_t len, 
const char *base,
return ret;
 }
 
+/* Warn if the current kernel's uprobe implementation is old */
+static void warn_uprobe_event_compat(struct probe_trace_event *tev)
+{
+   int i;
+   char *buf = synthesize_probe_trace_command(tev);
+
+   /* Old uprobe event doesn't support memory dereference */
+   if (!tev->uprobes || tev->nargs == 0 || !buf)
+   goto out;
+
+   for (i = 0; i < tev->nargs; i++)
+   if (strglobmatch(tev->args[i].value, "[$@+-]*")) {
+   pr_warning("Please upgrade your kernel to at least "
+  "3.14 to have access to feature %s\n",
+  tev->args[i].value);
+   break;
+   }
+out:
+   free(buf);
+}
+
 static int __add_probe_trace_events(struct perf_probe_event *pev,
 struct probe_trace_event *tevs,
 int ntevs, bool allow_suffix)
@@ -2295,6 +2316,8 @@ static int __add_probe_trace_events(struct 
perf_probe_event *pev,
 */
allow_suffix = true;
}
+   if (ret == -EINVAL && pev->uprobes)
+   warn_uprobe_event_compat(tev);
 
/* Note that it is possible to skip all events because of blacklist */
if (ret >= 0 && tev->event) {

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


[PATCH perf/core ] perf-probe: Warn if given uprobe event accesses memory on older kernel

2015-02-27 Thread Masami Hiramatsu
Warn if given uprobe event accesses memory on older kernel.
Until 3.14, uprobe event only supports accessing registers
so this warns to upgrade kernel if uprobe-event returns
-EINVAL and an argument of the event accesses memory ($stack,
@+offset, and +|-offs() symtax).

With this patch (on 3.10.0-123.13.2.el7.x86_64);
  -
  # ./perf probe -x ./perf warn_uprobe_event_compat stack=-0\(%sp\)
  Added new event:
  Failed to write event: Invalid argument
  Please upgrade your kernel to at least 3.14 to have access to feature -0(%sp)
Error: Failed to add events.
  -

Signed-off-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com
---
 tools/perf/util/probe-event.c |   23 +++
 1 file changed, 23 insertions(+)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 7c0e765..1c570c2fa7 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2199,6 +2199,27 @@ static int get_new_event_name(char *buf, size_t len, 
const char *base,
return ret;
 }
 
+/* Warn if the current kernel's uprobe implementation is old */
+static void warn_uprobe_event_compat(struct probe_trace_event *tev)
+{
+   int i;
+   char *buf = synthesize_probe_trace_command(tev);
+
+   /* Old uprobe event doesn't support memory dereference */
+   if (!tev-uprobes || tev-nargs == 0 || !buf)
+   goto out;
+
+   for (i = 0; i  tev-nargs; i++)
+   if (strglobmatch(tev-args[i].value, [$@+-]*)) {
+   pr_warning(Please upgrade your kernel to at least 
+  3.14 to have access to feature %s\n,
+  tev-args[i].value);
+   break;
+   }
+out:
+   free(buf);
+}
+
 static int __add_probe_trace_events(struct perf_probe_event *pev,
 struct probe_trace_event *tevs,
 int ntevs, bool allow_suffix)
@@ -2295,6 +2316,8 @@ static int __add_probe_trace_events(struct 
perf_probe_event *pev,
 */
allow_suffix = true;
}
+   if (ret == -EINVAL  pev-uprobes)
+   warn_uprobe_event_compat(tev);
 
/* Note that it is possible to skip all events because of blacklist */
if (ret = 0  tev-event) {

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


Re: [PATCH perf/core ] perf-probe: Warn if given uprobe event accesses memory on older kernel

2015-02-27 Thread Masami Hiramatsu
(2015/02/28 11:53), Masami Hiramatsu wrote:
 Warn if given uprobe event accesses memory on older kernel.
 Until 3.14, uprobe event only supports accessing registers
 so this warns to upgrade kernel if uprobe-event returns
 -EINVAL and an argument of the event accesses memory ($stack,
 @+offset, and +|-offs() symtax).
 
 With this patch (on 3.10.0-123.13.2.el7.x86_64);
   -
   # ./perf probe -x ./perf warn_uprobe_event_compat stack=-0\(%sp\)
   Added new event:
   Failed to write event: Invalid argument
   Please upgrade your kernel to at least 3.14 to have access to feature 
 -0(%sp)
 Error: Failed to add events.
   -
 

Oops,

Suggested-by: Arnaldo Carvalho de Melo a...@kernel.org

Thanks,

 Signed-off-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com
 ---
  tools/perf/util/probe-event.c |   23 +++
  1 file changed, 23 insertions(+)
 
 diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
 index 7c0e765..1c570c2fa7 100644
 --- a/tools/perf/util/probe-event.c
 +++ b/tools/perf/util/probe-event.c
 @@ -2199,6 +2199,27 @@ static int get_new_event_name(char *buf, size_t len, 
 const char *base,
   return ret;
  }
  
 +/* Warn if the current kernel's uprobe implementation is old */
 +static void warn_uprobe_event_compat(struct probe_trace_event *tev)
 +{
 + int i;
 + char *buf = synthesize_probe_trace_command(tev);
 +
 + /* Old uprobe event doesn't support memory dereference */
 + if (!tev-uprobes || tev-nargs == 0 || !buf)
 + goto out;
 +
 + for (i = 0; i  tev-nargs; i++)
 + if (strglobmatch(tev-args[i].value, [$@+-]*)) {
 + pr_warning(Please upgrade your kernel to at least 
 +3.14 to have access to feature %s\n,
 +tev-args[i].value);
 + break;
 + }
 +out:
 + free(buf);
 +}
 +
  static int __add_probe_trace_events(struct perf_probe_event *pev,
struct probe_trace_event *tevs,
int ntevs, bool allow_suffix)
 @@ -2295,6 +2316,8 @@ static int __add_probe_trace_events(struct 
 perf_probe_event *pev,
*/
   allow_suffix = true;
   }
 + if (ret == -EINVAL  pev-uprobes)
 + warn_uprobe_event_compat(tev);
  
   /* Note that it is possible to skip all events because of blacklist */
   if (ret = 0  tev-event) {
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-kernel in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/
 
 
 


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu...@hitachi.com


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