[RFC 0/6] perf tools: Add perf_evlist errno

2013-11-29 Thread Jiri Olsa
hi,
Andi reported wrong error message for :S modifier
on kernel without event ID ioctl support.

The reason was that the ioctl failed, but the error was
printed like the mmap would:

$ perf.old record -e '{cycles,cache-misses}:S' ls
failed to mmap with 25 (Inappropriate ioctl for device)
ls: Terminated

I experimentally added sort of 'libc errno' interface for
perf_evlist to be able to get proper error message, like:

$ perf record -e '{cycles,cache-misses}:S' ls
Cannot read event group on this kernel.
Please consider kernel update (v3.12+).
ls: Terminated

I'm not sure about this approach. Maybe it'd be better be more
global..? So before throwing this out, sending it as RFC ;-)

thanks for ideas,
jirka

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@redhat.com
Cc: David Ahern dsah...@gmail.com
Cc: Andi Kleen a...@firstfloor.org
---
Jiri Olsa (6):
  perf tools: Add perf_evlist error string interface
  perf tools: Add PERF_EVLIST__ERRNO_MMAP internal error
  perf tools: Add PERF_EVLIST__ERRNO_OPEN internal error
  perf tools: Add PERF_EVLIST__ERRNO_IOCTL_ID_GROUP internal error
  perf tools: Add PERF_EVLIST__ERRNO_NEWTP internal error
  perf tools: Use perf_evlist__strerror in kvm/record/top/trace commands

 tools/perf/builtin-kvm.c|   2 +-
 tools/perf/builtin-record.c |  13 +--
 tools/perf/builtin-top.c|   3 +-
 tools/perf/builtin-trace.c  |  34 -
 tools/perf/util/evlist.c| 205 
++-
 tools/perf/util/evlist.h|  23 +++-
 6 files changed, 181 insertions(+), 99 deletions(-)
--
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 1/6] perf tools: Add perf_evlist error string interface

2013-11-29 Thread Jiri Olsa
Adding perf_evlist__strerror function that returns
static string of the last error occured during
'struct perf_evlist' handling:

  char *perf_evlist__strerror(struct perf_evlist *evlist);

After each 'struct perf_evlist' operation that supports
internal error handling, this function returns proper
error string for output.

The point is to have internal error handling so we could
print our propper error message, eg. when 'perf_evlist__mmap'
fails, we have no idea if it was for the mmap failure or ioctl
(event ID retrieval).

NOTE We can add thread safe '_r' variant in the
future, currently it's not needed.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@redhat.com
Cc: David Ahern dsah...@gmail.com
Cc: Andi Kleen a...@firstfloor.org
---
 tools/perf/util/evlist.c | 34 ++
 tools/perf/util/evlist.h | 13 +
 2 files changed, 47 insertions(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 76fa764..dfb72d4 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -28,6 +28,11 @@
 #define FD(e, x, y) (*(int *)xyarray__entry(e-fd, x, y))
 #define SID(e, x, y) xyarray__entry(e-sample_id, x, y)
 
+#define SET_ERR(_err) ({   \
+   evlist-err  = PERF_EVLIST__ERRNO_##_err;   \
+   evlist-err_libc = errno;   \
+})
+
 void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus,
   struct thread_map *threads)
 {
@@ -600,6 +605,34 @@ static int perf_evlist__alloc_mmap(struct perf_evlist 
*evlist)
return evlist-mmap != NULL ? 0 : -ENOMEM;
 }
 
+static void __perf_evlist__strerror(struct perf_evlist *evlist,
+   char *buf, size_t size)
+{
+   int err_libc = evlist-err_libc;
+   int err  = evlist-err;
+
+   switch (err) {
+   case PERF_EVLIST__ERRNO_SUCCESS:
+   break;
+   default:
+   scnprintf(buf, size, Unknown error\n);
+   return;
+   }
+
+   if (!err_libc)
+   scnprintf(buf, size, Success.);
+   else
+   scnprintf(buf, size, Failed with %d (%s)\n,
+ err_libc, strerror(err_libc));
+}
+
+char *perf_evlist__strerror(struct perf_evlist *evlist)
+{
+   static char str[BUFSIZ];
+   __perf_evlist__strerror(evlist, str, BUFSIZ);
+   return str;
+}
+
 static int __perf_evlist__mmap(struct perf_evlist *evlist,
   int idx, int prot, int mask, int fd)
 {
@@ -607,6 +640,7 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist,
evlist-mmap[idx].mask = mask;
evlist-mmap[idx].base = mmap(NULL, evlist-mmap_len, prot,
  MAP_SHARED, fd, 0);
+
if (evlist-mmap[idx].base == MAP_FAILED) {
pr_debug2(failed to mmap perf event ring buffer, error %d\n,
  errno);
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 649d6ea..9832fbd 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -17,6 +17,10 @@ struct perf_record_opts;
 #define PERF_EVLIST__HLIST_BITS 8
 #define PERF_EVLIST__HLIST_SIZE (1  PERF_EVLIST__HLIST_BITS)
 
+enum {
+   PERF_EVLIST__ERRNO_SUCCESS  = 0,
+};
+
 struct perf_mmap {
void *base;
int  mask;
@@ -45,6 +49,14 @@ struct perf_evlist {
struct thread_map *threads;
struct cpu_map*cpus;
struct perf_evsel *selected;
+
+   /*
+* Internal error handling:
+*   err  - internal error value of last operation (
+*   err_libc - adjacent libc errno value
+*/
+   int  err;
+   int  err_libc;
 };
 
 struct perf_evsel_str_handler {
@@ -172,6 +184,7 @@ size_t perf_evlist__fprintf(struct perf_evlist *evlist, 
FILE *fp);
 
 int perf_evlist__strerror_tp(struct perf_evlist *evlist, int err, char *buf, 
size_t size);
 int perf_evlist__strerror_open(struct perf_evlist *evlist, int err, char *buf, 
size_t size);
+char *perf_evlist__strerror(struct perf_evlist *evlist);
 
 static inline unsigned int perf_mmap__read_head(struct perf_mmap *mm)
 {
-- 
1.8.3.1

--
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 2/6] perf tools: Add PERF_EVLIST__ERRNO_MMAP internal error

2013-11-29 Thread Jiri Olsa
Adding internal error (PERF_EVLIST__ERRNO_MMAP) for case
when 'mmap' syscall fails.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@redhat.com
Cc: David Ahern dsah...@gmail.com
Cc: Andi Kleen a...@firstfloor.org
---
 tools/perf/util/evlist.c | 28 
 tools/perf/util/evlist.h |  1 +
 2 files changed, 29 insertions(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index dfb72d4..d156f0a 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -605,6 +605,28 @@ static int perf_evlist__alloc_mmap(struct perf_evlist 
*evlist)
return evlist-mmap != NULL ? 0 : -ENOMEM;
 }
 
+static void strerror_mmap(struct perf_evlist *evlist,
+ char *buf, size_t size)
+{
+   int err_libc = evlist-err_libc;
+
+   switch (evlist-err_libc) {
+   case EPERM:
+   scnprintf(buf, size,
+   Permission error mapping pages.\n
+   Consider increasing 
+   /proc/sys/kernel/perf_event_mlock_kb,\n
+   or try again with a smaller value of 
-m/--mmap_pages.\n
+   (current size: %dB)\n, evlist-mmap_len);
+   break;
+   default:
+   scnprintf(buf, size,
+   Failed to mmap events with error %d (%s)\n,
+   err_libc, strerror(err_libc));
+   break;
+   }
+}
+
 static void __perf_evlist__strerror(struct perf_evlist *evlist,
char *buf, size_t size)
 {
@@ -614,6 +636,9 @@ static void __perf_evlist__strerror(struct perf_evlist 
*evlist,
switch (err) {
case PERF_EVLIST__ERRNO_SUCCESS:
break;
+   case PERF_EVLIST__ERRNO_MMAP:
+   strerror_mmap(evlist, buf, size);
+   return;
default:
scnprintf(buf, size, Unknown error\n);
return;
@@ -642,6 +667,7 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist,
  MAP_SHARED, fd, 0);
 
if (evlist-mmap[idx].base == MAP_FAILED) {
+   SET_ERR(MMAP);
pr_debug2(failed to mmap perf event ring buffer, error %d\n,
  errno);
evlist-mmap[idx].base = NULL;
@@ -821,6 +847,8 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned 
int pages,
const struct thread_map *threads = evlist-threads;
int prot = PROT_READ | (overwrite ? 0 : PROT_WRITE), mask;
 
+   SET_ERR(SUCCESS);
+
if (evlist-mmap == NULL  perf_evlist__alloc_mmap(evlist)  0)
return -ENOMEM;
 
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 9832fbd..02df99a 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -19,6 +19,7 @@ struct perf_record_opts;
 
 enum {
PERF_EVLIST__ERRNO_SUCCESS  = 0,
+   PERF_EVLIST__ERRNO_MMAP = 1,
 };
 
 struct perf_mmap {
-- 
1.8.3.1

--
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 4/6] perf tools: Add PERF_EVLIST__ERRNO_IOCTL_ID_GROUP internal error

2013-11-29 Thread Jiri Olsa
Adding internal error (PERF_EVLIST__ERRNO_IOCTL_ID_GROUP) for
cases when ioctl syscall fails during perf_evlist__mmap call.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@redhat.com
Cc: David Ahern dsah...@gmail.com
Cc: Andi Kleen a...@firstfloor.org
---
 tools/perf/util/evlist.c | 9 -
 tools/perf/util/evlist.h | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 4af0cca..f9c5abd 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -399,8 +399,10 @@ static int perf_evlist__id_add_fd(struct perf_evlist 
*evlist,
 * This way does not work with group format read, so bail
 * out in that case.
 */
-   if (perf_evlist__read_format(evlist)  PERF_FORMAT_GROUP)
+   if (perf_evlist__read_format(evlist)  PERF_FORMAT_GROUP) {
+   SET_ERR(IOCTL_ID_GROUP);
return -1;
+   }
 
if (!(evsel-attr.read_format  PERF_FORMAT_ID) ||
read(fd, read_data, sizeof(read_data)) == -1)
@@ -676,6 +678,11 @@ static void __perf_evlist__strerror(struct perf_evlist 
*evlist,
case PERF_EVLIST__ERRNO_OPEN:
strerror_open(evlist, buf, size);
return;
+   case PERF_EVLIST__ERRNO_IOCTL_ID_GROUP:
+   scnprintf(buf, size,
+   Cannot read event group on this kernel.\n
+   Please consider kernel update (v3.12+).\n);
+   return;
default:
scnprintf(buf, size, Unknown error\n);
return;
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 48ac4c5..e5ce8c7 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -21,6 +21,7 @@ enum {
PERF_EVLIST__ERRNO_SUCCESS  = 0,
PERF_EVLIST__ERRNO_MMAP = 1,
PERF_EVLIST__ERRNO_OPEN = 2,
+   PERF_EVLIST__ERRNO_IOCTL_ID_GROUP   = 3,
 };
 
 struct perf_mmap {
-- 
1.8.3.1

--
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 6/6] perf tools: Use perf_evlist__strerror in kvm/record/top/trace commands

2013-11-29 Thread Jiri Olsa
Using perf_evlist__strerror in kvm/record/top/trace commands
to handle perf_evlist__mmap failures.

Examples with kernel not supporting event ID ioctl:

  * record session before:

$ perf.old record -e '{cycles,cache-misses}:S' ls
failed to mmap with 25 (Inappropriate ioctl for device)
ls: Terminated

  * record session now:

$ perf record -e '{cycles,cache-misses}:S' ls
Cannot read event group on this kernel.
Please consider kernel update (v3.12+).
ls: Terminated

Examples with session allocating ring buffer with the
size over the allowed threshold.

  * record session before:

$ perf record -m 10M ls
rounding mmap pages size to 16777216 bytes (4096 pages)
Permission error mapping pages.
Consider increasing /proc/sys/kernel/perf_event_mlock_kb,
or try again with a smaller value of -m/--mmap_pages.
(current size: 16781312B)
ls: Terminated

  * record session now:

$ perf record -m 10M ls
rounding mmap pages size to 16777216 bytes (4096 pages)
Permission error mapping pages.
Consider increasing /proc/sys/kernel/perf_event_mlock_kb,
or try again with a smaller value of -m/--mmap_pages.
(current value: 4096)
ls: Terminated

  * top session, before:

$ perf top -m 100M --stdio
rounding mmap pages size to 134217728 bytes (32768 pages)
Error:
Failed to mmap with 1 (Operation not permitted)

  * top session, now:

$ perf top -m 100M --stdio
rounding mmap pages size to 134217728 bytes (32768 pages)
Error:
Permission error mapping pages.
Consider increasing /proc/sys/kernel/perf_event_mlock_kb,
or try again with a smaller value of -m/--mmap_pages.
(current size: 134221824B)

  * trace session, before:

$ perf trace -m 100M ./ex
rounding mmap pages size to 16777216 bytes (4096 pages)
Permission error mapping pages.
Consider increasing /proc/sys/kernel/perf_event_mlock_kb,
or try again with a smaller value of -m/--mmap_pages.
(current value: 4096)
ls: Terminated

  * trace session, now:

$ perf trace -m 100M ./ex
rounding mmap pages size to 134217728 bytes (32768 pages)
Permission error mapping pages.
Consider increasing /proc/sys/kernel/perf_event_mlock_kb,
or try again with a smaller value of -m/--mmap_pages.
(current size: 134221824B)

  * kvm stat live session, before:

$ perf kvm stat live -m 1M
rounding mmap pages size to 17179869184 bytes (4194304 pages)
Error:
Failed to mmap the events: Cannot allocate memory

  * kvm stat live session, now:

$ perf kvm stat live -m 1M
rounding mmap pages size to 17179869184 bytes (4194304 pages)
Error:
Failed to mmap events with error 12 (Cannot allocate memory)

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@redhat.com
Cc: David Ahern dsah...@gmail.com
Cc: Andi Kleen a...@firstfloor.org
---
 tools/perf/builtin-kvm.c|  2 +-
 tools/perf/builtin-record.c | 13 ++---
 tools/perf/builtin-top.c|  3 +--
 tools/perf/builtin-trace.c  |  2 +-
 4 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index f8bf5f2..131781f 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1210,7 +1210,7 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm)
}
 
if (perf_evlist__mmap(evlist, kvm-opts.mmap_pages, false)  0) {
-   ui__error(Failed to mmap the events: %s\n, strerror(errno));
+   ui__error(%s, perf_evlist__strerror(evlist));
perf_evlist__close(evlist);
goto out;
}
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index d93e2ee..f697362 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -219,17 +219,8 @@ try_again:
}
 
if (perf_evlist__mmap(evlist, opts-mmap_pages, false)  0) {
-   if (errno == EPERM) {
-   pr_err(Permission error mapping pages.\n
-  Consider increasing 
-  /proc/sys/kernel/perf_event_mlock_kb,\n
-  or try again with a smaller value of 
-m/--mmap_pages.\n
-  (current value: %d)\n, opts-mmap_pages);
-   rc = -errno;
-   } else {
-   pr_err(failed to mmap with %d (%s)\n, errno, 
strerror(errno));
-   rc = -errno;
-   }
+   pr_err(%s, perf_evlist__strerror(evlist));
+   rc = -errno;
goto out;
}
 
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 03d37a7..3825495

[PATCH 5/6] perf tools: Add PERF_EVLIST__ERRNO_NEWTP internal error

2013-11-29 Thread Jiri Olsa
Adding internal error (PERF_EVLIST__ERRNO_NEWTP) for case
when perf_evlist__add_newtp call fails.

Moving perf_evlist__strerror_tp function to the error
string handling framework.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@redhat.com
Cc: David Ahern dsah...@gmail.com
Cc: Andi Kleen a...@firstfloor.org
---
 tools/perf/builtin-trace.c | 31 ++---
 tools/perf/util/evlist.c   | 67 --
 tools/perf/util/evlist.h   |  6 +
 3 files changed, 55 insertions(+), 49 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index cba33e8..f2886c7 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -199,23 +199,29 @@ static int perf_evlist__add_syscall_newtp(struct 
perf_evlist *evlist,
int ret = -1;
struct perf_evsel *sys_enter, *sys_exit;
 
+#define GOTO_ERR(label) ({ \
+   PERF_EVLIST__SET_ERR(evlist, OPEN); \
+   goto label; \
+})
+
sys_enter = perf_evsel__syscall_newtp(sys_enter, sys_enter_handler);
if (sys_enter == NULL)
-   goto out;
+   GOTO_ERR(out);
 
if (perf_evsel__init_sc_tp_ptr_field(sys_enter, args))
-   goto out_delete_sys_enter;
+   GOTO_ERR(out_delete_sys_enter);
 
sys_exit = perf_evsel__syscall_newtp(sys_exit, sys_exit_handler);
if (sys_exit == NULL)
-   goto out_delete_sys_enter;
+   GOTO_ERR(out_delete_sys_enter);
 
if (perf_evsel__init_sc_tp_uint_field(sys_exit, ret))
-   goto out_delete_sys_exit;
+   GOTO_ERR(out_delete_sys_exit);
 
perf_evlist__add(evlist, sys_enter);
perf_evlist__add(evlist, sys_exit);
 
+   PERF_EVLIST__SET_ERR(evlist, SUCCESS);
ret = 0;
 out:
return ret;
@@ -1851,14 +1857,14 @@ static int trace__run(struct trace *trace, int argc, 
const char **argv)
}
 
if (perf_evlist__add_syscall_newtp(evlist, trace__sys_enter, 
trace__sys_exit))
-   goto out_error_tp;
+   goto out_error;
 
perf_evlist__add_vfs_getname(evlist);
 
if (trace-sched 
perf_evlist__add_newtp(evlist, sched, sched_stat_runtime,
trace__sched_stat_runtime))
-   goto out_error_tp;
+   goto out_error;
 
err = perf_evlist__create_maps(evlist, trace-opts.target);
if (err  0) {
@@ -1888,7 +1894,7 @@ static int trace__run(struct trace *trace, int argc, 
const char **argv)
 
err = perf_evlist__open(evlist);
if (err  0)
-   goto out_error_open;
+   goto out_error;
 
err = perf_evlist__mmap(evlist, trace-opts.mmap_pages, false);
if (err  0) {
@@ -1988,18 +1994,9 @@ out:
trace-live = false;
return err;
 
-out_error_open:
+out_error:
fprintf(trace-output, %s\n, perf_evlist__strerror(evlist));
goto out_delete_evlist;
-
-{
-   char errbuf[BUFSIZ];
-
-out_error_tp:
-   perf_evlist__strerror_tp(evlist, errno, errbuf, sizeof(errbuf));
-   fprintf(trace-output, %s\n, errbuf);
-   goto out_delete_evlist;
-}
 }
 
 static int trace__replay(struct trace *trace)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index f9c5abd..edb933c 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -28,10 +28,7 @@
 #define FD(e, x, y) (*(int *)xyarray__entry(e-fd, x, y))
 #define SID(e, x, y) xyarray__entry(e-sample_id, x, y)
 
-#define SET_ERR(_err) ({   \
-   evlist-err  = PERF_EVLIST__ERRNO_##_err;   \
-   evlist-err_libc = errno;   \
-})
+#define SET_ERR(_err) PERF_EVLIST__SET_ERR(evlist, _err)
 
 void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus,
   struct thread_map *threads)
@@ -258,9 +255,12 @@ int perf_evlist__add_newtp(struct perf_evlist *evlist,
 {
struct perf_evsel *evsel = perf_evsel__newtp(sys, name);
 
-   if (evsel == NULL)
+   if (evsel == NULL) {
+   SET_ERR(NEWTP);
return -1;
+   }
 
+   SET_ERR(SUCCESS);
evsel-handler = handler;
perf_evlist__add(evlist, evsel);
return 0;
@@ -663,6 +663,33 @@ static void strerror_open(struct perf_evlist *evlist,
}
 }
 
+static void strerror_newtp(struct perf_evlist *evlist,
+   char *buf, size_t size)
+{
+   int err_libc = evlist-err_libc;
+   char sbuf[128];
+
+   switch (err_libc) {
+   case ENOENT:
+   scnprintf(buf, size, %s,
+ Error:\tUnable

[PATCH 3/6] perf tools: Add PERF_EVLIST__ERRNO_OPEN internal error

2013-11-29 Thread Jiri Olsa
Adding internal error (PERF_EVLIST__ERRNO_OPEN) for
cases when perf_evlist__open fails.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@redhat.com
Cc: David Ahern dsah...@gmail.com
Cc: Andi Kleen a...@firstfloor.org
---
 tools/perf/builtin-trace.c | 11 ---
 tools/perf/util/evlist.c   | 75 --
 tools/perf/util/evlist.h   |  2 +-
 3 files changed, 45 insertions(+), 43 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 9f2a242..cba33e8 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1987,17 +1987,16 @@ out_delete_evlist:
 out:
trace-live = false;
return err;
+
+out_error_open:
+   fprintf(trace-output, %s\n, perf_evlist__strerror(evlist));
+   goto out_delete_evlist;
+
 {
char errbuf[BUFSIZ];
 
 out_error_tp:
perf_evlist__strerror_tp(evlist, errno, errbuf, sizeof(errbuf));
-   goto out_error;
-
-out_error_open:
-   perf_evlist__strerror_open(evlist, errno, errbuf, sizeof(errbuf));
-
-out_error:
fprintf(trace-output, %s\n, errbuf);
goto out_delete_evlist;
 }
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index d156f0a..4af0cca 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -627,6 +627,40 @@ static void strerror_mmap(struct perf_evlist *evlist,
}
 }
 
+static void strerror_open(struct perf_evlist *evlist,
+ char *buf, size_t size)
+{
+   int printed, value, err_libc = evlist-err_libc;
+   char sbuf[128], *emsg = strerror_r(err_libc, sbuf, sizeof(sbuf));
+
+   switch (err_libc) {
+   case EACCES:
+   case EPERM:
+   printed = scnprintf(buf, size,
+   Error:\t%s.\n
+   Hint:\tCheck 
/proc/sys/kernel/perf_event_paranoid setting., emsg);
+
+   if (filename__read_int(/proc/sys/kernel/perf_event_paranoid, 
value))
+   break;
+
+   printed += scnprintf(buf + printed, size - printed, 
\nHint:\t);
+
+   if (value = 2) {
+   printed += scnprintf(buf + printed, size - printed,
+For your workloads it needs to be 
= 1\nHint:\t);
+   }
+   printed += scnprintf(buf + printed, size - printed,
+For system wide tracing it needs to be 
set to -1);
+
+   printed += scnprintf(buf + printed, size - printed,
+   .\nHint:\tThe current value is %d., 
value);
+   break;
+   default:
+   scnprintf(buf, size, %s, emsg);
+   break;
+   }
+}
+
 static void __perf_evlist__strerror(struct perf_evlist *evlist,
char *buf, size_t size)
 {
@@ -639,6 +673,9 @@ static void __perf_evlist__strerror(struct perf_evlist 
*evlist,
case PERF_EVLIST__ERRNO_MMAP:
strerror_mmap(evlist, buf, size);
return;
+   case PERF_EVLIST__ERRNO_OPEN:
+   strerror_open(evlist, buf, size);
+   return;
default:
scnprintf(buf, size, Unknown error\n);
return;
@@ -1089,8 +1126,10 @@ int perf_evlist__open(struct perf_evlist *evlist)
goto out_err;
}
 
+   SET_ERR(SUCCESS);
return 0;
 out_err:
+   SET_ERR(OPEN);
perf_evlist__close(evlist);
errno = -err;
return err;
@@ -1243,39 +1282,3 @@ int perf_evlist__strerror_tp(struct perf_evlist *evlist 
__maybe_unused,
 
return 0;
 }
-
-int perf_evlist__strerror_open(struct perf_evlist *evlist __maybe_unused,
-  int err, char *buf, size_t size)
-{
-   int printed, value;
-   char sbuf[128], *emsg = strerror_r(err, sbuf, sizeof(sbuf));
-
-   switch (err) {
-   case EACCES:
-   case EPERM:
-   printed = scnprintf(buf, size,
-   Error:\t%s.\n
-   Hint:\tCheck 
/proc/sys/kernel/perf_event_paranoid setting., emsg);
-
-   if (filename__read_int(/proc/sys/kernel/perf_event_paranoid, 
value))
-   break;
-
-   printed += scnprintf(buf + printed, size - printed, 
\nHint:\t);
-
-   if (value = 2) {
-   printed += scnprintf(buf + printed, size - printed,
-For your workloads it needs to be 
= 1\nHint:\t);
-   }
-   printed += scnprintf(buf + printed, size - printed

[PATCHv3 20/29] tools lib traceevent: Remove malloc_or_die from plugin_function.c

2013-11-29 Thread Jiri Olsa
On Fri, Nov 29, 2013 at 10:54:21AM +, Namhyung Kim wrote:
  Removing malloc_or_die calls from plugin_function.c,
  replacing them and factoring the code with standard
  realloc and error path.
 
 [SNIP]
 
  if (cpu  cpus) {
  -   if (fstack)
  -   fstack = realloc(fstack, sizeof(*fstack) * (cpu + 
  1));
  -   else
  -   fstack = malloc_or_die(sizeof(*fstack) * (cpu + 1));
  +   fstack = realloc(fstack, sizeof(*fstack) * (cpu + 1));
 
 This code also has same problem..
 

and v3.1 ;-) thanks

jirka


---
Removing malloc_or_die calls from plugin_function.c,
replacing them and factoring the code with standard
realloc and error path.

Suggested-by: Namhyung Kim namhy...@kernel.org
Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@redhat.com
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/plugin_function.c | 29 -
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/tools/lib/traceevent/plugin_function.c 
b/tools/lib/traceevent/plugin_function.c
index 87acf9c..aad92ad 100644
--- a/tools/lib/traceevent/plugin_function.c
+++ b/tools/lib/traceevent/plugin_function.c
@@ -43,11 +43,17 @@ static void add_child(struct func_stack *stack, const char 
*child, int pos)
if (pos  stack-size)
free(stack-stack[pos]);
else {
-   if (!stack-stack)
-   stack-stack = malloc_or_die(sizeof(char *) * STK_BLK);
-   else
-   stack-stack = realloc(stack-stack, sizeof(char *) *
-  (stack-size + STK_BLK));
+   char **ptr;
+
+   ptr = realloc(stack-stack, sizeof(char *) *
+ (stack-size + STK_BLK));
+   if (!ptr) {
+   warning(could not allocate plugin memory\n);
+   return;
+   }
+
+   stack-stack = ptr;
+
for (i = stack-size; i  stack-size + STK_BLK; i++)
stack-stack[i] = NULL;
stack-size += STK_BLK;
@@ -64,10 +70,15 @@ static int add_and_get_index(const char *parent, const char 
*child, int cpu)
return 0;
 
if (cpu  cpus) {
-   if (fstack)
-   fstack = realloc(fstack, sizeof(*fstack) * (cpu + 1));
-   else
-   fstack = malloc_or_die(sizeof(*fstack) * (cpu + 1));
+   struct func_stack *ptr;
+
+   ptr = realloc(fstack, sizeof(*fstack) * (cpu + 1));
+   if (!ptr) {
+   warning(could not allocate plugin memory\n);
+   return 0;
+   }
+
+   fstack = ptr;
 
/* Account for holes in the cpu count */
for (i = cpus + 1; i = cpu; i++)
-- 
1.8.3.1

--
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: [BUG] perf stat: explicit grouping yields unexpected results

2013-11-29 Thread Jiri Olsa
On Sat, Nov 16, 2013 at 07:41:34PM -0800, Andi Kleen wrote:
  I'd say that the default behavior should be what Jiri implemented: get 
  the most out of the situation and inform. But you are right in that 
  'forcing' all elements of a group to be valid should be possible as 
  well - if a special perf stat option or event format is used.
 
 When something is multiplexed it can have a very 
 large measurement error. For workloads that fluctuate quite a bit, and the
 fluctuations do not line up well with the multiplexing interval,
 the default scaling does not give good results.
 
 So you expect to get good data, but you get very bad data.
 
 When collecting data for a large number of events it is important
 to group them correctly, so that events that are directly dependent
 on each other in equations are properly grouped.
 
 When explicit groups were added the user likely considered this 
 problem, so it's not good to silently override the choices.
 
 If a user doesn't care they can always not use groups.
 
  Even in that second case it shouldn't say unsupported for everything 
  in the result, but should deny the run immediately and return with an 
  error, and should tell the user how many events in the group fit and 
  which ones didn't.
 
 Returning this information would be great, but it would really 
 need an extended errno, or just a error string reported out.

(sry for late reply, I was still ooo, and missed this conversation)

I agree, when the last event fails sys_perf_event_open
due to the validate_group check, we will get just EINVAL

Was there any discussion about the error (or erorr string)
propagation from sys_perf_event_open?

Something like below? user space supply buffer for error string.

jirka


---
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index e1802d6..a827870 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -331,8 +331,8 @@ struct perf_event_attr {
 */
__u32   sample_stack_user;
 
-   /* Align to u64. */
-   __u32   __reserved_2;
+   __u32   errstr_size;
+   char*errstr;
 };
 
 #define perf_flags(attr)   (*((attr)-read_format + 1))

--
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 v3 1/4] perf diff: color the Delta column

2013-11-29 Thread Jiri Olsa
On Thu, Nov 28, 2013 at 10:54:25PM +0530, Ramkumar Ramachandra wrote:
 Jiri Olsa wrote:
  these colors are not consistent with colors in baseline,
  moreover all negative values are shown as red
 
  - please check get_percent_color function (used for baseline),
it checks the percentage against following values:
 
#define MIN_GREEN   0.5
#define MIN_RED 5.0
 
 That was intentional. If you want colors that are consistent with the
 baseline, what do we do about [4/4], where wdiff numbers can be huge?
 (currently I use [green, red] for [positive, negative] there too)

you're, ratio and wdiff need special treatment..

but I expect delta to be have same colors as baseline
(regardless of the +-)

thanks,
jirka
--
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: [BUG] perf stat: explicit grouping yields unexpected results

2013-11-29 Thread Jiri Olsa
On Fri, Nov 29, 2013 at 02:43:35PM +0100, Stephane Eranian wrote:
 On Fri, Nov 29, 2013 at 2:33 PM, Jiri Olsa jo...@redhat.com wrote:
  On Sat, Nov 16, 2013 at 07:41:34PM -0800, Andi Kleen wrote:
   I'd say that the default behavior should be what Jiri implemented: get
   the most out of the situation and inform. But you are right in that
   'forcing' all elements of a group to be valid should be possible as
   well - if a special perf stat option or event format is used.
 
  When something is multiplexed it can have a very
  large measurement error. For workloads that fluctuate quite a bit, and the
  fluctuations do not line up well with the multiplexing interval,
  the default scaling does not give good results.
 
  So you expect to get good data, but you get very bad data.
 
  When collecting data for a large number of events it is important
  to group them correctly, so that events that are directly dependent
  on each other in equations are properly grouped.
 
  When explicit groups were added the user likely considered this
  problem, so it's not good to silently override the choices.
 
  If a user doesn't care they can always not use groups.
 
   Even in that second case it shouldn't say unsupported for everything
   in the result, but should deny the run immediately and return with an
   error, and should tell the user how many events in the group fit and
   which ones didn't.
 
  Returning this information would be great, but it would really
  need an extended errno, or just a error string reported out.
 
  (sry for late reply, I was still ooo, and missed this conversation)
 
  I agree, when the last event fails sys_perf_event_open
  due to the validate_group check, we will get just EINVAL
 
  Was there any discussion about the error (or erorr string)
  propagation from sys_perf_event_open?
 
  Something like below? user space supply buffer for error string.
 
 No. Why do you need kernel changes for that.
 Perf gets the error, knows it is grouping and prints an appropriate

how does perf know it's grouping and not something else?

 error message. Why do you need kernel for this?

like how would you differentiate EINVAL from validate_group or say
from set_ext_hw_attr (got by using unsupported cache event) ?

jirka
--
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 34/34] perf tools unwinding: Use the per-feature check flags

2013-11-29 Thread Jiri Olsa
On Thu, Nov 28, 2013 at 09:02:23PM +0100, Jean Pihet wrote:
 On 28 November 2013 14:46, Arnaldo Carvalho de Melo a...@infradead.org 
 wrote:
  Em Thu, Nov 28, 2013 at 09:56:19AM -0300, Arnaldo Carvalho de Melo escreveu:
  Em Thu, Nov 28, 2013 at 10:58:01AM +0100, Jiri Olsa escreveu:
   On Wed, Nov 27, 2013 at 11:43:23PM +0100, Jiri Olsa wrote:
On Wed, Nov 27, 2013 at 05:16:34PM -0300, Arnaldo Carvalho de Melo 
wrote:
  LINK perf
/bin/ld: cannot find -lunwind
/bin/ld: cannot find -lunwind-x86_64
collect2: error: ld returned 1 exit status
make[1]: *** [perf] Error 1
make[1]: *** Waiting for unfinished jobs
make: *** [all] Error 2
 
I haven't checked this one.. will do tomorrow
 
   we need to plug libunwind flags/libs only if
   the $(feature-libunwind) is enabled..
 
   NO_LIBUNWIND - user's decision not to link with libunwind or
  architecture that does not support it
 
   $(feature-libunwind) - if it's actually installed
 
   attached change fixies that for me, feel free to use/merge it
 
  Argh, I used tests/make on one machine where those two patches by Jean
  were not applied, then rebased on another, the one I use to submit,
  those got included but not tests/make tested, which probably explains
  why this got thru :-\
 
  Jean, can you please check that this works for you on ARM too?
 
  I just noticed that this patch breaks the feature detection mechanism,
  after it is applied it is back performing all tests at every make call,
  this needs rethinking, so I'm dropping both.
 Oh I am sorry about that. I tested on ARM with and without the
 LIBUNWIND_DIR option set.
 Let me rethink/rework this and come back to you with a proper fix.
 
 
  Ingo, please disregard, yet again, my latest pull request, sigh.
 
  Jiri, this could be something for tests/make, till then I'll try
  to check this manually.
 
 One question though: are you OK with the principle of having
 per-feature check flags? This brings two things to the feature
 detection and build:
 1. the ability to specify specific flags for the feature check, which
 is not possible on the current code,
 2. a simplification in the Makefiles.

looks good to me

jirka
--
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 06/29] tools lib traceevent: Add jbd2 plugin

2013-11-30 Thread Jiri Olsa
On Fri, Nov 29, 2013 at 03:42:35PM -0300, Arnaldo Carvalho de Melo wrote:
 Em Thu, Nov 28, 2013 at 12:33:05PM +0100, Jiri Olsa escreveu:
  Backporting jbd2 plugin.
  
  Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
  
  This plugin adds field resolving functions for following
  tracepoint events:
jbd2:jbd2_checkpoint_stats
jbd2:jbd2_run_stats
  
  The diff of 'perf script' output generated by old and new code:
  (data was generated by 'perf record -e 
  'jbd2:jbd2_run_stats,jbd2:jbd2_checkpoint_stats' -a')
 
 
 The lines after one that starts with
 
 ---
 
 are ignored by 'git am', please ident them with at least one space,
 I'm doing that this time.

oops, ok

thanks,
jirka
--
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/


[PATCHv3 01/29] perf tools: Remove stackprotector feature check

2013-11-30 Thread Jiri Olsa
On Fri, Nov 29, 2013 at 03:34:39PM -0300, Arnaldo Carvalho de Melo wrote:
 Em Thu, Nov 28, 2013 at 12:33:00PM +0100, Jiri Olsa escreveu:
  We use -fstack-protector-all option to enable stack protecting
  for all available functions. There's no reason for enabling
  -Wstack-protector to get warning for unprotected functions.
  
  Removing stackprotector feature check which was used to
  enable the -Wstack-protector option.
 
 Doesn't applies to my perf/core branch.

yep, that's that libunwind stuff messing up ;-)

attaching v3, I could resend whole rebased patchset if
needed.. I also updated my perf/core_plugins branch

thanks,
jirka


---
We use -fstack-protector-all option to enable stack protecting
for all available functions. There's no reason for enabling
-Wstack-protector to get warning for unprotected functions.

Removing stackprotector feature check which was used to
enable the -Wstack-protector option.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@redhat.com
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/perf/config/Makefile | 5 -
 tools/perf/config/feature-checks/Makefile  | 6 +-
 tools/perf/config/feature-checks/test-stackprotector.c | 6 --
 3 files changed, 1 insertion(+), 16 deletions(-)
 delete mode 100644 tools/perf/config/feature-checks/test-stackprotector.c

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 80ea6d8..38f388c2 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -161,7 +161,6 @@ CORE_FEATURE_TESTS =\
libslang\
libunwind   \
on-exit \
-   stackprotector  \
stackprotector-all  \
timerfd
 
@@ -229,10 +228,6 @@ ifeq ($(feature-stackprotector-all), 1)
   CFLAGS += -fstack-protector-all
 endif
 
-ifeq ($(feature-stackprotector), 1)
-  CFLAGS += -Wstack-protector
-endif
-
 ifeq ($(DEBUG),0)
   ifeq ($(feature-fortify-source), 1)
 CFLAGS += -D_FORTIFY_SOURCE=2
diff --git a/tools/perf/config/feature-checks/Makefile 
b/tools/perf/config/feature-checks/Makefile
index 8dffb62..fc78699 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -26,7 +26,6 @@ FILES=\
test-libunwind-debug-frame  \
test-on-exit\
test-stackprotector-all \
-   test-stackprotector \
test-timerfd
 
 CC := $(CC) -MD
@@ -38,7 +37,7 @@ BUILD = $(CC) $(CFLAGS) $(LDFLAGS) -o $(OUTPUT)$@ $@.c
 ###
 
 test-all:
-   $(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror 
-D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang 
-lslang $(shell pkg-config --libs --cflags gtk+-2.0 2/dev/null) 
$(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='perf' -lbfd -ldl
+   $(BUILD) -Werror -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 
-ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config 
--libs --cflags gtk+-2.0 2/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) 
-DPACKAGE='perf' -lbfd -ldl
 
 test-hello:
$(BUILD)
@@ -46,9 +45,6 @@ test-hello:
 test-stackprotector-all:
$(BUILD) -Werror -fstack-protector-all
 
-test-stackprotector:
-   $(BUILD) -Werror -fstack-protector -Wstack-protector
-
 test-fortify-source:
$(BUILD) -O2 -Werror -D_FORTIFY_SOURCE=2
 
diff --git a/tools/perf/config/feature-checks/test-stackprotector.c 
b/tools/perf/config/feature-checks/test-stackprotector.c
deleted file mode 100644
index c9f398d..000
--- a/tools/perf/config/feature-checks/test-stackprotector.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include stdio.h
-
-int main(void)
-{
-   return puts(hi);
-}
-- 
1.8.3.1

--
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 06/29] tools lib traceevent: Add jbd2 plugin

2013-11-30 Thread Jiri Olsa
On Fri, Nov 29, 2013 at 04:31:13PM -0300, Arnaldo Carvalho de Melo wrote:
 Em Fri, Nov 29, 2013 at 03:42:35PM -0300, Arnaldo Carvalho de Melo escreveu:
  Em Thu, Nov 28, 2013 at 12:33:05PM +0100, Jiri Olsa escreveu:
   This plugin adds field resolving functions for following tracepoint 
   events:
 jbd2:jbd2_checkpoint_stats
 jbd2:jbd2_run_stats
 
   The diff of 'perf script' output generated by old and new code:
   (data was generated by 'perf record -e 
   'jbd2:jbd2_run_stats,jbd2:jbd2_checkpoint_stats' -a')
  
  The lines after one that starts with
  
  ---
  
  are ignored by 'git am', please ident them with at least one space,
  I'm doing that this time.
   
   --- script.jbd2.old
   +++ script.jbd2.new
 
 Also I just tried:
 
 [acme@ssdandy linux]$ git log --oneline | head -7
 b0496b02fcea tools lib traceevent: Add hrtimer plugin
 1ec7a71e0b2c tools lib traceevent: Add jbd2 plugin
 c63100c95c6e tools lib traceevent: Add traceevent_host_bigendian function
 d54b335656b7 tools lib traceevent: Add plugin build support
 e796a0d73bcc tools lib traceevent: Add plugin support
 28c803842250 perf tools: Include test-stackprotector-all.c in test-all
 1a69f6ce513d perf timechart: Move wake_events list to 'struct timechart'
 [acme@ssdandy linux]$ 
 
 [acme@ssdandy linux]$ time make O=/tmp/build/perf -C tools/perf/ install
 SNIP successful build
 
 [acme@ssdandy linux]$ ls -la ~/.traceevent
 ls: cannot access /home/acme/.traceevent: No such file or directory
 [acme@ssdandy linux]$
 
 Where did the plugins go? At least two should be there by now, no?

At this stage (patches applied) you'd need to run the
make for traceevent directory.

The perf installation link is done within this patch:
perf tools: Add build and install plugins targets

which I presume you haven't applied yet? 

jirka
--
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 v4 1/3] perf diff: color the Delta column

2013-12-01 Thread Jiri Olsa
On Fri, Nov 29, 2013 at 07:06:30PM +0530, Ramkumar Ramachandra wrote:
 Color the numbers in the Delta column using percent_color_snprintf().
 Generalize the function so that we can accommodate all three comparison
 methods in the future: delta, ratio, and wdiff.
 
 Cc: Jiri Olsa jo...@redhat.com
 Cc: Arnaldo Carvalho de Melo a...@redhat.com
 Signed-off-by: Ramkumar Ramachandra artag...@gmail.com
 ---
  tools/perf/builtin-diff.c | 49 
 ++-
  1 file changed, 48 insertions(+), 1 deletion(-)
 
 diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
 index 3b67ea2..c970aae 100644
 --- a/tools/perf/builtin-diff.c
 +++ b/tools/perf/builtin-diff.c
 @@ -769,6 +769,45 @@ static int hpp__entry_baseline(struct hist_entry *he, 
 char *buf, size_t size)
   return ret;
  }
  
 +static int __hpp__color_compare(struct perf_hpp_fmt *fmt,
 + struct perf_hpp *hpp, struct hist_entry *he,
 + int comparison_method)
 +{
 + struct diff_hpp_fmt *dfmt =
 + container_of(fmt, struct diff_hpp_fmt, fmt);
 + struct hist_entry *pair = get_pair_fmt(he, dfmt);
 + double diff;
 + char pfmt[20] =  ;
 +
 + if (!pair)
 + goto dummy_print;
 +
 + switch(comparison_method){
 + case COMPUTE_DELTA:
 + if (pair-diff.computed)
 + diff = pair-diff.period_ratio_delta;
 + else
 + diff = compute_delta(he, pair);
 +
 + if (fabs(diff)  0.01)
 + goto dummy_print;
 + scnprintf(pfmt, 20, %%%+d.2f, dfmt-header_width - 1);
 + return percent_color_snprintf(hpp-buf, hpp-size,
 + pfmt, fabs(diff));

we dont want print fabs(diff)..  we just want percent_color_snprintf
assign proper color for negative numbers, the change needs to go there

jirka
--
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 v4 2/3] perf diff: color the Ratio column

2013-12-01 Thread Jiri Olsa
On Fri, Nov 29, 2013 at 07:06:31PM +0530, Ramkumar Ramachandra wrote:
 In
 
   $ perf diff -c ratio
 
 color the Ratio column using percent_color_snprintf().
 
 Cc: Jiri Olsa jo...@redhat.com
 Cc: Arnaldo Carvalho de Melo a...@redhat.com
 Signed-off-by: Ramkumar Ramachandra artag...@gmail.com
 ---
  tools/perf/builtin-diff.c | 20 
  1 file changed, 20 insertions(+)
 
 diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
 index c970aae..25dac6c 100644
 --- a/tools/perf/builtin-diff.c
 +++ b/tools/perf/builtin-diff.c
 @@ -794,6 +794,17 @@ static int __hpp__color_compare(struct perf_hpp_fmt *fmt,
   scnprintf(pfmt, 20, %%%+d.2f, dfmt-header_width - 1);
   return percent_color_snprintf(hpp-buf, hpp-size,
   pfmt, fabs(diff));
 + case COMPUTE_RATIO:
 + if (he-dummy)
 + goto dummy_print;
 + if (pair-diff.computed)
 + diff = pair-diff.period_ratio;
 + else
 + diff = compute_ratio(he, pair);
 +
 + scnprintf(pfmt, 20, %%%d.6f, dfmt-header_width);
 + return percent_color_snprintf(hpp-buf, hpp-size,
 + pfmt, diff);

ok, lets keep same limits for ratio and wdiff.. unless
we hear otherwise ;-)

Arnaldo,
I think we want to add something like 'value_color_snprintf' ?
to keep percent/values separated..

It'd do the same job, just the name does not fit in here,
because we are printing out ratio values.

thanks,
jirka
--
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 06/29] tools lib traceevent: Add jbd2 plugin

2013-12-02 Thread Jiri Olsa
On Mon, Dec 02, 2013 at 04:26:51PM -0300, Arnaldo Carvalho de Melo wrote:
 Em Sat, Nov 30, 2013 at 05:49:21PM +0100, Jiri Olsa escreveu:
  On Fri, Nov 29, 2013 at 04:31:13PM -0300, Arnaldo Carvalho de Melo wrote:
   Em Fri, Nov 29, 2013 at 03:42:35PM -0300, Arnaldo Carvalho de Melo 
   escreveu:
   Also I just tried:
 
   [acme@ssdandy linux]$ git log --oneline | head -7
   b0496b02fcea tools lib traceevent: Add hrtimer plugin
   1ec7a71e0b2c tools lib traceevent: Add jbd2 plugin
   c63100c95c6e tools lib traceevent: Add traceevent_host_bigendian function
   d54b335656b7 tools lib traceevent: Add plugin build support
   e796a0d73bcc tools lib traceevent: Add plugin support
   28c803842250 perf tools: Include test-stackprotector-all.c in test-all
   1a69f6ce513d perf timechart: Move wake_events list to 'struct timechart'
   [acme@ssdandy linux]$ 
 
   [acme@ssdandy linux]$ time make O=/tmp/build/perf -C tools/perf/ install
   SNIP successful build
 
   [acme@ssdandy linux]$ ls -la ~/.traceevent
   ls: cannot access /home/acme/.traceevent: No such file or directory
   [acme@ssdandy linux]$
 
   Where did the plugins go? At least two should be there by now, no?
  
  At this stage (patches applied) you'd need to run the make for
  traceevent directory.
  
  The perf installation link is done within this patch:
  perf tools: Add build and install plugins targets
  
  which I presume you haven't applied yet? 
 
 No I haven't, and I expected that I could test it straight away, so I
 suggest you reorder the patches so that, right after the first plugin is
 introduced a:
 
   make -C tools/perf install
 
 in all its variants (in place, with O=, etc) allows one to test it.

ok, I will send v3

jirka
--
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: [PATCHSET 0/8] perf tools: Fix scalability problem on callchain merging (v5)

2013-10-13 Thread Jiri Olsa
On Fri, Oct 11, 2013 at 04:04:43PM -0600, David Ahern wrote:
 On 10/11/13 3:51 PM, Andi Kleen wrote:
 David Ahern dsah...@gmail.com writes:
 
 On 10/11/13 9:11 AM, David Ahern wrote:
 It would be nice to fix the callchain arg handler to not attempt to
 process the next argument if it is not fp or dwarf.
 
 Specifically, something like this which maintains syntax and default
 fp option:
 
 Yes please! This happens to me all the time too
 
 (usually I train myself to use -g --, but i still sometimes forget)
 
 It still wouldn't handle -ga, but naked -g seems to be the common case.
 
 grrr... you're right. I ran right through that. With -ga the 'a' gets lost.
 
 This seems to do the trick:
 
 diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
 index 92ca541..726d2c2 100644
 --- a/tools/perf/builtin-record.c
 +++ b/tools/perf/builtin-record.c
 @@ -721,7 +721,11 @@ int record_parse_callchain_opt(const struct
 option *opt,
 return 0;
 
 /* We specified default option if none is provided. */
 -   BUG_ON(!arg);
 +   if (!arg) {
 +   opts-call_graph = CALLCHAIN_FP;
 +   return 0;
 +   }
 +
 
 /* We need buffer that we know we can write to. */
 buf = malloc(strlen(arg) + 1);
 @@ -766,8 +770,8 @@ int record_parse_callchain_opt(const struct option *opt,
  opts-stack_dump_size);
  #endif /* HAVE_LIBUNWIND_SUPPORT */
 } else {
 -   pr_err(callchain: Unknown -g option 
 -  value: %s\n, arg);
 +   opts-call_graph = CALLCHAIN_FP;
 +   ret = 0;
 break;
 }
 
 @@ -855,7 +859,7 @@ const struct option record_options[] = {
  perf_evlist__parse_mmap_pages),
 OPT_BOOLEAN(0, group, record.opts.group,
 put the counters into a counter group),
 -   OPT_CALLBACK_DEFAULT('g', call-graph, record.opts,
 +   OPT_CALLBACK_DEFAULT_NOOPT('g', call-graph, record.opts,

hum, this disables the option completely, no?

The issue is a consequence of allowing '-g' to have carry
a value (dwarf,fp). Maybe we could have some sort of new
OPT_OPTION type, where if its value is not recognized it
would be passed to next option.

Or the way Ingo suggested earlier:

---
So, why not keep -g as a shortcut to whatever default call-graph profiling
we want to provide (note, this does not mean it always has to be 'fp'),
and use --call-graph for more specific variants?

a .perfconfig value could even set the default for '-g', so that you don't
have to type '--call-graph dwarf' all the time.
---

I'll try to come up with something later today

jirka
--
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: [PATCHSET 0/8] perf tools: Fix scalability problem on callchain merging (v5)

2013-10-13 Thread Jiri Olsa
On Fri, Oct 11, 2013 at 02:15:35PM +0900, Namhyung Kim wrote:
 Hello,
 
 This is a new version of callchain improvement patchset.  Basically
 it's almost same as v4 but rebased on current acme/perf/core and some
 functions are renamed as Frederic requested.
 
 Now I'm hunting down a bug in 'perf report -s sym' which was found
 during the test, but I think it's not related to this change as it can
 be reproduced in earlier versions too.
 
 I put this series on 'perf/callchain-v5' branch in my tree
 
   git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
hi,
while hunting another issue, I got segfault in callchains code:

Press '?' for help on key bindings
Program received signal SIGSEGV, Segmentation fault.
0x004dcd89 in callchain_node__init_have_children_rb_tree 
(node=0x21a0330) at ui/browsers/hists.c:158
158 chain-ms.has_children = 
chain-list.next == child-val 
Missing separate debuginfos, use: debuginfo-install 
audit-libs-2.2.1-1.fc16.x86_64 elfutils-libelf-0.154-2.fc16.x86_64 
elfutils-libs-0.154-2.fc16.x86_64 glibc-2.14.90-24.fc16.9.x86_64 
libunwind-0.99-2.20110424git1e10c293.fc16.x86_64 
nss-softokn-freebl-3.14.1-3.fc16.x86_64 numactl-2.0.7-2.fc16.x86_64 
perl-libs-5.14.3-205.fc16.x86_64 python-libs-2.7.3-4.fc16.x86_64 
slang-2.2.4-1.fc16.x86_64 xz-libs-5.1.1-1alpha.fc16.x86_64 
zlib-1.2.5-7.fc16.x86_64
(gdb) bt
#0  0x004dcd89 in callchain_node__init_have_children_rb_tree 
(node=0x21a0330) at ui/browsers/hists.c:158
#1  0x004dcdf9 in callchain_node__init_have_children_rb_tree 
(node=0x1fa90a0) at ui/browsers/hists.c:162
#2  0x004dcead in callchain_node__init_have_children (node=0x1fa90a0) 
at ui/browsers/hists.c:173
#3  0x004dcf10 in callchain__init_have_children (root=0x1fa8ff8) at 
ui/browsers/hists.c:182
#4  0x004dcf97 in hist_entry__init_have_children (he=0x1fa8f00) at 
ui/browsers/hists.c:190
#5  0x004debf3 in hist_browser__show_entry (browser=0xa27010, 
entry=0x1fa8f00, row=66) at ui/browsers/hists.c:739
#6  0x004df062 in hist_browser__refresh (browser=0xa27010) at 
ui/browsers/hists.c:823
#7  0x004d8487 in __ui_browser__refresh (browser=0xa27010) at 
ui/browser.c:307
#8  0x004d8681 in ui_browser__run (browser=0xa27010, delay_secs=0) at 
ui/browser.c:362
#9  0x004dd6a7 in hist_browser__run (browser=0xa27010, ev_name=0xa26ff0 
cycles:pp, hbt=0x0) at ui/browsers/hists.c:335
#10 0x004e0d9b in perf_evsel__hists_browse (evsel=0xa24b60, 
nr_events=1, 
helpline=0x58e588 For a higher level overview, try: perf report --sort 
comm,dso, ev_name=0xa26ff0 cycles:pp, left_exits=false, 
hbt=0x0, min_pcnt=0, env=0xa23f90) at ui/browsers/hists.c:1430
#11 0x004e2605 in perf_evlist__tui_browse_hists (evlist=0xa242e0, 
help=0x58e588 For a higher level overview, try: perf report --sort 
comm,dso, hbt=0x0, min_pcnt=0, env=0xa23f90)
at ui/browsers/hists.c:1950
#12 0x0042c3cb in __cmd_report (rep=0x7fffdf40) at 
builtin-report.c:590
#13 0x0042d84a in cmd_report (argc=0, argv=0x7fffe3a0, prefix=0x0) 
at builtin-report.c:988
#14 0x00418fed in run_builtin (p=0x803c28, argc=5, argv=0x7fffe3a0) 
at perf.c:319
#15 0x00419225 in handle_internal_command (argc=5, argv=0x7fffe3a0) 
at perf.c:376
#16 0x00419371 in run_argv (argcp=0x7fffe27c, argv=0x7fffe270) 
at perf.c:420
#17 0x00419658 in main (argc=5, argv=0x7fffe3a0) at perf.c:529


I got it on the original code, so I've tried your's
perf/callchain-v5 with same result.

I put perf archive and data output in here if you're interested:
http://people.redhat.com/jolsa/cc/

thanks,
jirka
--
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/


[RFC] perf record,top: Add callchain option into .perfconfig

2013-10-13 Thread Jiri Olsa
On Sun, Oct 13, 2013 at 12:25:21PM +0200, Jiri Olsa wrote:

SNIP

 
 I'll try to come up with something later today
 
 jirka


hi,
here it is.. not fully tested, no doc updates, dont want
to go too far before we agreed on this ;-)

thanks for comments,
jirka

--
The callchain option is now used only to enable
callchains. By default it's framepointer type.

If dwarf unwind is needed, following option needs
to be added into .perfconfig:

for top command:
  [top]
call-graph = dwarf,8192

for record command:
  [record]
call-graph = dwarf,8192

running perf with above config like this:
perf record -g ls
perf top -G

will enable dwarf unwind. The config file option
by itself does not enable the callchain, the -g/-G
option does.

TODO: doc/help needs to be updated

Signed-off-by: Jiri Olsa jo...@redhat.com
---
 tools/perf/builtin-record.c | 58 ++---
 tools/perf/builtin-top.c| 23 +++---
 tools/perf/perf.h   |  1 +
 tools/perf/util/callchain.h |  4 +++-
 tools/perf/util/evsel.c |  2 +-
 5 files changed, 58 insertions(+), 30 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 92ca541..9b245d3 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -709,19 +709,35 @@ static int get_stack_size(char *str, unsigned long *_size)
 #endif /* HAVE_LIBUNWIND_SUPPORT */
 
 int record_parse_callchain_opt(const struct option *opt,
-  const char *arg, int unset)
+  const char *arg __maybe_unused,
+  int unset)
 {
struct perf_record_opts *opts = opt-value;
-   char *tok, *name, *saveptr = NULL;
-   char *buf;
-   int ret = -1;
+
+   opts-call_graph_enabled = !unset;
 
/* --no-call-graph */
-   if (unset)
+   if (unset) {
+   opts-call_graph = CALLCHAIN_NONE;
return 0;
+   }
+
+   if (opts-call_graph == CALLCHAIN_NONE)
+   opts-call_graph = CALLCHAIN_FP;
+
+   pr_debug(callchain: type %d\n, opts-call_graph);
+
+   if (opts-call_graph == CALLCHAIN_DWARF)
+   pr_debug(callchain: stack dump size %d\n,
+opts-stack_dump_size);
+   return 0;
+}
 
-   /* We specified default option if none is provided. */
-   BUG_ON(!arg);
+int record_parse_callchain(const char *arg, struct perf_record_opts *opts)
+{
+   char *tok, *name, *saveptr = NULL;
+   char *buf;
+   int ret = -1;
 
/* We need buffer that we know we can write to. */
buf = malloc(strlen(arg) + 1);
@@ -740,7 +756,7 @@ int record_parse_callchain_opt(const struct option *opt,
opts-call_graph = CALLCHAIN_FP;
ret = 0;
} else
-   pr_err(callchain: No more arguments 
+   fprintf(stderr, callchain: No more arguments 
   needed for -g fp\n);
break;
 
@@ -760,13 +776,9 @@ int record_parse_callchain_opt(const struct option *opt,
ret = get_stack_size(tok, size);
opts-stack_dump_size = size;
}
-
-   if (!ret)
-   pr_debug(callchain: stack dump size %d\n,
-opts-stack_dump_size);
 #endif /* HAVE_LIBUNWIND_SUPPORT */
} else {
-   pr_err(callchain: Unknown -g option 
+   fprintf(stderr, callchain: Unknown -g option 
   value: %s\n, arg);
break;
}
@@ -774,11 +786,17 @@ int record_parse_callchain_opt(const struct option *opt,
} while (0);
 
free(buf);
+   return ret;
+}
 
-   if (!ret)
-   pr_debug(callchain: type %d\n, opts-call_graph);
+static int perf_record_config(const char *var, const char *value, void *cb)
+{
+   struct perf_record *rec = cb;
 
-   return ret;
+   if (!strcmp(var, record.call-graph))
+   return record_parse_callchain(value, rec-opts);
+
+   return perf_default_config(var, value, cb);
 }
 
 static const char * const record_usage[] = {
@@ -855,9 +873,9 @@ const struct option record_options[] = {
 perf_evlist__parse_mmap_pages),
OPT_BOOLEAN(0, group, record.opts.group,
put the counters into a counter group),
-   OPT_CALLBACK_DEFAULT('g', call-graph, record.opts,
-mode[,dump_size], record_callchain_help,
-record_parse_callchain_opt, fp),
+   OPT_CALLBACK_NOOPT('g', call-graph, record.opts,
+  mode[,dump_size], record_callchain_help,
+  record_parse_callchain_opt

[PATCH] perf make: Move DEBUG initialization into Makefile.perf

2013-10-13 Thread Jiri Olsa
Adding new top level Makefile invalidated the
DEBUG variable check for command line origin.

Moving this check into Makefile.perf.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: David Ahern dsah...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/Makefile| 6 +-
 tools/perf/config/Makefile | 3 ---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 5aa3d04..db21dad 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -37,12 +37,16 @@ ifneq ($(O),)
   FULL_O := $(shell readlink -f $(O))
 endif
 
+ifeq ($(origin DEBUG), command line)
+  D = $(DEBUG)
+endif
+
 define print_msg
   @printf '  BUILD:   Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel 
build\n'
 endef
 
 define make
-  @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $@
+  @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) 
PERF_DEBUG=$(D) $@
 endef
 
 #
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 9680424..912026a 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -66,9 +66,6 @@ ifneq ($(WERROR),0)
   CFLAGS += -Werror
 endif
 
-ifeq ($(origin DEBUG), command line)
-  PERF_DEBUG = $(DEBUG)
-endif
 ifndef PERF_DEBUG
   CFLAGS += -O6
 endif
-- 
1.7.11.7

--
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: [PATCHSET 0/8] perf tools: Fix scalability problem on callchain merging (v5)

2013-10-14 Thread Jiri Olsa
On Mon, Oct 14, 2013 at 01:50:09PM +0900, Namhyung Kim wrote:
 On Sun, 13 Oct 2013 14:34:44 +0200, Jiri Olsa wrote:
  I put perf archive and data output in here if you're interested:
  http://people.redhat.com/jolsa/cc/
 
 I can't download the data output (but the archive is fine).
 
   $ curl http://people.redhat.com/jolsa/cc/perf.data
   !DOCTYPE HTML PUBLIC -//IETF//DTD HTML 2.0//EN
   htmlhead
   title403 Forbidden/title
   /headbody
   h1Forbidden/h1
   pYou don't have permission to access /jolsa/cc/perf.data
   on this server./p
   hr
   addressApache Server at people.redhat.com Port 80/address
   /body/html

oops, should be fixed now.. haven't checked persmissions :-\

jirka
--
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 make: Move DEBUG initialization into Makefile.perf

2013-10-14 Thread Jiri Olsa
On Mon, Oct 14, 2013 at 09:16:11AM +0200, Ingo Molnar wrote:
 
 * Jiri Olsa jo...@redhat.com wrote:
 
  Adding new top level Makefile invalidated the
  DEBUG variable check for command line origin.
  
  Moving this check into Makefile.perf.
 
 This ought to be fixed in my latest tip:tmp.perf branch. The fix commit in 
 particular is:
 
   91a7b6db20ae tools/perf/build: Pass through DEBUG parameter
 
 I'm waiting for Arnaldo to send an updated perf/core and then I will 
 double check whether any of the fixes is missing.

ook, thanks

jirka
--
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 record: mmap output file - v2

2013-10-15 Thread Jiri Olsa
On Tue, Oct 15, 2013 at 09:25:40AM +0200, Ingo Molnar wrote:
 
 * Namhyung Kim namhy...@kernel.org wrote:
 
   3)
  
   The rec-bytes_at_mmap_start field feels a bit weird. If I read the code 
   correctly, in every 'perf record' invocation, rec-bytes_written starts 
   at 
   0 - i.e. we don't have repeat invocations of cmd_record().
  
  rec-bytes_written is updated when it writes to the output file for 
  synthesizing COMM/MMAP events (this mmap output is not used at that 
  time).
 
 Btw., while looking into it, I think advance_output() needlessly 
 obfuscates as well:
 
 static void advance_output(struct perf_record *rec, size_t size)
 {
 rec-bytes_written += size;
 }
 
 that code should just be written open coded.
 
 So I think all this needs a few good rounds of cleanups, before we can 
 complicate it with a new feature. (the cleanups can be on top of the 
 feature, if they go in at the same time.)

I sent some file code cleanup week ago, I'll rebase
and resend it soon:
http://marc.info/?l=linux-kernelm=138113836428425w=2

it's mostly about centralizing the code into file
object.. got no comments so far

jirka
--
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 1/3] perf tools: Add data object to handle perf data file

2013-10-15 Thread Jiri Olsa
This patch is adding 'struct perf_data_file' object as
a placeholder for all attributes regarding perf.data
file handling. Changing perf_session__new to take it
as an argument.

The rest of the functionality will be added later to keep
this change simple enough, because all the places using
perf_session are changed now.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@redhat.com
Cc: David Ahern dsah...@gmail.com
Cc: Adrian Hunter adrian.hun...@intel.com
Cc: Andi Kleen a...@firstfloor.org
---
 tools/perf/builtin-annotate.c  |  9 --
 tools/perf/builtin-buildid-cache.c |  8 +++--
 tools/perf/builtin-buildid-list.c  |  9 --
 tools/perf/builtin-diff.c  | 19 +++-
 tools/perf/builtin-evlist.c|  7 -
 tools/perf/builtin-inject.c|  7 -
 tools/perf/builtin-kmem.c  |  7 -
 tools/perf/builtin-kvm.c   | 13 ++--
 tools/perf/builtin-lock.c  |  7 -
 tools/perf/builtin-mem.c   |  9 --
 tools/perf/builtin-record.c| 61 --
 tools/perf/builtin-report.c| 10 +--
 tools/perf/builtin-sched.c |  6 +++-
 tools/perf/builtin-script.c| 15 --
 tools/perf/builtin-timechart.c | 10 +--
 tools/perf/builtin-top.c   |  6 +++-
 tools/perf/builtin-trace.c |  8 +++--
 tools/perf/perf.h  |  1 -
 tools/perf/util/data.h | 29 ++
 tools/perf/util/session.c  | 12 
 tools/perf/util/session.h  |  6 ++--
 21 files changed, 186 insertions(+), 73 deletions(-)
 create mode 100644 tools/perf/util/data.h

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 94f9a8e..95df683 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -28,6 +28,7 @@
 #include util/hist.h
 #include util/session.h
 #include util/tool.h
+#include util/data.h
 #include arch/common.h
 
 #include dlfcn.h
@@ -199,9 +200,13 @@ static int __cmd_annotate(struct perf_annotate *ann)
struct perf_session *session;
struct perf_evsel *pos;
u64 total_nr_samples;
+   struct perf_data_file file = {
+   .path  = input_name,
+   .mode  = PERF_DATA_MODE_READ,
+   .force = ann-force,
+   };
 
-   session = perf_session__new(input_name, O_RDONLY,
-   ann-force, false, ann-tool);
+   session = perf_session__new(file, false, ann-tool);
if (session == NULL)
return -ENOMEM;
 
diff --git a/tools/perf/builtin-buildid-cache.c 
b/tools/perf/builtin-buildid-cache.c
index 8140b7b..cfede86 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -221,8 +221,12 @@ static bool dso__missing_buildid_cache(struct dso *dso, 
int parm __maybe_unused)
 
 static int build_id_cache__fprintf_missing(const char *filename, bool force, 
FILE *fp)
 {
-   struct perf_session *session = perf_session__new(filename, O_RDONLY,
-force, false, NULL);
+   struct perf_data_file file = {
+   .path  = filename,
+   .mode  = PERF_DATA_MODE_READ,
+   .force = force,
+   };
+   struct perf_session *session = perf_session__new(file, false, NULL);
if (session == NULL)
return -1;
 
diff --git a/tools/perf/builtin-buildid-list.c 
b/tools/perf/builtin-buildid-list.c
index e74366a..0164c1c 100644
--- a/tools/perf/builtin-buildid-list.c
+++ b/tools/perf/builtin-buildid-list.c
@@ -15,6 +15,7 @@
 #include util/parse-options.h
 #include util/session.h
 #include util/symbol.h
+#include util/data.h
 
 static int sysfs__fprintf_build_id(FILE *fp)
 {
@@ -52,6 +53,11 @@ static bool dso__skip_buildid(struct dso *dso, int with_hits)
 static int perf_session__list_build_ids(bool force, bool with_hits)
 {
struct perf_session *session;
+   struct perf_data_file file = {
+   .path  = input_name,
+   .mode  = PERF_DATA_MODE_READ,
+   .force = force,
+   };
 
symbol__elf_init();
/*
@@ -60,8 +66,7 @@ static int perf_session__list_build_ids(bool force, bool 
with_hits)
if (filename__fprintf_build_id(input_name, stdout))
goto out;
 
-   session = perf_session__new(input_name, O_RDONLY, force, false,
-   build_id__mark_dso_hit_ops);
+   session = perf_session__new(file, false, build_id__mark_dso_hit_ops);
if (session == NULL)
return -1;
/*
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 2a78dc8..419d27d 100644

[PATCH 2/3] perf tools: Add perf_data_file__open interface to data object

2013-10-15 Thread Jiri Olsa
Adding perf_data_file__open interface to data object
to open the perf.data file for both read and write.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@redhat.com
Cc: David Ahern dsah...@gmail.com
Cc: Adrian Hunter adrian.hun...@intel.com
Cc: Andi Kleen a...@firstfloor.org
---
 tools/perf/Makefile.perf|   1 +
 tools/perf/builtin-record.c |  34 +
 tools/perf/builtin-top.c|   9 +---
 tools/perf/util/data.c  | 120 
 tools/perf/util/data.h  |   4 ++
 tools/perf/util/session.c   |  95 +++
 tools/perf/util/session.h   |   2 +-
 7 files changed, 158 insertions(+), 107 deletions(-)
 create mode 100644 tools/perf/util/data.c

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index c873e03..326a26e 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -365,6 +365,7 @@ LIB_OBJS += $(OUTPUT)util/vdso.o
 LIB_OBJS += $(OUTPUT)util/stat.o
 LIB_OBJS += $(OUTPUT)util/record.o
 LIB_OBJS += $(OUTPUT)util/srcline.o
+LIB_OBJS += $(OUTPUT)util/data.o
 
 LIB_OBJS += $(OUTPUT)ui/setup.o
 LIB_OBJS += $(OUTPUT)ui/helpline.o
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 37088f9..d83d54a 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -345,8 +345,6 @@ out:
 
 static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
 {
-   struct stat st;
-   int flags;
int err, feat;
unsigned long waking = 0;
const bool forks = argc  0;
@@ -355,7 +353,6 @@ static int __cmd_record(struct perf_record *rec, int argc, 
const char **argv)
struct perf_record_opts *opts = rec-opts;
struct perf_evlist *evsel_list = rec-evlist;
struct perf_data_file *file = rec-file;
-   const char *output_name = file-path;
struct perf_session *session;
bool disabled = false;
 
@@ -367,35 +364,6 @@ static int __cmd_record(struct perf_record *rec, int argc, 
const char **argv)
signal(SIGUSR1, sig_handler);
signal(SIGTERM, sig_handler);
 
-   if (!output_name) {
-   if (!fstat(STDOUT_FILENO, st)  S_ISFIFO(st.st_mode))
-   file-is_pipe = true;
-   else
-   file-path = output_name = perf.data;
-   }
-   if (output_name) {
-   if (!strcmp(output_name, -))
-   file-is_pipe = true;
-   else if (!stat(output_name, st)  st.st_size) {
-   char oldname[PATH_MAX];
-   snprintf(oldname, sizeof(oldname), %s.old,
-output_name);
-   unlink(oldname);
-   rename(output_name, oldname);
-   }
-   }
-
-   flags = O_CREAT|O_RDWR|O_TRUNC;
-
-   if (file-is_pipe)
-   file-fd = STDOUT_FILENO;
-   else
-   file-fd = open(output_name, flags, S_IRUSR | S_IWUSR);
-   if (file-fd  0) {
-   perror(failed to create output file);
-   return -1;
-   }
-
session = perf_session__new(file, false, NULL);
if (session == NULL) {
pr_err(Not enough memory for reading perf file header\n);
@@ -586,7 +554,7 @@ static int __cmd_record(struct perf_record *rec, int argc, 
const char **argv)
fprintf(stderr,
[ perf record: Captured and wrote %.3f MB %s (~% PRIu64  
samples) ]\n,
(double)rec-bytes_written / 1024.0 / 1024.0,
-   output_name,
+   file-path,
rec-bytes_written / 24);
 
return 0;
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 752bebe..d934f70 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -929,15 +929,8 @@ static int __cmd_top(struct perf_top *top)
struct perf_record_opts *opts = top-record_opts;
pthread_t thread;
int ret;
-   struct perf_data_file file = {
-   .mode = PERF_DATA_MODE_WRITE,
-   };
 
-   /*
-* FIXME: perf_session__new should allow passing a O_MMAP, so that all 
this
-* mmap reading, etc is encapsulated in it. Use O_WRONLY for now.
-*/
-   top-session = perf_session__new(file, false, NULL);
+   top-session = perf_session__new(NULL, false, NULL);
if (top-session == NULL)
return -ENOMEM;
 
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
new file mode 100644
index 000..7d09faf
--- /dev/null
+++ b/tools/perf/util/data.c
@@ -0,0 +1,120 @@
+#include linux/compiler.h
+#include linux/kernel.h
+#include sys/types.h
+#include sys/stat.h
+#include

[PATCH 3/3] perf tools: Separating data file properties from session

2013-10-15 Thread Jiri Olsa
Removing 'fd, fd_pipe, filename, size' from struct perf_session
and replacing them with struct perf_data_file object.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@redhat.com
Cc: David Ahern dsah...@gmail.com
Cc: Adrian Hunter adrian.hun...@intel.com
Cc: Andi Kleen a...@firstfloor.org
---
 tools/perf/builtin-annotate.c |  2 +-
 tools/perf/builtin-buildid-list.c |  2 +-
 tools/perf/builtin-record.c   |  1 -
 tools/perf/builtin-report.c   |  8 +---
 tools/perf/builtin-script.c   |  2 +-
 tools/perf/util/data.h| 15 +++
 tools/perf/util/header.c  | 22 +-
 tools/perf/util/session.c | 36 +++-
 tools/perf/util/session.h |  5 +
 9 files changed, 56 insertions(+), 37 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 95df683..03cfa59 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -259,7 +259,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
}
 
if (total_nr_samples == 0) {
-   ui__error(The %s file has no samples!\n, session-filename);
+   ui__error(The %s file has no samples!\n, file.path);
goto out_delete;
}
 
diff --git a/tools/perf/builtin-buildid-list.c 
b/tools/perf/builtin-buildid-list.c
index 0164c1c..ed3873b 100644
--- a/tools/perf/builtin-buildid-list.c
+++ b/tools/perf/builtin-buildid-list.c
@@ -73,7 +73,7 @@ static int perf_session__list_build_ids(bool force, bool 
with_hits)
 * in pipe-mode, the only way to get the buildids is to parse
 * the record stream. Buildids are stored as RECORD_HEADER_BUILD_ID
 */
-   if (with_hits || session-fd_pipe)
+   if (with_hits || perf_data_file__is_pipe(file))
perf_session__process_events(session, 
build_id__mark_dso_hit_ops);
 
perf_session__fprintf_dsos_buildid(session, stdout, dso__skip_buildid, 
with_hits);
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index d83d54a..e02e129 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -257,7 +257,6 @@ static int process_buildids(struct perf_record *rec)
if (size == 0)
return 0;
 
-   session-fd = file-fd;
return __perf_session__process_events(session, 
rec-post_processing_offset,
  size - 
rec-post_processing_offset,
  size, 
build_id__mark_dso_hit_ops);
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 60d7f8e..fa68a36 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -368,8 +368,9 @@ static int perf_report__setup_sample_type(struct 
perf_report *rep)
 {
struct perf_session *self = rep-session;
u64 sample_type = perf_evlist__combined_sample_type(self-evlist);
+   bool is_pipe = perf_data_file__is_pipe(self-file);
 
-   if (!self-fd_pipe  !(sample_type  PERF_SAMPLE_CALLCHAIN)) {
+   if (!is_pipe  !(sample_type  PERF_SAMPLE_CALLCHAIN)) {
if (sort__has_parent) {
ui__error(Selected --sort parent, but no 
callchain data. Did you call 
@@ -392,7 +393,7 @@ static int perf_report__setup_sample_type(struct 
perf_report *rep)
}
 
if (sort__mode == SORT_MODE__BRANCH) {
-   if (!self-fd_pipe 
+   if (!is_pipe 
!(sample_type  PERF_SAMPLE_BRANCH_STACK)) {
ui__error(Selected -b but no branch data. 
  Did you call perf record without -b?\n);
@@ -488,6 +489,7 @@ static int __cmd_report(struct perf_report *rep)
struct map *kernel_map;
struct kmap *kernel_kmap;
const char *help = For a higher level overview, try: perf report 
--sort comm,dso;
+   struct perf_data_file *file = session-file;
 
signal(SIGINT, sig_handler);
 
@@ -572,7 +574,7 @@ static int __cmd_report(struct perf_report *rep)
return 0;
 
if (nr_samples == 0) {
-   ui__error(The %s file has no samples!\n, session-filename);
+   ui__error(The %s file has no samples!\n, file-path);
return 0;
}
 
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 2fe06a4..3866e52 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1523,7 +1523,7 @@ int cmd_script(int argc, const char **argv, const char 
*prefix __maybe_unused)
return -1;
}
 
-   input = open

Re: [PATCH] tools lib traceevent: Add direct access to dynamic arrays

2013-11-12 Thread Jiri Olsa
On Mon, Nov 11, 2013 at 04:08:10PM -0500, Steven Rostedt wrote:
 
 Jiri Olsa was writing a plugin for the cfg80211_tx_mlme_mgmt trace
 event, and was not able to get the implemented function working.
 The event's print fmt looks like:
 
netdev:%s(%d), ftype:0x%.2x, REC-name, REC-ifindex,
 __le16_to_cpup((__le16 *)__get_dynamic_array(frame))
 
 As there's no helper function for __le16_to_cpup(), Jiri was creating one
 with a plugin. But unfortunately, it would not work even though he set
 up the plugin correctly.
 
 The problem is that the function parameters do not handle the helper
 function __get_dynamic_array(), and that passes in a NULL pointer.
 
 Adding PRINT_DYNAMIC_ARRAY direct support to eval_num_arg() allows the
 use of __get_dynamic_array() in function parameters.
 
 Reported-by: Jiri Olsa jo...@redhat.com
 Signed-off-by: Steven Rostedt rost...@goodmis.org

cool, thanks

Tested-by: Jiri Olsa jo...@redhat.com


jirka
--
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 top: Make -g refer to callchains

2013-11-18 Thread Jiri Olsa
On Mon, Nov 18, 2013 at 09:59:45AM -0300, Arnaldo Carvalho de Melo wrote:
 Em Fri, Nov 15, 2013 at 06:46:09AM +0100, Ingo Molnar escreveu:
  btw., here's some 'perf top' call graph performance and profiling 
  quality feedback, with the latest perf code:
  
  'perf top --call-graph fp' now works very well, using just 0.2% 
  of CPU time on a fast system:
  
   4676 mingo 20   0  612m  56m 9948 S 1  0.2   0:00.68 perf  
  

  
  'perf top --call-graph dwarf' on the other hand is horrendously 
  slow, using 20% of CPU time on a 4 GHz CPU:
  
PID USER  PR  NI  VIRT  RES  SHR S  %CPU %MEMTIME+  COMMAND   
  

   4646 mingo 20   0  658m  81m  12m R19  0.3   0:18.17 perf
  
  On another system with a 2.4GHz CPU it's taking up 100% of CPU 
  time (!):
  
PID USER  PR  NIVIRTRESSHR S  %CPU %MEM TIME+ COMMAND 
  

   8018 mingo 20   0  290320  45220   8520 R  99.5  0.3   0:58.81 perf

  
  Profiling 'perf top' shows all sorts of very high dwarf 
  processing overhead:
 
 Yeah, top dwarf callchain has been so far a proof of concept, it
 exacerbates problems that can be seen on 'report', but since its live,
 we can see it more clearly.
 
 The work on improving callchain processing, (rb_tree'ing, new comm
 infrastructure) alleviated the problem a bit.
 
 Tuning the stack size requested from the kernel and using --max-stack
 can help when it is really needed, but yes, work on it is *badly* needed.

agreed ;-)

also there's new remote unwind interface recently added
into libdw, which seems to be faster than libunwind.
I plan on adding this soon.

jirka
--
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 top: Make -g refer to callchains

2013-11-18 Thread Jiri Olsa
On Mon, Nov 18, 2013 at 03:26:53PM +0100, Ingo Molnar wrote:
 
 * Jiri Olsa jo...@redhat.com wrote:
 
  On Mon, Nov 18, 2013 at 09:59:45AM -0300, Arnaldo Carvalho de Melo wrote:
   Em Fri, Nov 15, 2013 at 06:46:09AM +0100, Ingo Molnar escreveu:
btw., here's some 'perf top' call graph performance and profiling 
quality feedback, with the latest perf code:

'perf top --call-graph fp' now works very well, using just 0.2% 
of CPU time on a fast system:

 4676 mingo 20   0  612m  56m 9948 S 1  0.2   0:00.68 perf  

  

'perf top --call-graph dwarf' on the other hand is horrendously 
slow, using 20% of CPU time on a 4 GHz CPU:

  PID USER  PR  NI  VIRT  RES  SHR S  %CPU %MEMTIME+  COMMAND   

  
 4646 mingo 20   0  658m  81m  12m R19  0.3   0:18.17 perf

On another system with a 2.4GHz CPU it's taking up 100% of CPU 
time (!):

  PID USER  PR  NIVIRTRESSHR S  %CPU %MEM TIME+ 
COMMAND 
  
 8018 mingo 20   0  290320  45220   8520 R  99.5  0.3   0:58.81 
perf  

Profiling 'perf top' shows all sorts of very high dwarf 
processing overhead:
   
   Yeah, top dwarf callchain has been so far a proof of concept, it 
   exacerbates problems that can be seen on 'report', but since its 
   live, we can see it more clearly.
   
   The work on improving callchain processing, (rb_tree'ing, new comm 
   infrastructure) alleviated the problem a bit.
   
   Tuning the stack size requested from the kernel and using 
   --max-stack can help when it is really needed, but yes, work on it 
   is *badly* needed.
  
  agreed ;-)
  
  also there's new remote unwind interface recently added into libdw, 
  which seems to be faster than libunwind.
 
  I plan on adding this soon.
 
 If the main source of overhead is libunwind (which needs independent 
 confirmation) then would it make sense to implement dwarf stack unwind 
 support ourselves?
 
 I think SysProf does that and it appears to be faster - its unwind.c 
 is only 400 lines long as it only implements the small subset needed 
 to walk the stack - AFAICS.

I think it's an option.. but it'll simpler to try the libdw
interface first and see if it's good/fast enough..

also I recall discussing the speed with libdw developer
Jan Kratochvil (CC-ed) and AFAICS they're open for
suggestions/optimizations

jirka
--
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 08/28] perf tools: Add filename__read_str util function

2013-12-03 Thread Jiri Olsa
Adding filename__read_str util function to read
text file and return it in the char array.

The interface is:
  int filename__read_str(const char *filename, char **buf, size_t *sizep)

  Returns 0/-1 if the read suceeded/fail respectively.

  buf  - place to store the data pointer
  size - place to store data size

v2 change:
  - better error handling suggested by Namhyung Kim.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/perf/util/util.c | 49 +
 tools/perf/util/util.h |  1 +
 2 files changed, 50 insertions(+)

diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index b1d5376..bae8756 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -6,6 +6,8 @@
 #endif
 #include stdio.h
 #include stdlib.h
+#include string.h
+#include errno.h
 #include linux/kernel.h
 
 /*
@@ -433,3 +435,50 @@ int filename__read_int(const char *filename, int *value)
close(fd);
return err;
 }
+
+int filename__read_str(const char *filename, char **buf, size_t *sizep)
+{
+   size_t size = 0, alloc_size = 0;
+   void *bf = NULL, *nbf;
+   int fd, n, err = 0;
+
+   fd = open(filename, O_RDONLY);
+   if (fd  0)
+   return -errno;
+
+   do {
+   if (size == alloc_size) {
+   alloc_size += BUFSIZ;
+   nbf = realloc(bf, alloc_size);
+   if (!nbf) {
+   err = -ENOMEM;
+   break;
+   }
+
+   bf = nbf;
+   }
+
+   n = read(fd, bf + size, alloc_size - size);
+   if (n  0) {
+   if (size) {
+   pr_warning(read failed %d: %s\n,
+  errno, strerror(errno));
+   err = 0;
+   } else
+   err = -errno;
+
+   break;
+   }
+
+   size += n;
+   } while (n  0);
+
+   if (!err) {
+   *sizep = size;
+   *buf   = bf;
+   } else
+   free(bf);
+
+   close(fd);
+   return err;
+}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index ce0f73d..adb39f2 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -308,4 +308,5 @@ char *get_srcline(struct dso *dso, unsigned long addr);
 void free_srcline(char *srcline);
 
 int filename__read_int(const char *filename, int *value);
+int filename__read_str(const char *filename, char **buf, size_t *sizep);
 #endif /* GIT_COMPAT_UTIL_H */
-- 
1.8.3.1

--
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 04/28] tools lib traceevent: Add traceevent_host_bigendian function

2013-12-03 Thread Jiri Olsa
Adding traceevent_host_bigendian function to get host
endianity. It's used in following patches.

Signed-off-by: Steven Rostedt rost...@goodmis.org
Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/event-parse.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/tools/lib/traceevent/event-parse.h 
b/tools/lib/traceevent/event-parse.h
index a288860..54273c0 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -23,6 +23,7 @@
 #include stdbool.h
 #include stdarg.h
 #include regex.h
+#include string.h
 
 #ifndef __maybe_unused
 #define __maybe_unused __attribute__((unused))
@@ -527,6 +528,15 @@ __data2host8(struct pevent *pevent, unsigned long long 
data)
__data2host8(pevent, __val);\
 })
 
+static inline int traceevent_host_bigendian(void)
+{
+   unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 };
+   unsigned int val;
+
+   memcpy(val, str, 4);
+   return val == 0x01020304;
+}
+
 /* taken from kernel/trace/trace.h */
 enum trace_flag_type {
TRACE_FLAG_IRQS_OFF = 0x01,
-- 
1.8.3.1

--
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 10/28] perf tools: Add trace-event global object for tracepoint interface

2013-12-03 Thread Jiri Olsa
In order to get the proper plugins processing we need to
use full trace-event interface when creating tracepoint
events. So far we were using shortcut to get the parsed
format.

Moving current 'event_format__new' function into trace-event
object as 'trace_event__tp_format'.

This function uses properly initialized global trace-event
object, ensuring proper plugins processing.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/perf/builtin-trace.c|  5 ++--
 tools/perf/util/evsel.c   | 44 ++-
 tools/perf/util/trace-event.c | 61 +++
 tools/perf/util/trace-event.h |  2 ++
 4 files changed, 68 insertions(+), 44 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 9f2a242..56afe33 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -11,6 +11,7 @@
 #include util/intlist.h
 #include util/thread_map.h
 #include util/stat.h
+#include trace-event.h
 
 #include libaudit.h
 #include stdlib.h
@@ -1430,11 +1431,11 @@ static int trace__read_syscall_info(struct trace 
*trace, int id)
sc-fmt  = syscall_fmt__find(sc-name);
 
snprintf(tp_name, sizeof(tp_name), sys_enter_%s, sc-name);
-   sc-tp_format = event_format__new(syscalls, tp_name);
+   sc-tp_format = trace_event__tp_format(syscalls, tp_name);
 
if (sc-tp_format == NULL  sc-fmt  sc-fmt-alias) {
snprintf(tp_name, sizeof(tp_name), sys_enter_%s, 
sc-fmt-alias);
-   sc-tp_format = event_format__new(syscalls, tp_name);
+   sc-tp_format = trace_event__tp_format(syscalls, tp_name);
}
 
if (sc-tp_format == NULL)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 6a046ed..7b510fd 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -23,6 +23,7 @@
 #include target.h
 #include perf_regs.h
 #include debug.h
+#include trace-event.h
 
 static struct {
bool sample_id_all;
@@ -180,47 +181,6 @@ struct perf_evsel *perf_evsel__new_idx(struct 
perf_event_attr *attr, int idx)
return evsel;
 }
 
-struct event_format *event_format__new(const char *sys, const char *name)
-{
-   int fd, n;
-   char *filename;
-   void *bf = NULL, *nbf;
-   size_t size = 0, alloc_size = 0;
-   struct event_format *format = NULL;
-
-   if (asprintf(filename, %s/%s/%s/format, tracing_events_path, sys, 
name)  0)
-   goto out;
-
-   fd = open(filename, O_RDONLY);
-   if (fd  0)
-   goto out_free_filename;
-
-   do {
-   if (size == alloc_size) {
-   alloc_size += BUFSIZ;
-   nbf = realloc(bf, alloc_size);
-   if (nbf == NULL)
-   goto out_free_bf;
-   bf = nbf;
-   }
-
-   n = read(fd, bf + size, alloc_size - size);
-   if (n  0)
-   goto out_free_bf;
-   size += n;
-   } while (n  0);
-
-   pevent_parse_format(NULL, format, bf, size, sys);
-
-out_free_bf:
-   free(bf);
-   close(fd);
-out_free_filename:
-   free(filename);
-out:
-   return format;
-}
-
 struct perf_evsel *perf_evsel__newtp_idx(const char *sys, const char *name, 
int idx)
 {
struct perf_evsel *evsel = zalloc(sizeof(*evsel));
@@ -235,7 +195,7 @@ struct perf_evsel *perf_evsel__newtp_idx(const char *sys, 
const char *name, int
if (asprintf(evsel-name, %s:%s, sys, name)  0)
goto out_free;
 
-   evsel-tp_format = event_format__new(sys, name);
+   evsel-tp_format = trace_event__tp_format(sys, name);
if (evsel-tp_format == NULL)
goto out_free;
 
diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c
index a155a77..d9f5f61 100644
--- a/tools/perf/util/trace-event.c
+++ b/tools/perf/util/trace-event.c
@@ -1,6 +1,24 @@
 
+#include stdio.h
+#include unistd.h
+#include stdlib.h
+#include errno.h
+#include sys/types.h
+#include sys/stat.h
+#include fcntl.h
+#include linux/kernel.h
 #include traceevent/event-parse.h
 #include trace-event.h
+#include util.h
+
+/*
+ * global trace_event object used by trace_event__tp_format
+ *
+ * TODO There's no cleanup call for this. Add some sort of
+ * __exit function support and call trace_event__cleanup
+ * there.
+ */
+static struct trace_event tevent;
 
 int trace_event__init(struct trace_event *t)
 {
@@ -19,3 +37,46 @@ void trace_event__cleanup(struct trace_event *t)
pevent_free(t-pevent

[PATCH 03/28] tools lib traceevent: Add plugin build support

2013-12-03 Thread Jiri Olsa
Backporting missing pieces of plugin building infrastructure:
  - adding Makefile 'plugins' target to build all
defined plugins
  - adding Makefile 'install_plugins' target as 'install_lib'
target dependency
  - link plugin objects with shared object building

Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git

Plugins are by default installed into following locations:
  '$(HOME)/.traceevent/plugins'
 - if we are installing under $(HOME)
  '$(prefix)/lib/traceevent/plugins'
 - otherwise

This path is propagated to the plugin object as
a plugins search path.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/Makefile | 52 ++-
 1 file changed, 47 insertions(+), 5 deletions(-)

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index 2ccb5bc..1526798 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -43,6 +43,30 @@ man_dir_SQ = '$(subst ','\'',$(man_dir))'
 export man_dir man_dir_SQ INSTALL
 export DESTDIR DESTDIR_SQ
 
+set_plugin_dir := 1
+
+# Set plugin_dir to preffered global plugin location
+# If we install under $HOME directory we go under
+# $(HOME)/.traceevent/plugins
+#
+# We dont set PLUGIN_DIR in case we install under $HOME
+# directory, because by default the code looks under:
+# $(HOME)/.traceevent/plugins by default.
+#
+ifeq ($(plugin_dir),)
+ifeq ($(prefix),$(HOME))
+override plugin_dir = $(HOME)/.traceevent/plugins
+set_plugin_dir := 0
+else
+override plugin_dir = $(prefix)/lib/traceevent/plugins
+endif
+endif
+
+ifeq ($(set_plugin_dir),1)
+PLUGIN_DIR = -DPLUGIN_DIR=$(DESTDIR)/$(plugin_dir)
+PLUGIN_DIR_SQ = '$(subst ','\'',$(PLUGIN_DIR))'
+endif
+
 # copy a bit from Linux kbuild
 
 ifeq ($(origin V), command line)
@@ -96,6 +120,7 @@ export prefix bindir src obj
 # Shell quotes
 bindir_SQ = $(subst ','\'',$(bindir))
 bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
+plugin_dir_SQ = $(subst ','\'',$(plugin_dir))
 
 LIB_FILE = libtraceevent.a libtraceevent.so
 
@@ -138,8 +163,8 @@ else
   print_app_build =echo '  BUILD'$(OBJ);
   print_fpic_compile = echo '  CC FPIC  '$(OBJ);
   print_shared_lib_compile =   echo '  BUILDSHARED LIB '$(OBJ);
-  print_plugin_obj_compile =   echo '  BUILDPLUGIN OBJ '$(OBJ);
-  print_plugin_build = echo '  BUILDPLUGIN '$(OBJ);
+  print_plugin_obj_compile =   echo '  CC FPIC  '$(OBJ);
+  print_plugin_build = echo '  BUILDPLUGIN '$(OBJ);
   print_static_lib_build = echo '  BUILDSTATIC LIB '$(OBJ);
   print_install =  echo '  INSTALL  '$1'   to  
$(DESTDIR_SQ)$2';
 endif
@@ -187,9 +212,11 @@ PEVENT_LIB_OBJS += parse-filter.o
 PEVENT_LIB_OBJS += parse-utils.o
 PEVENT_LIB_OBJS += kbuffer-parse.o
 
-ALL_OBJS = $(PEVENT_LIB_OBJS)
+PLUGINS := $(PLUGIN_OBJS:.o=.so)
+
+ALL_OBJS = $(PEVENT_LIB_OBJS) $(PLUGIN_OBJS)
 
-CMD_TARGETS = $(LIB_FILE)
+CMD_TARGETS = $(LIB_FILE) $(PLUGINS)
 
 TARGETS = $(CMD_TARGETS)
 
@@ -204,9 +231,17 @@ libtraceevent.so: $(PEVENT_LIB_OBJS)
 libtraceevent.a: $(PEVENT_LIB_OBJS)
$(Q)$(do_build_static_lib)
 
+plugins: $(PLUGINS)
+
 $(PEVENT_LIB_OBJS): %.o: $(src)/%.c TRACEEVENT-CFLAGS
$(Q)$(do_fpic_compile)
 
+$(PLUGIN_OBJS): %.o : $(src)/%.c
+   $(Q)$(do_compile_plugin_obj)
+
+$(PLUGINS): %.so: %.o
+   $(Q)$(do_plugin_build)
+
 define make_version.h
(echo '/* This file is automatically generated. Do not modify. */'; 
\
echo \#define VERSION_CODE $(shell  
\
@@ -294,9 +329,16 @@ define do_install
$(INSTALL) $1 '$(DESTDIR_SQ)$2'
 endef
 
-install_lib: all_cmd
+install_lib: all_cmd install_plugins
$(Q)$(call do_install,$(LIB_FILE),$(bindir_SQ))
 
+PLUGINS_INSTALL = $(subst .so,.install,$(PLUGINS))
+
+$(PLUGINS_INSTALL): %.install : %.so force
+   $(Q)$(call do_install,$,$(plugin_dir_SQ))
+
+install_plugins: $(PLUGINS_INSTALL)
+
 install: install_lib
 
 clean:
-- 
1.8.3.1

--
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/


[PATCHv3 00/28] perf tools: Add traceevent plugins support

2013-12-03 Thread Jiri Olsa
 -- 811a5d6b
-  ls 10781 [001] 32667.291386: ftrace:function:  
811a9fa0 -- 811aa015
-  ls 10781 [001] 32667.291387: ftrace:function:  
810851c0 -- 811aa053
-  ls 10781 [001] 32667.291387: ftrace:function:  
81090e00 -- 81085211
+  ls 10781 [001] 32667.291379: ftrace:function: would_dump -- 
setup_new_exec
+  ls 10781 [001] 32667.291379: ftrace:function:
inode_permission -- would_dump
+  ls 10781 [001] 32667.291380: ftrace:function:   
__inode_permission -- inode_permission
+  ls 10781 [001] 32667.291380: ftrace:function:  
generic_permission -- __inode_permission
+  ls 10781 [001] 32667.291381: ftrace:function:  
security_inode_permission -- __inode_permission
+  ls 10781 [001] 32667.291381: ftrace:function: 
cap_inode_permission -- security_inode_permission
+  ls 10781 [001] 32667.291382: ftrace:function: 
flush_signal_handlers -- setup_new_exec
+  ls 10781 [001] 32667.291383: ftrace:function: 
do_close_on_exec -- setup_new_exec
+  ls 10781 [001] 32667.291383: ftrace:function:
_raw_spin_lock -- do_close_on_exec
+  ls 10781 [001] 32667.291384: ftrace:function:filp_close 
-- do_close_on_exec
+  ls 10781 [001] 32667.291384: ftrace:function:   
dnotify_flush -- filp_close
+  ls 10781 [001] 32667.291385: ftrace:function:   
locks_remove_posix -- filp_close
+  ls 10781 [001] 32667.291385: ftrace:function:   fput -- 
filp_close
+  ls 10781 [001] 32667.291386: ftrace:function:  
file_sb_list_del -- fput
+  ls 10781 [001] 32667.291387: ftrace:function:  
task_work_add -- fput
+  ls 10781 [001] 32667.291387: ftrace:function: 
kick_process -- task_work_add


  * data was generated by 'perf record -e 'kvm:*,kvmmmu:*' -a'
--- script.kvm.old
+++ script.kvm.new
  qemu-system-x86 17414 [000]  6868.995053: kvm:kvm_exit: reason 
EPT_VIOLATION rip 0xfff0 info 184 0
  qemu-system-x86 17414 [000]  6868.995109: kvm:kvm_emulate_insn: 
f:c46b:e4 71 (real)
- qemu-system-x86  3006 [002] 10562.079422: kvmmmu:kvm_mmu_get_page: 
[FAILED TO PARSE] mmu_valid_gen=0x2 gfn=0 role=122884 root_count=0
+ qemu-system-x86  3006 [002] 10562.079422: kvmmmu:kvm_mmu_get_page: new sp 
gfn 0 0/4 q0 direct --- !pge !nxe root 0 sync
- qemu-system-x86  3006 [002] 10562.080502: 
kvmmmu:kvm_mmu_prepare_zap_page: [FAILED TO PARSE] mmu_valid_gen=0x2 gfn=0 
role=122884 root
+ qemu-system-x86  3006 [002] 10562.080502: 
kvmmmu:kvm_mmu_prepare_zap_page: 0/4 q0 direct --- !pge !nxe root 1 sync
  qemu-system-x86  3290 [002] 10708.755312: kvmmmu:fast_page_fault: [FAILED 
TO PARSE] vcpu_id=0 gva=4094486080 error_code=3 sptep=0xfff
-  insmod  2576 [001]   781.731666: kvmmmu:kvm_mmu_sync_page: 
[FAILED TO PARSE] mmu_valid_gen=0x1 gfn=2 role=24624 root_count=1
+  insmod  2576 [001]   781.731666: kvmmmu:kvm_mmu_sync_page: 3/0 
q0 --- !pge !nxe root 10 unsync
-  insmod  2576 [001]   781.731668: kvmmmu:kvm_mmu_unsync_page: 
[FAILED TO PARSE] mmu_valid_gen=0x1 gfn=2 role=24624 root_count
+  insmod  2576 [001]   781.731668: kvmmmu:kvm_mmu_unsync_page: 3/0 
q0 --- !pge !nxe root 10 unsync


Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@redhat.com
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
Jiri Olsa (28):
  perf tools: Remove stackprotector feature check
  tools lib traceevent: Add plugin support
  tools lib traceevent: Add plugin build support
  tools lib traceevent: Add traceevent_host_bigendian function
  tools lib traceevent: Change pevent_parse_format to include pevent handle
  tools lib traceevent: Harmonize the install messages in lib-traceevent
  perf tools: Add build and install plugins targets
  perf tools: Add filename__read_str util function
  perf tools: Add trace-event object
  perf tools: Add trace-event global object for tracepoint interface
  perf tools: Overload pr_stat traceevent print function
  tools lib traceevent: Add jbd2 plugin
  tools lib traceevent: Add hrtimer plugin
  tools lib traceevent: Add kmem plugin
  tools lib traceevent: Add kvm plugin
  tools lib traceevent: Add mac80211 plugin
  tools lib traceevent: Add sched_switch plugin
  tools lib traceevent: Add function plugin
  tools lib traceevent: Add xen plugin
  tools lib traceevent: Add scsi plugin
  tools lib

[PATCH 24/28] tools lib traceevent: Use pevent_print_func_field in hrtimer_start handler

2013-12-03 Thread Jiri Olsa
The pevent_print_func_field function encompasses all the
functionality used in the hrtimer_start handler. Changing
the handler to use this function.

This also unifies the function field output with the
hrtimer_expire_entry handler.

Suggested-by: Steven Rostedt rost...@goodmis.org
Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/plugin_hrtimer.c | 19 ++-
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/tools/lib/traceevent/plugin_hrtimer.c 
b/tools/lib/traceevent/plugin_hrtimer.c
index e41d4cf..0b0ebf3 100644
--- a/tools/lib/traceevent/plugin_hrtimer.c
+++ b/tools/lib/traceevent/plugin_hrtimer.c
@@ -48,10 +48,6 @@ static int timer_start_handler(struct trace_seq *s,
   struct pevent_record *record,
   struct event_format *event, void *context)
 {
-   struct pevent *pevent = event-pevent;
-   struct format_field *fn = pevent_find_field(event, function);
-   void *data = record-data;
-
trace_seq_printf(s, hrtimer=);
 
if (pevent_print_num_field(s, 0x%llx, event, timer,
@@ -59,19 +55,8 @@ static int timer_start_handler(struct trace_seq *s,
pevent_print_num_field(s, 0x%llx, event, hrtimer,
   record, 1);
 
-   if (!fn) {
-   trace_seq_printf(s,  function=MISSING);
-   } else {
-   unsigned long long function;
-   const char *func;
-
-   if (pevent_read_number_field(fn, data, function))
-   trace_seq_printf(s,  function=INVALID);
-
-   func = pevent_find_function(pevent, function);
-
-   trace_seq_printf(s,  function=%s, func);
-   }
+   pevent_print_func_field(s,  function=%s, event, function,
+   record, 0);
 
trace_seq_printf(s,  expires=);
pevent_print_num_field(s, %llu, event, expires, record, 1);
-- 
1.8.3.1

--
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 27/28] tools lib traceevent: Update kvm plugin with is_writable_pte helper

2013-12-03 Thread Jiri Olsa
Adding is_writable_pte print helper function, so the
kvmmmu:fast_page_fault print format gets resolved properly.

The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'kvm:*,kvmmmu:*' -a')

  --- script.kvm.old
  +++ script.kvm.new
  - qemu-system-x86  3290 [002] 10708.755312: kvmmmu:fast_page_fault: [FAILED 
TO PARSE] vcpu_id=0 gva=4094486080 error_code=3 sptep=0x88019f1e3670 
old_spte=336391285 new_spte=336391287 retry=1
  + qemu-system-x86  3290 [002] 10708.755312: kvmmmu:fast_page_fault: vcpu 0 
gva f40ce640 error_code P|W sptep 0x88019f1e3670 old 0x140cec75 new 
140cec77 spurious 0 fixed 1

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/plugin_kvm.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/tools/lib/traceevent/plugin_kvm.c 
b/tools/lib/traceevent/plugin_kvm.c
index be9d9c6..a0e282c 100644
--- a/tools/lib/traceevent/plugin_kvm.c
+++ b/tools/lib/traceevent/plugin_kvm.c
@@ -389,6 +389,16 @@ static int kvm_mmu_get_page_handler(struct trace_seq *s,
return kvm_mmu_print_role(s, record, event, context);
 }
 
+#define PT_WRITABLE_SHIFT 1
+#define PT_WRITABLE_MASK (1ULL  PT_WRITABLE_SHIFT)
+
+static unsigned long long
+process_is_writable_pte(struct trace_seq *s, unsigned long long *args)
+{
+   unsigned long pte = args[0];
+   return pte  PT_WRITABLE_MASK;
+}
+
 int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 {
init_disassembler();
@@ -415,5 +425,12 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
pevent_register_event_handler(pevent, -1, kvmmmu,
kvm_mmu_prepare_zap_page, kvm_mmu_print_role,
NULL);
+
+   pevent_register_print_function(pevent,
+  process_is_writable_pte,
+  PEVENT_FUNC_ARG_INT,
+  is_writable_pte,
+  PEVENT_FUNC_ARG_LONG,
+  PEVENT_FUNC_ARG_VOID);
return 0;
 }
-- 
1.8.3.1

--
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 26/28] tools lib traceevent: Remove malloc_or_die from plugin_function.c

2013-12-03 Thread Jiri Olsa
Removing malloc_or_die calls from plugin_function.c,
replacing them and factoring the code with standard
realloc and error path.

Suggested-by: Namhyung Kim namhy...@kernel.org
Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/plugin_function.c | 29 -
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/tools/lib/traceevent/plugin_function.c 
b/tools/lib/traceevent/plugin_function.c
index 87acf9c..aad92ad 100644
--- a/tools/lib/traceevent/plugin_function.c
+++ b/tools/lib/traceevent/plugin_function.c
@@ -43,11 +43,17 @@ static void add_child(struct func_stack *stack, const char 
*child, int pos)
if (pos  stack-size)
free(stack-stack[pos]);
else {
-   if (!stack-stack)
-   stack-stack = malloc_or_die(sizeof(char *) * STK_BLK);
-   else
-   stack-stack = realloc(stack-stack, sizeof(char *) *
-  (stack-size + STK_BLK));
+   char **ptr;
+
+   ptr = realloc(stack-stack, sizeof(char *) *
+ (stack-size + STK_BLK));
+   if (!ptr) {
+   warning(could not allocate plugin memory\n);
+   return;
+   }
+
+   stack-stack = ptr;
+
for (i = stack-size; i  stack-size + STK_BLK; i++)
stack-stack[i] = NULL;
stack-size += STK_BLK;
@@ -64,10 +70,15 @@ static int add_and_get_index(const char *parent, const char 
*child, int cpu)
return 0;
 
if (cpu  cpus) {
-   if (fstack)
-   fstack = realloc(fstack, sizeof(*fstack) * (cpu + 1));
-   else
-   fstack = malloc_or_die(sizeof(*fstack) * (cpu + 1));
+   struct func_stack *ptr;
+
+   ptr = realloc(fstack, sizeof(*fstack) * (cpu + 1));
+   if (!ptr) {
+   warning(could not allocate plugin memory\n);
+   return 0;
+   }
+
+   fstack = ptr;
 
/* Account for holes in the cpu count */
for (i = cpus + 1; i = cpu; i++)
-- 
1.8.3.1

--
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 20/28] tools lib traceevent: Add scsi plugin

2013-12-03 Thread Jiri Olsa
Adding scsi plugin.

This plugin adds fields resolving functions for following
tracepoint events:
  scsi:scsi_dispatch_cmd_start
  scsi:scsi_dispatch_cmd_error
  scsi:scsi_dispatch_cmd_done
  scsi:scsi_dispatch_cmd_timeout

The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'scsi:scsi_dispatch_cmd*' -a)

  - swapper 0 [000]  6620.491019: scsi:scsi_dispatch_cmd_done: 
[FAILED TO PARSE] host_no=0 channel=0 id=0 lun=0 result=0 opcode=53 cmd_len=10 
data_sglen=0 prot_sglen=0 prot_op=0 cmnd=5
  + swapper 0 [000]  6620.491019: scsi:scsi_dispatch_cmd_done: 
host_no=0 channel=0 id=0 lun=0 data_sgl=0 prot_sgl=0 prot_op=SCSI_PROT_NORMAL 
cmnd=(SYNCHRONIZE_CACHE - raw=35 00 00 00 00 00 00 00 00 00) 
result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE 
status=SAM_STAT_GOOD)
  - kworker/0:0 21554 [000]  6620.491126: scsi:scsi_dispatch_cmd_start: 
[FAILED TO PARSE] host_no=0 channel=0 id=0 lun=0 opcode=42 cmd_len=10 
data_sglen=1 prot_sglen=0 prot_op=0 cmnd=*
  + kworker/0:0 21554 [000]  6620.491126: scsi:scsi_dispatch_cmd_start: 
host_no=0 channel=0 id=0 lun=0 data_sgl=1 prot_sgl=0 prot_op=SCSI_PROT_NORMAL 
cmnd=(WRITE_10 lba=570899168 txlen=8 protect=0 raw=2a 00 22 07 3a e0 00 00 08 
00)
  - jbd2/dm-3-8   593 [002]  6621.607992: scsi:scsi_dispatch_cmd_error: 
[FAILED TO PARSE] host_no=0 channel=0 id=0 lun=0 rtn=4182 opcode=53 cmd_len=10 
data_sglen=0 prot_sglen=0 prot_op=0 cmnd=5
  + jbd2/dm-3-8   593 [002]  6621.607992: scsi:scsi_dispatch_cmd_error: 
host_no=0 channel=0 id=0 lun=0 data_sgl=0 prot_sgl=0 prot_op=SCSI_PROT_NORMAL 
cmnd=(SYNCHRONIZE_CACHE - raw=35 00 00 00 00 00 00 00 00 00) rtn=4182

NOTE I couldn't generate scsi_dispatch_cmd_timeout tracepoint,
 but it's similar to the rest, so I believe it's ok.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
Cc: Martin K. Petersen martin.peter...@oracle.com
---
 tools/lib/traceevent/Makefile  |   1 +
 tools/lib/traceevent/plugin_scsi.c | 423 +
 2 files changed, 424 insertions(+)
 create mode 100644 tools/lib/traceevent/plugin_scsi.c

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index 54af60a..671f969 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -220,6 +220,7 @@ PLUGIN_OBJS += plugin_mac80211.o
 PLUGIN_OBJS += plugin_sched_switch.o
 PLUGIN_OBJS += plugin_function.o
 PLUGIN_OBJS += plugin_xen.o
+PLUGIN_OBJS += plugin_scsi.o
 
 PLUGINS := $(PLUGIN_OBJS:.o=.so)
 
diff --git a/tools/lib/traceevent/plugin_scsi.c 
b/tools/lib/traceevent/plugin_scsi.c
new file mode 100644
index 000..6fb8e3e
--- /dev/null
+++ b/tools/lib/traceevent/plugin_scsi.c
@@ -0,0 +1,423 @@
+#include stdio.h
+#include string.h
+#include inttypes.h
+#include event-parse.h
+
+typedef unsigned long sector_t;
+typedef uint64_t u64;
+typedef unsigned int u32;
+
+/*
+ *  SCSI opcodes
+ */
+#define TEST_UNIT_READY0x00
+#define REZERO_UNIT0x01
+#define REQUEST_SENSE  0x03
+#define FORMAT_UNIT0x04
+#define READ_BLOCK_LIMITS  0x05
+#define REASSIGN_BLOCKS0x07
+#define INITIALIZE_ELEMENT_STATUS  0x07
+#define READ_6 0x08
+#define WRITE_60x0a
+#define SEEK_6 0x0b
+#define READ_REVERSE   0x0f
+#define WRITE_FILEMARKS0x10
+#define SPACE  0x11
+#define INQUIRY0x12
+#define RECOVER_BUFFERED_DATA  0x14
+#define MODE_SELECT0x15
+#define RESERVE0x16
+#define RELEASE0x17
+#define COPY   0x18
+#define ERASE  0x19
+#define MODE_SENSE 0x1a
+#define START_STOP 0x1b
+#define RECEIVE_DIAGNOSTIC 0x1c
+#define SEND_DIAGNOSTIC0x1d
+#define ALLOW_MEDIUM_REMOVAL   0x1e
+
+#define READ_FORMAT_CAPACITIES 0x23
+#define SET_WINDOW 0x24
+#define READ_CAPACITY  0x25
+#define READ_100x28
+#define WRITE_10   0x2a
+#define SEEK_100x2b
+#define POSITION_TO_ELEMENT0x2b
+#define WRITE_VERIFY   0x2e
+#define VERIFY 0x2f
+#define SEARCH_HIGH0x30
+#define SEARCH_EQUAL

[PATCH 28/28] perf tools: Add udis86 disassembler feature check

2013-12-03 Thread Jiri Olsa
Adding udis86 disassembler feature check which support
is needed for kvm:kvm_emulate_insn tracepoint.

The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e kvm:kvm_emulate_insn -a')

  --- script.kvm.old
  +++ script.kvm.new
  - qemu-system-x86 15519 [003]  5332.470049: kvm:kvm_emulate_insn: 
0:8103c596:89 b7 00 80 5f ff (prot64)
  + qemu-system-x86 15519 [003]  5332.470049: kvm:kvm_emulate_insn: 
0:8103c596: mov %esi, -0xa08000(%rdi)

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/perf/Makefile.perf   |  2 +-
 tools/perf/config/Makefile |  8 
 tools/perf/config/feature-checks/Makefile  |  6 +-
 tools/perf/config/feature-checks/test-all.c|  5 +
 tools/perf/config/feature-checks/test-udis86.c | 11 +++
 5 files changed, 30 insertions(+), 2 deletions(-)
 create mode 100644 tools/perf/config/feature-checks/test-udis86.c

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index ca3b87d..be336f8 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -712,7 +712,7 @@ $(LIB_FILE): $(LIB_OBJS)
 TE_SOURCES = $(wildcard $(TRACE_EVENT_DIR)*.[ch])
 
 LIBTRACEEVENT_FLAGS  = $(QUIET_SUBDIR1) O=$(OUTPUT)
-LIBTRACEEVENT_FLAGS += CFLAGS=-g -Wall $(EXTRA_CFLAGS)
+LIBTRACEEVENT_FLAGS += CFLAGS=-g -Wall $(EXTRA_CFLAGS) 
$(LIBTRACEEVENT_CFLAGS)
 LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ)
 
 $(LIBTRACEEVENT): $(TE_SOURCES) $(OUTPUT)PERF-CFLAGS
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index bae1072..5e3fb25 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -413,6 +413,14 @@ else
   msg := $(warning No timerfd support. Disables 'perf kvm stat live');
 endif
 
+$(call feature_check,udis86)
+ifeq ($(feature-udis86), 1)
+  LIBTRACEEVENT_CFLAGS += -DHAVE_UDIS86
+  EXTLIBS += -ludis86
+else
+  msg := $(warning No udis86 support.);
+endif
+
 disable-python = $(eval $(disable-python_code))
 define disable-python_code
   CFLAGS += -DNO_LIBPYTHON
diff --git a/tools/perf/config/feature-checks/Makefile 
b/tools/perf/config/feature-checks/Makefile
index b8bb749..c550b4f 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -26,7 +26,8 @@ FILES=\
test-libunwind-debug-frame  \
test-on-exit\
test-stackprotector-all \
-   test-timerfd
+   test-timerfd\
+   test-udis86
 
 CC := $(CC) -MD
 
@@ -140,6 +141,9 @@ test-backtrace:
 test-timerfd:
$(BUILD)
 
+test-udis86:
+   $(BUILD) -DHAVE_UDIS86 -ludis86
+
 -include *.d
 
 ###
diff --git a/tools/perf/config/feature-checks/test-all.c 
b/tools/perf/config/feature-checks/test-all.c
index 9b8a544..df087a5 100644
--- a/tools/perf/config/feature-checks/test-all.c
+++ b/tools/perf/config/feature-checks/test-all.c
@@ -89,6 +89,10 @@
 # include test-stackprotector-all.c
 #undef main
 
+#define main main_test_udis86
+# include test-udis86.c
+#undef main
+
 int main(int argc, char *argv[])
 {
main_test_libpython();
@@ -111,6 +115,7 @@ int main(int argc, char *argv[])
main_test_libnuma();
main_test_timerfd();
main_test_stackprotector_all();
+   main_test_udis86();
 
return 0;
 }
diff --git a/tools/perf/config/feature-checks/test-udis86.c 
b/tools/perf/config/feature-checks/test-udis86.c
new file mode 100644
index 000..dbc2c26
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-udis86.c
@@ -0,0 +1,11 @@
+
+/*
+ * test for udis86 functions used by plugin_kvm.c
+ */
+
+#include udis86.h
+
+int main(void)
+{
+   return puts(hi);
+}
-- 
1.8.3.1

--
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 23/28] tools lib traceevent: Use static functions in jbd2 plugin

2013-12-03 Thread Jiri Olsa
There's no need for following functions to be global:
  process_jbd2_dev_to_name
  process_jiffies_to_msecs

Making them static.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/plugin_jbd2.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/lib/traceevent/plugin_jbd2.c 
b/tools/lib/traceevent/plugin_jbd2.c
index 5d85de7..2f93f81 100644
--- a/tools/lib/traceevent/plugin_jbd2.c
+++ b/tools/lib/traceevent/plugin_jbd2.c
@@ -29,8 +29,9 @@
 #define MAJOR(dev) ((unsigned int) ((dev)  MINORBITS))
 #define MINOR(dev) ((unsigned int) ((dev)  MINORMASK))
 
-unsigned long long process_jbd2_dev_to_name(struct trace_seq *s,
-   unsigned long long *args)
+static unsigned long long
+process_jbd2_dev_to_name(struct trace_seq *s,
+unsigned long long *args)
 {
unsigned int dev = args[0];
 
@@ -38,8 +39,9 @@ unsigned long long process_jbd2_dev_to_name(struct trace_seq 
*s,
return 0;
 }
 
-unsigned long long process_jiffies_to_msecs(struct trace_seq *s,
-   unsigned long long *args)
+static unsigned long long
+process_jiffies_to_msecs(struct trace_seq *s,
+unsigned long long *args)
 {
unsigned long long jiffies = args[0];
 
-- 
1.8.3.1

--
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 25/28] tools lib traceevent: Several cleanups for function plugin

2013-12-03 Thread Jiri Olsa
Several cleanups suggested by Namhyung:
  * removing index field from struct func_stack as
it's not needed
  * renaming get_index into add_and_get_index
  * using '%*X' format string capability instead of
the loop

Suggested-by: Namhyung Kim namhy...@kernel.org
Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/plugin_function.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/tools/lib/traceevent/plugin_function.c 
b/tools/lib/traceevent/plugin_function.c
index 8deb22e..87acf9c 100644
--- a/tools/lib/traceevent/plugin_function.c
+++ b/tools/lib/traceevent/plugin_function.c
@@ -25,7 +25,6 @@
 #include event-utils.h
 
 static struct func_stack {
-   int index;
int size;
char **stack;
 } *fstack;
@@ -57,7 +56,7 @@ static void add_child(struct func_stack *stack, const char 
*child, int pos)
stack-stack[pos] = strdup(child);
 }
 
-static int get_index(const char *parent, const char *child, int cpu)
+static int add_and_get_index(const char *parent, const char *child, int cpu)
 {
int i;
 
@@ -97,7 +96,7 @@ static int function_handler(struct trace_seq *s, struct 
pevent_record *record,
unsigned long long pfunction;
const char *func;
const char *parent;
-   int i, index;
+   int index;
 
if (pevent_get_field_val(s, event, ip, record, function, 1))
return trace_seq_putc(s, '!');
@@ -109,10 +108,9 @@ static int function_handler(struct trace_seq *s, struct 
pevent_record *record,
 
parent = pevent_find_function(pevent, pfunction);
 
-   index = get_index(parent, func, record-cpu);
+   index = add_and_get_index(parent, func, record-cpu);
 
-   for (i = 0; i  index; i++)
-   trace_seq_printf(s,);
+   trace_seq_printf(s, %*s, index*3, );
 
if (func)
trace_seq_printf(s, %s, func);
-- 
1.8.3.1

--
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 22/28] tools lib traceevent: Remove malloc_or_die from event-plugin.c

2013-12-03 Thread Jiri Olsa
Removing malloc_or_die calls from event-plugin.c,
replacing them with standard malloc and error path.

Suggested-by: Namhyung Kim namhy...@kernel.org
Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/event-plugin.c | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/tools/lib/traceevent/event-plugin.c 
b/tools/lib/traceevent/event-plugin.c
index d272d87..125f567 100644
--- a/tools/lib/traceevent/event-plugin.c
+++ b/tools/lib/traceevent/event-plugin.c
@@ -47,7 +47,11 @@ load_plugin(struct pevent *pevent, const char *path,
char *plugin;
void *handle;
 
-   plugin = malloc_or_die(strlen(path) + strlen(file) + 2);
+   plugin = malloc(strlen(path) + strlen(file) + 2);
+   if (!plugin) {
+   warning(could not allocate plugin memory\n);
+   return;
+   }
 
strcpy(plugin, path);
strcat(plugin, /);
@@ -71,7 +75,12 @@ load_plugin(struct pevent *pevent, const char *path,
goto out_free;
}
 
-   list = malloc_or_die(sizeof(*list));
+   list = malloc(sizeof(*list));
+   if (!list) {
+   warning(could not allocate plugin memory\n);
+   goto out_free;
+   }
+
list-next = *plugin_list;
list-handle = handle;
list-name = plugin;
@@ -163,7 +172,11 @@ load_plugins(struct pevent *pevent, const char *suffix,
if (!home)
return;
 
-   path = malloc_or_die(strlen(home) + strlen(LOCAL_PLUGIN_DIR) + 2);
+   path = malloc(strlen(home) + strlen(LOCAL_PLUGIN_DIR) + 2);
+   if (!path) {
+   warning(could not allocate plugin memory\n);
+   return;
+   }
 
strcpy(path, home);
strcat(path, /);
-- 
1.8.3.1

--
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 18/28] tools lib traceevent: Add function plugin

2013-12-03 Thread Jiri Olsa
Backporting function plugin.

Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git

This plugin adds function and parent function fields
resolving for ftrace:function tracepoint event.

The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e ftrace:function ls')

  --- script.function.old
  +++ script.function.new
  -  ls 10781 [001] 32667.291379: ftrace:function:  
811adb80 -- 811afc48
  -  ls 10781 [001] 32667.291379: ftrace:function:  
811b35d0 -- 811adb9b
  -  ls 10781 [001] 32667.291380: ftrace:function:  
811b3520 -- 811b35e8
  -  ls 10781 [001] 32667.291380: ftrace:function:  
811b2720 -- 811b3549
  -  ls 10781 [001] 32667.291381: ftrace:function:  
81297e10 -- 811b356c
  -  ls 10781 [001] 32667.291381: ftrace:function:  
81298f40 -- 81297e2c
  -  ls 10781 [001] 32667.291382: ftrace:function:  
81076160 -- 811afbf0
  -  ls 10781 [001] 32667.291383: ftrace:function:  
811c3eb0 -- 811afbfc
  -  ls 10781 [001] 32667.291383: ftrace:function:  
8164e100 -- 811c3ed8
  -  ls 10781 [001] 32667.291384: ftrace:function:  
811a5d10 -- 811c3f53
  -  ls 10781 [001] 32667.291384: ftrace:function:  
811e8e70 -- 811a5d58
  -  ls 10781 [001] 32667.291385: ftrace:function:  
811f38e0 -- 811a5d63
  -  ls 10781 [001] 32667.291385: ftrace:function:  
811a9ff0 -- 811a5d6b
  -  ls 10781 [001] 32667.291386: ftrace:function:  
811a9fa0 -- 811aa015
  -  ls 10781 [001] 32667.291387: ftrace:function:  
810851c0 -- 811aa053
  -  ls 10781 [001] 32667.291387: ftrace:function:  
81090e00 -- 81085211
  +  ls 10781 [001] 32667.291379: ftrace:function: would_dump -- 
setup_new_exec
  +  ls 10781 [001] 32667.291379: ftrace:function:
inode_permission -- would_dump
  +  ls 10781 [001] 32667.291380: ftrace:function:   
__inode_permission -- inode_permission
  +  ls 10781 [001] 32667.291380: ftrace:function:  
generic_permission -- __inode_permission
  +  ls 10781 [001] 32667.291381: ftrace:function:  
security_inode_permission -- __inode_permission
  +  ls 10781 [001] 32667.291381: ftrace:function: 
cap_inode_permission -- security_inode_permission
  +  ls 10781 [001] 32667.291382: ftrace:function: 
flush_signal_handlers -- setup_new_exec
  +  ls 10781 [001] 32667.291383: ftrace:function: do_close_on_exec 
-- setup_new_exec
  +  ls 10781 [001] 32667.291383: ftrace:function:
_raw_spin_lock -- do_close_on_exec
  +  ls 10781 [001] 32667.291384: ftrace:function:filp_close 
-- do_close_on_exec
  +  ls 10781 [001] 32667.291384: ftrace:function:   
dnotify_flush -- filp_close
  +  ls 10781 [001] 32667.291385: ftrace:function:   
locks_remove_posix -- filp_close
  +  ls 10781 [001] 32667.291385: ftrace:function:   fput -- 
filp_close
  +  ls 10781 [001] 32667.291386: ftrace:function:  
file_sb_list_del -- fput
  +  ls 10781 [001] 32667.291387: ftrace:function:  
task_work_add -- fput
  +  ls 10781 [001] 32667.291387: ftrace:function: 
kick_process -- task_work_add

Removing options support as it's not backported yet.
Currently this plugin supports 2 options:
 'parent' to display parent function
 'indent' to show function call indents

Enabling both of them by default.

Signed-off-by: Steven Rostedt rost...@goodmis.org
Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/Makefile  |   1 +
 tools/lib/traceevent/plugin_function.c | 151 +
 2 files changed, 152 insertions(+)
 create mode 100644 tools/lib/traceevent/plugin_function.c

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index 1c319a8..21f9b8f 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -218,6 +218,7 @@ PLUGIN_OBJS += plugin_kmem.o
 PLUGIN_OBJS += plugin_kvm.o
 PLUGIN_OBJS += plugin_mac80211.o
 PLUGIN_OBJS += plugin_sched_switch.o
+PLUGIN_OBJS += plugin_function.o
 
 PLUGINS

[PATCH 21/28] tools lib traceevent: Add cfg80211 plugin

2013-12-03 Thread Jiri Olsa
Adding cfg80211 plugin.

This plugin adds handler for __le16_to_cpup function
t properly parse following tracepoint events:
  cfg80211:cfg80211_tx_mlme_mgmt
  cfg80211:cfg80211_rx_mlme_mgmt
  cfg80211:cfg80211_rx_unprot_mlme_mgmt

The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'cfg80211:*' -a')

  --- script.cfg80211.old
  +++ script.cfg80211.new
  -ifconfig  2705 [003]   662.896560: cfg80211:cfg80211_tx_mlme_mgmt: 
[FAILED TO PARSE] name=wlan0 ifindex=3 frame=ARRAY[c0, 00, 00, 00, 00, 3a, 98, 
a0, 30, 51, 10, 0b, a9, c6, f4, 74, 00, 3a, 98, a0, 30, 51, 00, 00, 03, 00]
  +ifconfig  2705 [003]   662.896560: cfg80211:cfg80211_tx_mlme_mgmt: 
netdev:wlan0(3), ftype:0xc0
  -   kworker/u16:0  1697 [002]   664.808210: cfg80211:cfg80211_rx_mlme_mgmt: 
[FAILED TO PARSE] name=wlan0 ifindex=3 frame=ARRAY[b0, 00, da, 00, 10, 0b, a9, 
c6, f4, 74, d8, 24, bd, a1, 26, 31, d8, 24, bd, a1, 26, 31, 10, b7, 00, 00, 02, 
00, 00, 00]
  +   kworker/u16:0  1697 [002]   664.808210: cfg80211:cfg80211_rx_mlme_mgmt: 
netdev:wlan0(3), ftype:0xb0

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/Makefile  |  1 +
 tools/lib/traceevent/plugin_cfg80211.c | 24 
 2 files changed, 25 insertions(+)
 create mode 100644 tools/lib/traceevent/plugin_cfg80211.c

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index 671f969..0d9cbb4 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -221,6 +221,7 @@ PLUGIN_OBJS += plugin_sched_switch.o
 PLUGIN_OBJS += plugin_function.o
 PLUGIN_OBJS += plugin_xen.o
 PLUGIN_OBJS += plugin_scsi.o
+PLUGIN_OBJS += plugin_cfg80211.o
 
 PLUGINS := $(PLUGIN_OBJS:.o=.so)
 
diff --git a/tools/lib/traceevent/plugin_cfg80211.c 
b/tools/lib/traceevent/plugin_cfg80211.c
new file mode 100644
index 000..dcab8e8
--- /dev/null
+++ b/tools/lib/traceevent/plugin_cfg80211.c
@@ -0,0 +1,24 @@
+#include stdio.h
+#include string.h
+#include inttypes.h
+#include endian.h
+#include event-parse.h
+
+static unsigned long long
+process___le16_to_cpup(struct trace_seq *s,
+  unsigned long long *args)
+{
+   uint16_t *val = (uint16_t *) args[0];
+   return val ? (long long) le16toh(*val) : 0;
+}
+
+int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
+{
+   pevent_register_print_function(pevent,
+  process___le16_to_cpup,
+  PEVENT_FUNC_ARG_INT,
+  __le16_to_cpup,
+  PEVENT_FUNC_ARG_PTR,
+  PEVENT_FUNC_ARG_VOID);
+   return 0;
+}
-- 
1.8.3.1

--
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 11/28] perf tools: Overload pr_stat traceevent print function

2013-12-03 Thread Jiri Olsa
The traceevent lib uses pr_stat to display all standard
info. It's defined as __weak. Overloading it with perf
version plugged into perf output system logic.

Displaying the pr_stat stuff under '-v' option.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/perf/util/debug.c | 30 +++---
 tools/perf/util/debug.h |  2 ++
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index 399e74c..8640a91 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -16,13 +16,11 @@
 int verbose;
 bool dump_trace = false, quiet = false;
 
-int eprintf(int level, const char *fmt, ...)
+static int _eprintf(int level, const char *fmt, va_list args)
 {
-   va_list args;
int ret = 0;
 
if (verbose = level) {
-   va_start(args, fmt);
if (use_browser = 1)
ui_helpline__vshow(fmt, args);
else
@@ -33,6 +31,32 @@ int eprintf(int level, const char *fmt, ...)
return ret;
 }
 
+int eprintf(int level, const char *fmt, ...)
+{
+   va_list args;
+   int ret;
+
+   va_start(args, fmt);
+   ret = _eprintf(level, fmt, args);
+   va_end(args);
+
+   return ret;
+}
+
+/*
+ * Overloading libtraceevent standard info print
+ * function, display with -v in perf.
+ */
+void pr_stat(const char *fmt, ...)
+{
+   va_list args;
+
+   va_start(args, fmt);
+   _eprintf(1, fmt, args);
+   va_end(args);
+   eprintf(1, \n);
+}
+
 int dump_printf(const char *fmt, ...)
 {
va_list args;
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index efbd988..443694c 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -17,4 +17,6 @@ void trace_event(union perf_event *event);
 int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2)));
 int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2)));
 
+void pr_stat(const char *fmt, ...);
+
 #endif /* __PERF_DEBUG_H */
-- 
1.8.3.1

--
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 15/28] tools lib traceevent: Add kvm plugin

2013-12-03 Thread Jiri Olsa
Backporting kvm plugin.

Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git

This plugin adds field resolving functions for following
tracepoint events:
  kvm:kvm_exit
  kvm:kvm_emulate_insn
  kvm:kvm_nested_vmexit
  kvm:kvm_nested_vmexit_inject
  kvmmmu:kvm_mmu_get_page
  kvmmmu:kvm_mmu_sync_page
  kvmmmu:kvm_mmu_unsync_page
  kvmmmu:kvm_mmu_zap_page
  kvmmmu:kvm_mmu_prepare_zap_page

The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'kvm:*,kvmmmu:*' -a')

  --- script.kvm.old
  +++ script.kvm.new
qemu-system-x86 17414 [000]  6868.995053: kvm:kvm_exit: reason 
EPT_VIOLATION rip 0xfff0 info 184 0
qemu-system-x86 17414 [000]  6868.995109: kvm:kvm_emulate_insn: 
f:c46b:e4 71 (real)
  - qemu-system-x86  3006 [002] 10562.079422: kvmmmu:kvm_mmu_get_page: [FAILED 
TO PARSE] mmu_valid_gen=0x2 gfn=0 role=122884 root_count=0 unsync=0 created=1
  + qemu-system-x86  3006 [002] 10562.079422: kvmmmu:kvm_mmu_get_page: new sp 
gfn 0 0/4 q0 direct --- !pge !nxe root 0 sync
  - qemu-system-x86  3006 [002] 10562.080502: kvmmmu:kvm_mmu_prepare_zap_page: 
[FAILED TO PARSE] mmu_valid_gen=0x2 gfn=0 role=122884 root_count=1 unsync=0
  + qemu-system-x86  3006 [002] 10562.080502: kvmmmu:kvm_mmu_prepare_zap_page: 
0/4 q0 direct --- !pge !nxe root 1 sync
qemu-system-x86  3290 [002] 10708.755312: kvmmmu:fast_page_fault: [FAILED 
TO PARSE] vcpu_id=0 gva=4094486080 error_code=3 sptep=0x88019f1e3670 
old_spte=336391285 new_spte=336391287 retry=1
  -  insmod  2576 [001]   781.731666: kvmmmu:kvm_mmu_sync_page: [FAILED 
TO PARSE] mmu_valid_gen=0x1 gfn=2 role=24624 root_count=10 unsync=1
  +  insmod  2576 [001]   781.731666: kvmmmu:kvm_mmu_sync_page: 3/0 q0 
--- !pge !nxe root 10 unsync
  -  insmod  2576 [001]   781.731668: kvmmmu:kvm_mmu_unsync_page: 
[FAILED TO PARSE] mmu_valid_gen=0x1 gfn=2 role=24624 root_count=10 unsync=1
  +  insmod  2576 [001]   781.731668: kvmmmu:kvm_mmu_unsync_page: 3/0 
q0 --- !pge !nxe root 10 unsync

Note:
 - kvm_mmu_zap_page is replaced by kvm_mmu_prepare_zap_page
   in current kernel, keeping it for backward compatibility
 - some of the tracepoints keep the same output even with
   the plugin handling: kvm:kvm_exit, kvm:kvm_emulate_insn
 - the 'kvmmmu:fast_page_fault' is still broken because of
   missing is_writable_pte function and is fixed in another patch
 - ommited following tracepoints from backport because
   the output was buggy
 kvm:kvm_nested_vmexit
 kvm:kvm_nested_vmexit_inject

Signed-off-by: Steven Rostedt rost...@goodmis.org
Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/Makefile |   1 +
 tools/lib/traceevent/plugin_kvm.c | 419 ++
 2 files changed, 420 insertions(+)
 create mode 100644 tools/lib/traceevent/plugin_kvm.c

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index 245d6b4..226a8f9 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -215,6 +215,7 @@ PEVENT_LIB_OBJS += kbuffer-parse.o
 PLUGIN_OBJS  = plugin_jbd2.o
 PLUGIN_OBJS += plugin_hrtimer.o
 PLUGIN_OBJS += plugin_kmem.o
+PLUGIN_OBJS += plugin_kvm.o
 
 PLUGINS := $(PLUGIN_OBJS:.o=.so)
 
diff --git a/tools/lib/traceevent/plugin_kvm.c 
b/tools/lib/traceevent/plugin_kvm.c
new file mode 100644
index 000..be9d9c6
--- /dev/null
+++ b/tools/lib/traceevent/plugin_kvm.c
@@ -0,0 +1,419 @@
+/*
+ * Copyright (C) 2009 Red Hat Inc, Steven Rostedt srost...@redhat.com
+ *
+ * ~~
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License (not later!)
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not,  see http://www.gnu.org/licenses
+ *
+ * ~~
+ */
+#include stdio.h
+#include stdlib.h
+#include string.h
+#include stdint.h
+
+#include event-parse.h
+
+#ifdef HAVE_UDIS86
+
+#include udis86.h
+
+static ud_t ud;
+
+static void init_disassembler(void)
+{
+   ud_init(ud

[PATCH 14/28] tools lib traceevent: Add kmem plugin

2013-12-03 Thread Jiri Olsa
Backporting kmem plugin.

Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git

This plugin adds call_site field resolving for following
tracepoint events:
  kmem:kfree
  kmem:kmalloc
  kmem:kmalloc_node
  kmem:kmem_cache_alloc
  kmem:kmem_cache_alloc_node
  kmem:kmem_cache_free

The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'kmem:*' -a')

  --- script.kmem.old
  +++ script.kmem.new
  -perf 27846 [001] 29643.403319: kmem:kfree: 
call_site=810e64f6 ptr=(nil)
  +perf 27846 [001] 29643.403238: kmem:kfree: 
(__audit_syscall_exit+0x1f6) call_site=810e64f6 ptr=(nil)
  -perf 27846 [001] 29643.403337: kmem:kmem_cache_alloc: 
call_site=812ff0c5 ptr=0x88020e155630 bytes_req=560 bytes_alloc=568 
gfp_flags=GFP_KERNEL
  +perf 27846 [001] 29643.403337: kmem:kmem_cache_alloc: 
(radix_tree_preload+0x35) call_site=812ff0c5 ptr=0x88020e155630 
bytes_req=560 bytes_alloc=568 gfp_flags=GFP_KERNEL
  -perf 27846 [001] 29643.403342: kmem:kmem_cache_free: 
call_site=8126ec61 ptr=0x88020dffe750
  +perf 27846 [001] 29643.403342: kmem:kmem_cache_free: 
(jbd2_journal_stop+0x221) call_site=8126ec61 ptr=0x88020dffe750
  - firefox   954 [000] 29643.445477: kmem:kmem_cache_alloc_node: 
call_site=8153c64e ptr=0x8801cecb4000 bytes_req=256 bytes_alloc=256 
gfp_flags=GFP_KERNEL|GFP_REPEAT node=-1
  + firefox   954 [000] 29643.445477: kmem:kmem_cache_alloc_node: 
(__alloc_skb+0x4e) call_site=8153c64e ptr=0x8801cecb4000 
bytes_req=256 bytes_alloc=256 gfp_flags=GFP_KERNEL|GFP_REPEAT node=-1
  -perf 27846 [001] 29643.445510: kmem:kmalloc: 
call_site=81250642 ptr=0x88020fd6c300 bytes_req=96 bytes_alloc=96 
gfp_flags=GFP_NOFS|GFP_ZERO
  +perf 27846 [001] 29643.445510: kmem:kmalloc: 
(ext4_ext_find_extent+0x362) call_site=81250642 ptr=0x88020fd6c300 
bytes_req=96 bytes_alloc=96 gfp_flags=GFP_NOFS|GFP_ZERO
  -   X   888 [002] 29643.445546: kmem:kmalloc_node: 
call_site=8153c67e ptr=0x880103828e00 bytes_req=384 bytes_alloc=512 
gfp_flags=GFP_KERNEL|GFP_NOWARN|GFP_REPEAT|GFP_NOMEMALLOC node=-1
  +   X   888 [002] 29643.445546: kmem:kmalloc_node: 
(__alloc_skb+0x7e) call_site=8153c67e ptr=0x880103828e00 
bytes_req=384 bytes_alloc=512 
gfp_flags=GFP_KERNEL|GFP_NOWARN|GFP_REPEAT|GFP_NOMEMALLOC node=-1

Signed-off-by: Steven Rostedt rost...@goodmis.org
Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/Makefile  |  1 +
 tools/lib/traceevent/plugin_kmem.c | 72 ++
 2 files changed, 73 insertions(+)
 create mode 100644 tools/lib/traceevent/plugin_kmem.c

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index 9ff2e25..245d6b4 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -214,6 +214,7 @@ PEVENT_LIB_OBJS += kbuffer-parse.o
 
 PLUGIN_OBJS  = plugin_jbd2.o
 PLUGIN_OBJS += plugin_hrtimer.o
+PLUGIN_OBJS += plugin_kmem.o
 
 PLUGINS := $(PLUGIN_OBJS:.o=.so)
 
diff --git a/tools/lib/traceevent/plugin_kmem.c 
b/tools/lib/traceevent/plugin_kmem.c
new file mode 100644
index 000..7115c80
--- /dev/null
+++ b/tools/lib/traceevent/plugin_kmem.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2009 Red Hat Inc, Steven Rostedt srost...@redhat.com
+ *
+ * ~~
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License (not later!)
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not,  see http://www.gnu.org/licenses
+ *
+ * ~~
+ */
+#include stdio.h
+#include stdlib.h
+#include string.h
+
+#include event-parse.h
+
+static int call_site_handler(struct trace_seq *s, struct pevent_record *record,
+struct event_format *event, void *context)
+{
+   struct format_field

[PATCH 13/28] tools lib traceevent: Add hrtimer plugin

2013-12-03 Thread Jiri Olsa
Backporting hrtimer plugin.

Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git

This plugin adds function field resolving for following
tracepoint events:
  timer:hrtimer_expire_entry
  timer:hrtimer_start

The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'timer:hrtimer*' -a')

  --- script.hrtimer.old
  +++ script.hrtimer.new
  - swapper 0 [000] 27405.519092: timer:hrtimer_start: [FAILED TO 
PARSE] hrtimer=0x88021e20e800 function=0x810c0e10 
expires=2739838300 softexpires=2739838300
  + swapper 0 [000] 27405.519103: timer:hrtimer_start: 
hrtimer=0x88021e20e800 function=tick_sched_timer expires=2739838300 
softexpires=2739838300
  - swapper 0 [001] 27405.519544: timer:hrtimer_expire_entry: 
[FAILED TO PARSE] hrtimer=0x880211334058 now=27398294182491 
function=0x81086f20
  + swapper 0 [001] 27405.519544: timer:hrtimer_expire_entry: 
hrtimer=0x880211334058 now=27398294182491 function=posix_timer_fn/0x0

Check the 'function' field is translated into the function name.

Signed-off-by: Steven Rostedt rost...@goodmis.org
Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/Makefile |  3 +-
 tools/lib/traceevent/plugin_hrtimer.c | 93 +++
 2 files changed, 95 insertions(+), 1 deletion(-)
 create mode 100644 tools/lib/traceevent/plugin_hrtimer.c

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index 6c65400..9ff2e25 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -212,7 +212,8 @@ PEVENT_LIB_OBJS += parse-filter.o
 PEVENT_LIB_OBJS += parse-utils.o
 PEVENT_LIB_OBJS += kbuffer-parse.o
 
-PLUGIN_OBJS = plugin_jbd2.o
+PLUGIN_OBJS  = plugin_jbd2.o
+PLUGIN_OBJS += plugin_hrtimer.o
 
 PLUGINS := $(PLUGIN_OBJS:.o=.so)
 
diff --git a/tools/lib/traceevent/plugin_hrtimer.c 
b/tools/lib/traceevent/plugin_hrtimer.c
new file mode 100644
index 000..e41d4cf
--- /dev/null
+++ b/tools/lib/traceevent/plugin_hrtimer.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2009 Red Hat Inc, Steven Rostedt srost...@redhat.com
+ * Copyright (C) 2009 Johannes Berg johan...@sipsolutions.net
+ *
+ * ~~
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License (not later!)
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not,  see http://www.gnu.org/licenses
+ *
+ * ~~
+ */
+#include stdio.h
+#include stdlib.h
+#include string.h
+
+#include event-parse.h
+
+static int timer_expire_handler(struct trace_seq *s,
+   struct pevent_record *record,
+   struct event_format *event, void *context)
+{
+   trace_seq_printf(s, hrtimer=);
+
+   if (pevent_print_num_field(s, 0x%llx, event, timer,
+  record, 0) == -1)
+   pevent_print_num_field(s, 0x%llx, event, hrtimer,
+  record, 1);
+
+   trace_seq_printf(s,  now=);
+
+   pevent_print_num_field(s, %llu, event, now, record, 1);
+
+   pevent_print_func_field(s,  function=%s, event, function,
+   record, 0);
+   return 0;
+}
+
+static int timer_start_handler(struct trace_seq *s,
+  struct pevent_record *record,
+  struct event_format *event, void *context)
+{
+   struct pevent *pevent = event-pevent;
+   struct format_field *fn = pevent_find_field(event, function);
+   void *data = record-data;
+
+   trace_seq_printf(s, hrtimer=);
+
+   if (pevent_print_num_field(s, 0x%llx, event, timer,
+  record, 0) == -1)
+   pevent_print_num_field(s, 0x%llx, event, hrtimer,
+  record, 1);
+
+   if (!fn) {
+   trace_seq_printf(s,  function=MISSING);
+   } else

[PATCH 19/28] tools lib traceevent: Add xen plugin

2013-12-03 Thread Jiri Olsa
Adding xen plugin.

This plugin adds fields resolving for
following tracepoint events:
  xen:xen_mc_entry
  xen:xen_mc_extend_args

The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'xen:*' ls')

  --- script.xen.old
  +++ script.xen.new
  - swapper 0 [002]   136.267492: xen:xen_mc_entry: [FAILED TO 
PARSE] op=3 nargs=2 args=ARRAY[18, 00, 00, 00, 00, 00, 00, 00, 00, e0, d4, 4b, 
04, 88, ff, ff, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 
00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00]
  + swapper 0 [002]   136.267492: xen:xen_mc_entry: op 
3(stack_switch) args [18, 0, 0, 0, 0, 0]
  -perf  1970 [008]   136.273319: xen:xen_mc_extend_args: [FAILED 
TO PARSE] op=1 args=16 res=1
  +perf  1970 [008]   136.273319: xen:xen_mc_extend_args: extending 
op 1(mmu_update) by 16 bytes res ???

NOTE We still do not handle the 'sizeof' and fail
to parse following xen tracepoints:
  xen:xen_mmu_set_pte
  xen:xen_mmu_set_pte_atomic
  xen:xen_mmu_set_domain_pte
  xen:xen_mmu_set_pte_at
  xen:xen_mmu_set_pmd
  xen:xen_mmu_set_pud
  xen:xen_mmu_set_pgd
  xen:xen_mmu_ptep_modify_prot_start
  xen:xen_mmu_ptep_modify_prot_commit

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
Cc: Jeremy Fitzhardinge jeremy.fitzhardi...@citrix.com
---
 tools/lib/traceevent/Makefile |   1 +
 tools/lib/traceevent/plugin_xen.c | 130 ++
 2 files changed, 131 insertions(+)
 create mode 100644 tools/lib/traceevent/plugin_xen.c

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index 21f9b8f..54af60a 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -219,6 +219,7 @@ PLUGIN_OBJS += plugin_kvm.o
 PLUGIN_OBJS += plugin_mac80211.o
 PLUGIN_OBJS += plugin_sched_switch.o
 PLUGIN_OBJS += plugin_function.o
+PLUGIN_OBJS += plugin_xen.o
 
 PLUGINS := $(PLUGIN_OBJS:.o=.so)
 
diff --git a/tools/lib/traceevent/plugin_xen.c 
b/tools/lib/traceevent/plugin_xen.c
new file mode 100644
index 000..e779429
--- /dev/null
+++ b/tools/lib/traceevent/plugin_xen.c
@@ -0,0 +1,130 @@
+#include stdio.h
+#include stdlib.h
+#include string.h
+#include event-parse.h
+
+#define __HYPERVISOR_set_trap_table0
+#define __HYPERVISOR_mmu_update1
+#define __HYPERVISOR_set_gdt   2
+#define __HYPERVISOR_stack_switch  3
+#define __HYPERVISOR_set_callbacks 4
+#define __HYPERVISOR_fpu_taskswitch5
+#define __HYPERVISOR_sched_op_compat   6
+#define __HYPERVISOR_dom0_op   7
+#define __HYPERVISOR_set_debugreg  8
+#define __HYPERVISOR_get_debugreg  9
+#define __HYPERVISOR_update_descriptor 10
+#define __HYPERVISOR_memory_op 12
+#define __HYPERVISOR_multicall 13
+#define __HYPERVISOR_update_va_mapping 14
+#define __HYPERVISOR_set_timer_op  15
+#define __HYPERVISOR_event_channel_op_compat   16
+#define __HYPERVISOR_xen_version   17
+#define __HYPERVISOR_console_io18
+#define __HYPERVISOR_physdev_op_compat 19
+#define __HYPERVISOR_grant_table_op20
+#define __HYPERVISOR_vm_assist 21
+#define __HYPERVISOR_update_va_mapping_otherdomain 22
+#define __HYPERVISOR_iret  23 /* x86 only */
+#define __HYPERVISOR_vcpu_op   24
+#define __HYPERVISOR_set_segment_base  25 /* x86/64 only */
+#define __HYPERVISOR_mmuext_op 26
+#define __HYPERVISOR_acm_op27
+#define __HYPERVISOR_nmi_op28
+#define __HYPERVISOR_sched_op  29
+#define __HYPERVISOR_callback_op   30
+#define __HYPERVISOR_xenoprof_op   31
+#define __HYPERVISOR_event_channel_op  32
+#define __HYPERVISOR_physdev_op33
+#define __HYPERVISOR_hvm_op34
+#define __HYPERVISOR_tmem_op   38
+
+/* Architecture-specific hypercall definitions. */
+#define __HYPERVISOR_arch_048
+#define __HYPERVISOR_arch_149
+#define __HYPERVISOR_arch_250
+#define __HYPERVISOR_arch_3

[PATCH 16/28] tools lib traceevent: Add mac80211 plugin

2013-12-03 Thread Jiri Olsa
Backporting mac80211 plugin.

Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git

This plugin adds changed field resolving for
mac80211:drv_bss_info_changed tracepoint event.

The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'mac80211:drv_bss_info_changed' -a')

  --- script.mac80211.old
  +++ script.mac80211.new
  -ifconfig  3711 [000]  1290.446492: mac80211:drv_bss_info_changed: 
phy0 vif:wlan0(2) changed:0x309f
  +ifconfig  3711 [000]  1290.446492: mac80211:drv_bss_info_changed: 
phy0 vif:wlan0(2)
  + assoc:0 
aid:2 cts:0 shortpre:0 shortslot:0 dtimper:1
  + bcnint:102 
assoc_cap:0x431 basic_rates:0xf enable_beacon:0
  + 
ht_operation_mode:0

Omitting the mac80211:drv_config tracepoint handling
because the kernel tracepoint changed its prototype
and the plugin handler is no longer working.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/Makefile  |  1 +
 tools/lib/traceevent/plugin_mac80211.c | 95 ++
 2 files changed, 96 insertions(+)
 create mode 100644 tools/lib/traceevent/plugin_mac80211.c

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index 226a8f9..d0e0ca1 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -216,6 +216,7 @@ PLUGIN_OBJS  = plugin_jbd2.o
 PLUGIN_OBJS += plugin_hrtimer.o
 PLUGIN_OBJS += plugin_kmem.o
 PLUGIN_OBJS += plugin_kvm.o
+PLUGIN_OBJS += plugin_mac80211.o
 
 PLUGINS := $(PLUGIN_OBJS:.o=.so)
 
diff --git a/tools/lib/traceevent/plugin_mac80211.c 
b/tools/lib/traceevent/plugin_mac80211.c
new file mode 100644
index 000..558a3b9
--- /dev/null
+++ b/tools/lib/traceevent/plugin_mac80211.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2009 Johannes Berg johan...@sipsolutions.net
+ *
+ * ~~
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License (not later!)
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not,  see http://www.gnu.org/licenses
+ *
+ * ~~
+ */
+#include stdio.h
+#include stdlib.h
+#include string.h
+
+#include event-parse.h
+
+#define INDENT 65
+
+static void print_string(struct trace_seq *s, struct event_format *event,
+const char *name, const void *data)
+{
+   struct format_field *f = pevent_find_field(event, name);
+   int offset;
+   int length;
+
+   if (!f) {
+   trace_seq_printf(s, NOTFOUND:%s, name);
+   return;
+   }
+
+   offset = f-offset;
+   length = f-size;
+
+   if (!strncmp(f-type, __data_loc, 10)) {
+   unsigned long long v;
+   if (pevent_read_number_field(f, data, v)) {
+   trace_seq_printf(s, invalid_data_loc);
+   return;
+   }
+   offset = v  0x;
+   length = v  16;
+   }
+
+   trace_seq_printf(s, %.*s, length, (char *)data + offset);
+}
+
+#define SF(fn) pevent_print_num_field(s, fn :%d, event, fn, record, 0)
+#define SFX(fn)pevent_print_num_field(s, fn :%#x, event, fn, record, 
0)
+#define SP()   trace_seq_putc(s, ' ')
+
+static int drv_bss_info_changed(struct trace_seq *s,
+   struct pevent_record *record,
+   struct event_format *event, void *context)
+{
+   void *data = record-data;
+
+   print_string(s, event, wiphy_name, data);
+   trace_seq_printf(s,  vif:);
+   print_string(s, event, vif_name, data);
+   pevent_print_num_field(s, (%d), event, vif_type, record, 1);
+
+   trace_seq_printf(s, \n%*s, INDENT, );
+   SF(assoc); SP();
+   SF(aid); SP();
+   SF(cts); SP();
+   SF(shortpre); SP();
+   SF(shortslot); SP

[PATCH 12/28] tools lib traceevent: Add jbd2 plugin

2013-12-03 Thread Jiri Olsa
Backporting jbd2 plugin.

Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git

This plugin adds field resolving functions for following
tracepoint events:
  jbd2:jbd2_checkpoint_stats
  jbd2:jbd2_run_stats

The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 
'jbd2:jbd2_run_stats,jbd2:jbd2_checkpoint_stats' -a')

  --- script.jbd2.old
  +++ script.jbd2.new
  - jbd2/dm-3-8   576 [000]  2983.748423: jbd2:jbd2_checkpoint_stats: 
[FAILED TO PARSE] dev=265289731 tid=0x3f2bbb chp_time=0x0 forced_to_close=0 
written=0 dropped=2
  + jbd2/dm-3-8   576 [000]  2983.748423: jbd2:jbd2_checkpoint_stats: dev 
253,3 tid 4139963 chp_time 0 forced_to_close 0 written 0 dropped 2
  - jbd2/dm-3-8   576 [000]  2983.852789: jbd2:jbd2_run_stats: [FAILED TO 
PARSE] dev=265289731 tid=0x3f2bc0 wait=0x0 request_delay=0x0 running=0x138d 
locked=0x0 flushing=0x0 logging=0x68 handle_count=2995 blocks=17 
blocks_logged=18
  + jbd2/dm-3-8   576 [000]  2983.852789: jbd2:jbd2_run_stats: dev 253,3 
tid 4139968 wait 0 request_delay 0 running 5005 locked 0 flushing 0 logging 104 
handle_count 2995 blocks 17 blocks_logged 18

This plugin also adds jbd2_dev_to_name function, which
was removed from jdb2 tracepoints recently. Keeping it
in for backward compatibility reasons.

Signed-off-by: Steven Rostedt rost...@goodmis.org
Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/Makefile  |  2 ++
 tools/lib/traceevent/plugin_jbd2.c | 66 ++
 2 files changed, 68 insertions(+)
 create mode 100644 tools/lib/traceevent/plugin_jbd2.c

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index f946851..6c65400 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -212,6 +212,8 @@ PEVENT_LIB_OBJS += parse-filter.o
 PEVENT_LIB_OBJS += parse-utils.o
 PEVENT_LIB_OBJS += kbuffer-parse.o
 
+PLUGIN_OBJS = plugin_jbd2.o
+
 PLUGINS := $(PLUGIN_OBJS:.o=.so)
 
 ALL_OBJS = $(PEVENT_LIB_OBJS) $(PLUGIN_OBJS)
diff --git a/tools/lib/traceevent/plugin_jbd2.c 
b/tools/lib/traceevent/plugin_jbd2.c
new file mode 100644
index 000..5d85de7
--- /dev/null
+++ b/tools/lib/traceevent/plugin_jbd2.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010 Red Hat Inc, Steven Rostedt srost...@redhat.com
+ *
+ * ~~
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License (not later!)
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not,  see http://www.gnu.org/licenses
+ *
+ * ~~
+ */
+#include stdio.h
+#include stdlib.h
+#include string.h
+
+#include event-parse.h
+
+#define MINORBITS  20
+#define MINORMASK  ((1U  MINORBITS) - 1)
+
+#define MAJOR(dev) ((unsigned int) ((dev)  MINORBITS))
+#define MINOR(dev) ((unsigned int) ((dev)  MINORMASK))
+
+unsigned long long process_jbd2_dev_to_name(struct trace_seq *s,
+   unsigned long long *args)
+{
+   unsigned int dev = args[0];
+
+   trace_seq_printf(s, %d:%d, MAJOR(dev), MINOR(dev));
+   return 0;
+}
+
+unsigned long long process_jiffies_to_msecs(struct trace_seq *s,
+   unsigned long long *args)
+{
+   unsigned long long jiffies = args[0];
+
+   trace_seq_printf(s, %lld, jiffies);
+   return jiffies;
+}
+
+int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
+{
+   pevent_register_print_function(pevent,
+  process_jbd2_dev_to_name,
+  PEVENT_FUNC_ARG_STRING,
+  jbd2_dev_to_name,
+  PEVENT_FUNC_ARG_INT,
+  PEVENT_FUNC_ARG_VOID);
+
+   pevent_register_print_function(pevent,
+  process_jiffies_to_msecs,
+  PEVENT_FUNC_ARG_LONG

[PATCH 17/28] tools lib traceevent: Add sched_switch plugin

2013-12-03 Thread Jiri Olsa
Backporting sched_switch plugin.

Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git

This plugin adds fields resolving for
sched:sched_switch tracepoint event.

The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e sched:sched_switch -a')

  --- script.sched_switch.old
  +++ script.sched_switch.new
  -perf   577 [002] 30965.311852: sched:sched_switch: 
prev_comm=perf prev_pid=577 prev_prio=120 prev_state=S == next_comm=swapper/2 
next_pid=0 next_prio=120
  +perf   577 [002] 30965.311852: sched:sched_switch: perf:577 
[120] S == swapper/2:0 [120]

Signed-off-by: Steven Rostedt rost...@goodmis.org
Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/Makefile  |   1 +
 tools/lib/traceevent/plugin_sched_switch.c | 148 +
 2 files changed, 149 insertions(+)
 create mode 100644 tools/lib/traceevent/plugin_sched_switch.c

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index d0e0ca1..1c319a8 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -217,6 +217,7 @@ PLUGIN_OBJS += plugin_hrtimer.o
 PLUGIN_OBJS += plugin_kmem.o
 PLUGIN_OBJS += plugin_kvm.o
 PLUGIN_OBJS += plugin_mac80211.o
+PLUGIN_OBJS += plugin_sched_switch.o
 
 PLUGINS := $(PLUGIN_OBJS:.o=.so)
 
diff --git a/tools/lib/traceevent/plugin_sched_switch.c 
b/tools/lib/traceevent/plugin_sched_switch.c
new file mode 100644
index 000..fea3724
--- /dev/null
+++ b/tools/lib/traceevent/plugin_sched_switch.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt srost...@redhat.com
+ *
+ * ~~
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License (not later!)
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not,  see http://www.gnu.org/licenses
+ *
+ * ~~
+ */
+#include stdio.h
+#include stdlib.h
+#include string.h
+
+#include event-parse.h
+
+static void write_state(struct trace_seq *s, int val)
+{
+   const char states[] = SDTtZXxW;
+   int found = 0;
+   int i;
+
+   for (i = 0; i  (sizeof(states) - 1); i++) {
+   if (!(val  (1  i)))
+   continue;
+
+   if (found)
+   trace_seq_putc(s, '|');
+
+   found = 1;
+   trace_seq_putc(s, states[i]);
+   }
+
+   if (!found)
+   trace_seq_putc(s, 'R');
+}
+
+static void write_and_save_comm(struct format_field *field,
+   struct pevent_record *record,
+   struct trace_seq *s, int pid)
+{
+   const char *comm;
+   int len;
+
+   comm = (char *)(record-data + field-offset);
+   len = s-len;
+   trace_seq_printf(s, %.*s,
+field-size, comm);
+
+   /* make sure the comm has a \0 at the end. */
+   trace_seq_terminate(s);
+   comm = s-buffer[len];
+
+   /* Help out the comm to ids. This will handle dups */
+   pevent_register_comm(field-event-pevent, comm, pid);
+}
+
+static int sched_wakeup_handler(struct trace_seq *s,
+   struct pevent_record *record,
+   struct event_format *event, void *context)
+{
+   struct format_field *field;
+   unsigned long long val;
+
+   if (pevent_get_field_val(s, event, pid, record, val, 1))
+   return trace_seq_putc(s, '!');
+
+   field = pevent_find_any_field(event, comm);
+   if (field) {
+   write_and_save_comm(field, record, s, val);
+   trace_seq_putc(s, ':');
+   }
+   trace_seq_printf(s, %lld, val);
+
+   if (pevent_get_field_val(s, event, prio, record, val, 0) == 0)
+   trace_seq_printf(s,  [%lld], val);
+
+   if (pevent_get_field_val(s, event, success, record, val, 1) == 0)
+   trace_seq_printf(s,  success=%lld, val

[PATCH 09/28] perf tools: Add trace-event object

2013-12-03 Thread Jiri Olsa
Add trace-event object to keep together 'struct pevent'
object with its loaded plugins with following interface:

int trace_event__init(struct trace_event *t);
  - initalizes 'struct pevent' object and loads plugins for it

void trace_event__cleanup(struct trace_event *t);
  - cleanups both 'struct pevent' and plugins

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/perf/Makefile.perf|  1 +
 tools/perf/builtin-script.c |  2 +-
 tools/perf/util/header.c|  8 
 tools/perf/util/python-ext-sources  |  1 +
 tools/perf/util/session.h   |  3 ++-
 tools/perf/util/trace-event-parse.c | 13 -
 tools/perf/util/trace-event-read.c  | 20 +++-
 tools/perf/util/trace-event.c   | 21 +
 tools/perf/util/trace-event.h   | 13 ++---
 9 files changed, 51 insertions(+), 31 deletions(-)
 create mode 100644 tools/perf/util/trace-event.c

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index abc7ac3..ca3b87d 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -353,6 +353,7 @@ LIB_OBJS += $(OUTPUT)util/pmu-bison.o
 LIB_OBJS += $(OUTPUT)util/trace-event-read.o
 LIB_OBJS += $(OUTPUT)util/trace-event-info.o
 LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o
+LIB_OBJS += $(OUTPUT)util/trace-event.o
 LIB_OBJS += $(OUTPUT)util/svghelper.o
 LIB_OBJS += $(OUTPUT)util/sort.o
 LIB_OBJS += $(OUTPUT)util/hist.o
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 952dce9..715766d 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1785,7 +1785,7 @@ int cmd_script(int argc, const char **argv, const char 
*prefix __maybe_unused)
return -1;
}
 
-   err = scripting_ops-generate_script(session-pevent,
+   err = scripting_ops-generate_script(session-tevent.pevent,
 perf-script);
goto out;
}
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 3e755f2..125cdc9 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2834,11 +2834,11 @@ int perf_session__read_header(struct perf_session 
*session)
 
symbol_conf.nr_events = nr_attrs;
 
-   perf_header__process_sections(header, fd, session-pevent,
+   perf_header__process_sections(header, fd, session-tevent,
  perf_file_section__process);
 
if (perf_evlist__prepare_tracepoint_events(session-evlist,
-  session-pevent))
+  session-tevent.pevent))
goto out_delete_evlist;
 
return 0;
@@ -3003,7 +3003,7 @@ int perf_event__process_tracing_data(struct perf_tool 
*tool __maybe_unused,
lseek(fd, offset + sizeof(struct tracing_data_event),
  SEEK_SET);
 
-   size_read = trace_report(fd, session-pevent,
+   size_read = trace_report(fd, session-tevent,
 session-repipe);
padding = PERF_ALIGN(size_read, sizeof(u64)) - size_read;
 
@@ -3025,7 +3025,7 @@ int perf_event__process_tracing_data(struct perf_tool 
*tool __maybe_unused,
}
 
perf_evlist__prepare_tracepoint_events(session-evlist,
-  session-pevent);
+  session-tevent.pevent);
 
return size_read + padding;
 }
diff --git a/tools/perf/util/python-ext-sources 
b/tools/perf/util/python-ext-sources
index 239036f..595bfc7 100644
--- a/tools/perf/util/python-ext-sources
+++ b/tools/perf/util/python-ext-sources
@@ -18,4 +18,5 @@ util/cgroup.c
 util/rblist.c
 util/strlist.c
 util/fs.c
+util/trace-event.c
 ../../lib/rbtree.c
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 50f6409..83cba9b 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -1,6 +1,7 @@
 #ifndef __PERF_SESSION_H
 #define __PERF_SESSION_H
 
+#include trace-event.h
 #include hist.h
 #include event.h
 #include header.h
@@ -32,7 +33,7 @@ struct perf_session {
struct perf_header  header;
struct machines machines;
struct perf_evlist  *evlist;
-   struct pevent   *pevent;
+   struct trace_event  tevent;
struct events_stats stats;
boolrepipe;
struct ordered_samples  ordered_samples;
diff --git a/tools/perf/util/trace-event-parse.c 
b/tools/perf/util/trace-event-parse.c
index 6681f71

[PATCH 01/28] perf tools: Remove stackprotector feature check

2013-12-03 Thread Jiri Olsa
We use -fstack-protector-all option to enable stack protecting
for all available functions. There's no reason for enabling
-Wstack-protector to get warning for unprotected functions.

Removing stackprotector feature check which was used to
enable the -Wstack-protector option.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/perf/config/Makefile | 5 -
 tools/perf/config/feature-checks/Makefile  | 6 +-
 tools/perf/config/feature-checks/test-stackprotector.c | 6 --
 3 files changed, 1 insertion(+), 16 deletions(-)
 delete mode 100644 tools/perf/config/feature-checks/test-stackprotector.c

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 36e66ac..0761d57 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -141,7 +141,6 @@ CORE_FEATURE_TESTS =\
libslang\
libunwind   \
on-exit \
-   stackprotector  \
stackprotector-all  \
timerfd
 
@@ -209,10 +208,6 @@ ifeq ($(feature-stackprotector-all), 1)
   CFLAGS += -fstack-protector-all
 endif
 
-ifeq ($(feature-stackprotector), 1)
-  CFLAGS += -Wstack-protector
-endif
-
 ifeq ($(DEBUG),0)
   ifeq ($(feature-fortify-source), 1)
 CFLAGS += -D_FORTIFY_SOURCE=2
diff --git a/tools/perf/config/feature-checks/Makefile 
b/tools/perf/config/feature-checks/Makefile
index 87e7900..b8bb749 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -26,7 +26,6 @@ FILES=\
test-libunwind-debug-frame  \
test-on-exit\
test-stackprotector-all \
-   test-stackprotector \
test-timerfd
 
 CC := $(CC) -MD
@@ -38,7 +37,7 @@ BUILD = $(CC) $(CFLAGS) $(LDFLAGS) -o $(OUTPUT)$@ $@.c
 ###
 
 test-all:
-   $(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror 
-D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma $(LIBUNWIND_LIBS) -lelf -laudit 
-I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 
2/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='perf' -lbfd 
-ldl
+   $(BUILD) -Werror -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 
-ldw -lelf -lnuma $(LIBUNWIND_LIBS) -lelf -laudit -I/usr/include/slang -lslang 
$(shell pkg-config --libs --cflags gtk+-2.0 2/dev/null) $(FLAGS_PERL_EMBED) 
$(FLAGS_PYTHON_EMBED) -DPACKAGE='perf' -lbfd -ldl
 
 test-hello:
$(BUILD)
@@ -46,9 +45,6 @@ test-hello:
 test-stackprotector-all:
$(BUILD) -Werror -fstack-protector-all
 
-test-stackprotector:
-   $(BUILD) -Werror -fstack-protector -Wstack-protector
-
 test-fortify-source:
$(BUILD) -O2 -Werror -D_FORTIFY_SOURCE=2
 
diff --git a/tools/perf/config/feature-checks/test-stackprotector.c 
b/tools/perf/config/feature-checks/test-stackprotector.c
deleted file mode 100644
index c9f398d..000
--- a/tools/perf/config/feature-checks/test-stackprotector.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include stdio.h
-
-int main(void)
-{
-   return puts(hi);
-}
-- 
1.8.3.1

--
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 05/28] tools lib traceevent: Change pevent_parse_format to include pevent handle

2013-12-03 Thread Jiri Olsa
Changing the pevent_parse_format interface to include the
pevent handle.

The goal is to always use pevent object when dealing with
traceevent library. The reason is that we might need additional
processing (like plugins), which is not possible otherwise.

Patches follow to make this happen completely.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/event-parse.c | 56 --
 tools/lib/traceevent/event-parse.h |  4 ++-
 tools/perf/util/evsel.c|  2 +-
 3 files changed, 39 insertions(+), 23 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c 
b/tools/lib/traceevent/event-parse.c
index 74007ab..22566c2 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -5129,8 +5129,38 @@ enum pevent_errno __pevent_parse_format(struct 
event_format **eventp,
return ret;
 }
 
+static enum pevent_errno
+__pevent_parse_event(struct pevent *pevent,
+struct event_format **eventp,
+const char *buf, unsigned long size,
+const char *sys)
+{
+   int ret = __pevent_parse_format(eventp, pevent, buf, size, sys);
+   struct event_format *event = *eventp;
+
+   if (event == NULL)
+   return ret;
+
+   if (pevent  add_event(pevent, event)) {
+   ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
+   goto event_add_failed;
+   }
+
+#define PRINT_ARGS 0
+   if (PRINT_ARGS  event-print_fmt.args)
+   print_args(event-print_fmt.args);
+
+   return 0;
+
+event_add_failed:
+   pevent_free_format(event);
+   return ret;
+}
+
 /**
  * pevent_parse_format - parse the event format
+ * @pevent: the handle to the pevent
+ * @eventp: returned format
  * @buf: the buffer storing the event format string
  * @size: the size of @buf
  * @sys: the system the event belongs to
@@ -5142,10 +5172,12 @@ enum pevent_errno __pevent_parse_format(struct 
event_format **eventp,
  *
  * /sys/kernel/debug/tracing/events/.../.../format
  */
-enum pevent_errno pevent_parse_format(struct event_format **eventp, const char 
*buf,
+enum pevent_errno pevent_parse_format(struct pevent *pevent,
+ struct event_format **eventp,
+ const char *buf,
  unsigned long size, const char *sys)
 {
-   return __pevent_parse_format(eventp, NULL, buf, size, sys);
+   return __pevent_parse_event(pevent, eventp, buf, size, sys);
 }
 
 /**
@@ -5166,25 +5198,7 @@ enum pevent_errno pevent_parse_event(struct pevent 
*pevent, const char *buf,
 unsigned long size, const char *sys)
 {
struct event_format *event = NULL;
-   int ret = __pevent_parse_format(event, pevent, buf, size, sys);
-
-   if (event == NULL)
-   return ret;
-
-   if (add_event(pevent, event)) {
-   ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
-   goto event_add_failed;
-   }
-
-#define PRINT_ARGS 0
-   if (PRINT_ARGS  event-print_fmt.args)
-   print_args(event-print_fmt.args);
-
-   return 0;
-
-event_add_failed:
-   pevent_free_format(event);
-   return ret;
+   return __pevent_parse_event(pevent, event, buf, size, sys);
 }
 
 #undef _PE
diff --git a/tools/lib/traceevent/event-parse.h 
b/tools/lib/traceevent/event-parse.h
index 54273c0..620c27a 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -562,7 +562,9 @@ int pevent_parse_header_page(struct pevent *pevent, char 
*buf, unsigned long siz
 
 enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,
 unsigned long size, const char *sys);
-enum pevent_errno pevent_parse_format(struct event_format **eventp, const char 
*buf,
+enum pevent_errno pevent_parse_format(struct pevent *pevent,
+ struct event_format **eventp,
+ const char *buf,
  unsigned long size, const char *sys);
 void pevent_free_format(struct event_format *event);
 
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index b5fe7f9..6a046ed 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -210,7 +210,7 @@ struct event_format *event_format__new(const char *sys, 
const char *name)
size += n;
} while (n  0);
 
-   pevent_parse_format(format, bf, size, sys);
+   pevent_parse_format(NULL, format, bf, size, sys);
 
 out_free_bf

[PATCH 02/28] tools lib traceevent: Add plugin support

2013-12-03 Thread Jiri Olsa
Backporting plugin support for traceevent lib.

Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git

It's now possible to use following interface to load plugins
(shared objects) to enhance pevent object functionality.

The plugin interface/hooks are as follows:
(taken from event-parse.h comments)

- 'pevent_plugin_loader' (required)
The function name to initialized the plugin.

int pevent_plugin_loader(struct pevent *pevent)

- 'pevent_plugin_unloader' (optional)
The function called just before unloading

int pevent_plugin_unloader(void)

- 'pevent_plugin_options'  (optional)
Plugin options that can be set before loading

struct plugin_option pevent_plugin_options[] = {
   {
   .name = option-name,
   .plugin_alias = overide-file-name, (optional)
   .description = description of option to show users,
   },
   {
   .name = NULL,
   },
};

Array must end with .name = NULL;

The plugin_alias (below) can be used to give a shorter
name to access the variable. Useful if a plugin handles
more than one event.

NOTE options support is not backported yet.

- 'pevent_plugin_alias' (optional)
The name to use for finding options (uses filename if not defined)

New traceevent functions are added to search and load
available plugins:

  struct plugin_list*
  traceevent_load_plugins(struct pevent *pevent)
- loads plusing for 'struct pevent' object and returns
  loaded plugins list

  void traceevent_unload_plugins(struct plugin_list *plugin_list);
- unload plugin list

Signed-off-by: Steven Rostedt rost...@goodmis.org
Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/Makefile   |   6 +-
 tools/lib/traceevent/event-parse.h  |   5 +
 tools/lib/traceevent/event-plugin.c | 202 
 3 files changed, 212 insertions(+), 1 deletion(-)
 create mode 100644 tools/lib/traceevent/event-plugin.c

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index fc15020..2ccb5bc 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -180,7 +180,11 @@ $(obj)/%.o: $(src)/%.c
 %.o: $(src)/%.c
$(Q)$(call do_compile)
 
-PEVENT_LIB_OBJS = event-parse.o trace-seq.o parse-filter.o parse-utils.o
+PEVENT_LIB_OBJS  = event-parse.o
+PEVENT_LIB_OBJS += event-plugin.o
+PEVENT_LIB_OBJS += trace-seq.o
+PEVENT_LIB_OBJS += parse-filter.o
+PEVENT_LIB_OBJS += parse-utils.o
 PEVENT_LIB_OBJS += kbuffer-parse.o
 
 ALL_OBJS = $(PEVENT_LIB_OBJS)
diff --git a/tools/lib/traceevent/event-parse.h 
b/tools/lib/traceevent/event-parse.h
index 8d73d25..a288860 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -377,6 +377,11 @@ enum pevent_errno {
 };
 #undef _PE
 
+struct plugin_list;
+
+struct plugin_list *traceevent_load_plugins(struct pevent *pevent);
+void traceevent_unload_plugins(struct plugin_list *plugin_list);
+
 struct cmdline;
 struct cmdline_list;
 struct func_map;
diff --git a/tools/lib/traceevent/event-plugin.c 
b/tools/lib/traceevent/event-plugin.c
new file mode 100644
index 000..d272d87
--- /dev/null
+++ b/tools/lib/traceevent/event-plugin.c
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt srost...@redhat.com
+ *
+ * ~~
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License (not later!)
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not,  see http://www.gnu.org/licenses
+ *
+ * ~~
+ */
+
+#include string.h
+#include dlfcn.h
+#include stdlib.h
+#include sys/types.h
+#include sys/stat.h
+#include unistd.h
+#include dirent.h
+#include event-parse.h
+#include event-utils.h
+
+#define LOCAL_PLUGIN_DIR .traceevent/plugins
+
+struct plugin_list {
+   struct plugin_list  *next;
+   char*name;
+   void*handle;
+};
+
+static void
+load_plugin(struct

[PATCH 06/28] tools lib traceevent: Harmonize the install messages in lib-traceevent

2013-12-03 Thread Jiri Olsa
Removing the 'to ...' part out of the install message,
because it does not fit to the rest of the build
messages we use.

Before:
  INSTALL  plugin_hrtimer.soto  
/home/jolsa/libexec/perf-core/traceevent/plugins
  INSTALL  plugin_jbd2.so   to  
/home/jolsa/libexec/perf-core/traceevent/plugins
  INSTALL  plugin_kmem.so   to  
/home/jolsa/libexec/perf-core/traceevent/plugins
  INSTALL  plugin_kvm.soto  
/home/jolsa/libexec/perf-core/traceevent/plugins
  INSTALL  plugin_mac80211.so   to  
/home/jolsa/libexec/perf-core/traceevent/plugins
  INSTALL  plugin_sched_switch.so   to  
/home/jolsa/libexec/perf-core/traceevent/plugins
  INSTALL  plugin_function.so   to  
/home/jolsa/libexec/perf-core/traceevent/plugins
  INSTALL  plugin_xen.soto  
/home/jolsa/libexec/perf-core/traceevent/plugins
  INSTALL  plugin_scsi.so   to  
/home/jolsa/libexec/perf-core/traceevent/plugins

Now:
  INSTALL  plugin_jbd2.so
  INSTALL  plugin_hrtimer.so
  INSTALL  plugin_kmem.so
  INSTALL  plugin_kvm.so
  INSTALL  plugin_mac80211.so
  INSTALL  plugin_sched_switch.so
  INSTALL  plugin_function.so
  INSTALL  plugin_xen.so
  INSTALL  plugin_scsi.so

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/lib/traceevent/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index 1526798..f946851 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -166,7 +166,7 @@ else
   print_plugin_obj_compile =   echo '  CC FPIC  '$(OBJ);
   print_plugin_build = echo '  BUILDPLUGIN '$(OBJ);
   print_static_lib_build = echo '  BUILDSTATIC LIB '$(OBJ);
-  print_install =  echo '  INSTALL  '$1'   to  
$(DESTDIR_SQ)$2';
+  print_install =  echo '  INSTALL  '$1;
 endif
 
 do_fpic_compile =  \
-- 
1.8.3.1

--
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 07/28] perf tools: Add build and install plugins targets

2013-12-03 Thread Jiri Olsa
Adding 'plugins' target along with the libtraceevent.a,
so plugins are built together with traceevent library.

Adding 'install-traceevent-plugins' Makefile install target,
instructing perf to install plugins into:
  $(HOME)/.traceevent/plugins
- if installed localy under $HOME
  $(DESTDIR)/$(prefix)/$(libdir)/traceevent/plugins
- if installed globally

Examples:
  $ make install
  ...
  $ find ~/.traceevent/plugins/
  /home/jolsa/.traceevent/plugins/
  /home/jolsa/.traceevent/plugins/plugin_mac80211.so
  /home/jolsa/.traceevent/plugins/plugin_kvm.so
  /home/jolsa/.traceevent/plugins/plugin_scsi.so
  /home/jolsa/.traceevent/plugins/plugin_sched_switch.so
  /home/jolsa/.traceevent/plugins/plugin_xen.so
  /home/jolsa/.traceevent/plugins/plugin_cfg80211.so
  /home/jolsa/.traceevent/plugins/plugin_function.so
  /home/jolsa/.traceevent/plugins/plugin_kmem.so
  /home/jolsa/.traceevent/plugins/plugin_hrtimer.so
  /home/jolsa/.traceevent/plugins/plugin_jbd2.so

  $ sudo make install DESTDIR=/opt/perf/
  ...
  $ find /opt/perf/lib64/traceevent/plugins/
  /opt/perf/lib64/traceevent/plugins/
  /opt/perf/lib64/traceevent/plugins/plugin_kvm.so
  /opt/perf/lib64/traceevent/plugins/plugin_scsi.so
  /opt/perf/lib64/traceevent/plugins/plugin_mac80211.so
  /opt/perf/lib64/traceevent/plugins/plugin_hrtimer.so
  /opt/perf/lib64/traceevent/plugins/plugin_kmem.so
  /opt/perf/lib64/traceevent/plugins/plugin_jbd2.so
  /opt/perf/lib64/traceevent/plugins/plugin_sched_switch.so
  /opt/perf/lib64/traceevent/plugins/plugin_function.so
  /opt/perf/lib64/traceevent/plugins/plugin_cfg80211.so
  /opt/perf/lib64/traceevent/plugins/plugin_xen.so

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/perf/Makefile.perf   | 17 -
 tools/perf/config/Makefile |  8 
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index e416ccc..abc7ac3 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -105,7 +105,7 @@ ifeq ($(config),1)
 include config/Makefile
 endif
 
-export prefix bindir sharedir sysconfdir
+export prefix bindir sharedir sysconfdir DESTDIR
 
 # sparse is architecture-neutral, which means that we need to tell it
 # explicitly what architecture to check for. Fix this up for yours..
@@ -710,13 +710,20 @@ $(LIB_FILE): $(LIB_OBJS)
 # libtraceevent.a
 TE_SOURCES = $(wildcard $(TRACE_EVENT_DIR)*.[ch])
 
-$(LIBTRACEEVENT): $(TE_SOURCES)
-   $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) 
CFLAGS=-g -Wall $(EXTRA_CFLAGS) libtraceevent.a
+LIBTRACEEVENT_FLAGS  = $(QUIET_SUBDIR1) O=$(OUTPUT)
+LIBTRACEEVENT_FLAGS += CFLAGS=-g -Wall $(EXTRA_CFLAGS)
+LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ)
+
+$(LIBTRACEEVENT): $(TE_SOURCES) $(OUTPUT)PERF-CFLAGS
+   $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) 
libtraceevent.a plugins
 
 $(LIBTRACEEVENT)-clean:
$(call QUIET_CLEAN, libtraceevent)
@$(MAKE) -C $(TRACE_EVENT_DIR) O=$(OUTPUT) clean /dev/null
 
+install-traceevent-plugins:
+   $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) 
install_plugins
+
 LIBLK_SOURCES = $(wildcard $(LK_PATH)*.[ch])
 
 # if subdir is set, we've been called from above so target has been built
@@ -785,7 +792,7 @@ cscope:
 
 ### Detect prefix changes
 TRACK_CFLAGS = $(subst ','\'',$(CFLAGS)):\
- $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
+ 
$(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):$(plugindir_SQ)
 
 $(OUTPUT)PERF-CFLAGS: .FORCE-PERF-CFLAGS
@FLAGS='$(TRACK_CFLAGS)'; \
@@ -849,7 +856,7 @@ endif
$(INSTALL) -d -m 755 
'$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
$(INSTALL) tests/attr/* 
'$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'
 
-install: install-bin try-install-man
+install: install-bin try-install-man install-traceevent-plugins
 
 install-python_ext:
$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 0761d57..bae1072 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -593,3 +593,11 @@ else
 perfexec_instdir = $(prefix)/$(perfexecdir)
 endif
 perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
+
+# If we install to $(HOME) we keep the traceevent default:
+# $(HOME)/.traceevent/plugins
+# Otherwise we install plugins into the global $(libdir).
+ifdef DESTDIR
+plugindir=$(libdir)/traceevent/plugins
+plugindir_SQ= $(subst ','\'',$(prefix)/$(plugindir))
+endif
-- 
1.8.3.1

--
To unsubscribe from this list

Re: [PATCH 22/28] tools lib traceevent: Remove malloc_or_die from event-plugin.c

2013-12-04 Thread Jiri Olsa
On Tue, Dec 03, 2013 at 11:16:01AM -0500, Steven Rostedt wrote:
 On Tue,  3 Dec 2013 14:09:36 +0100
 Jiri Olsa jo...@redhat.com wrote:
 
  Removing malloc_or_die calls from event-plugin.c,
  replacing them with standard malloc and error path.
  
  Suggested-by: Namhyung Kim namhy...@kernel.org
  Signed-off-by: Jiri Olsa jo...@redhat.com
  Cc: Corey Ashford cjash...@linux.vnet.ibm.com
  Cc: Frederic Weisbecker fweis...@gmail.com
  Cc: Ingo Molnar mi...@elte.hu
  Cc: Namhyung Kim namhy...@kernel.org
  Cc: Paul Mackerras pau...@samba.org
  Cc: Peter Zijlstra a.p.zijls...@chello.nl
  Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
  Cc: Steven Rostedt rost...@goodmis.org
  Cc: David Ahern dsah...@gmail.com
  ---
   tools/lib/traceevent/event-plugin.c | 19 ---
   1 file changed, 16 insertions(+), 3 deletions(-)
  
  diff --git a/tools/lib/traceevent/event-plugin.c 
  b/tools/lib/traceevent/event-plugin.c
  index d272d87..125f567 100644
  --- a/tools/lib/traceevent/event-plugin.c
  +++ b/tools/lib/traceevent/event-plugin.c
  @@ -47,7 +47,11 @@ load_plugin(struct pevent *pevent, const char *path,
  char *plugin;
  void *handle;
   
  -   plugin = malloc_or_die(strlen(path) + strlen(file) + 2);
  +   plugin = malloc(strlen(path) + strlen(file) + 2);
  +   if (!plugin) {
  +   warning(could not allocate plugin memory\n);
  +   return;
 
 This should be changed to return an error code. Yes it will require
 other places to change for that update as well.

Any chance this could be a separated feature? ;-)

AFACIS there's no technical problem with the current code.
If the load_plugin fails (due to ENOMEM or interface error)
it's not added on the plugin_list, which is the output/handle
of plugin interface (and there's warning ;-)).

I think we need some complex/unified error handling for the
whole library and add that globally.

jirka
--
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 28/28] perf tools: Add udis86 disassembler feature check

2013-12-04 Thread Jiri Olsa
On Wed, Dec 04, 2013 at 03:53:02PM -0300, Arnaldo Carvalho de Melo wrote:

SNIP

 Auto-detecting system features:
 ... backtrace: [ on  ]
 ... dwarf: [ on  ]
 ...fortify-source: [ on  ]
 ... glibc: [ on  ]
 ...  gtk2: [ on  ]
 ...  gtk2-infobar: [ on  ]
 ...  libaudit: [ on  ]
 ...libbfd: [ on  ]
 ...libelf: [ on  ]
 ... libelf-getphdrnum: [ on  ]
 ...   libelf-mmap: [ on  ]
 ...   libnuma: [ on  ]
 ...   libperl: [ on  ]
 ... libpython: [ on  ]
 ... libpython-version: [ on  ]
 ...  libslang: [ on  ]
 ... libunwind: [ on  ]
 ...   on-exit: [ on  ]
 ...stackprotector-all: [ on  ]
 ...   timerfd: [ on  ]
 
 config/Makefile:421: No udis86 support.
 
 ---
 
 Please try to fix it and resubmit. And yes, I don't have udis86-devel
 installed in this test system.

hum, I did not make it as the feature check with visible state '[ on ]',
but I guess check for packages should be on the list.. I'll repost

jirka
--
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 28/28] perf tools: Add udis86 disassembler feature check

2013-12-05 Thread Jiri Olsa
On Wed, Dec 04, 2013 at 03:50:24PM -0300, Arnaldo Carvalho de Melo wrote:
 Em Tue, Dec 03, 2013 at 02:09:42PM +0100, Jiri Olsa escreveu:
  Adding udis86 disassembler feature check which support
  is needed for kvm:kvm_emulate_insn tracepoint.
   
  +$(call feature_check,udis86)
  +ifeq ($(feature-udis86), 1)
  +  LIBTRACEEVENT_CFLAGS += -DHAVE_UDIS86
  +  EXTLIBS += -ludis86
  +else
  +  msg := $(warning No udis86 support.);
  +endif
 
 That is really an incomplete message, what package should I install?
 Perhaps we should add this there then:
 
 http://bit.ly/1hyrN52

nice :-)

 
 Wow, that was easy, but yeah, could be made easier 8-) ;-P

so something like:
No udis86 found. Please install udis86-devel.

or:
No udis86 found, disabling kvm tracepoints instruction disassembly. Please 
install udis86-devel.

jirka
--
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/


[PATCHv4 28/28] perf tools: Add udis86 disassembler feature check

2013-12-05 Thread Jiri Olsa
On Thu, Dec 05, 2013 at 09:05:13AM +0100, Jiri Olsa wrote:
 On Wed, Dec 04, 2013 at 03:50:24PM -0300, Arnaldo Carvalho de Melo wrote:
  Em Tue, Dec 03, 2013 at 02:09:42PM +0100, Jiri Olsa escreveu:
   Adding udis86 disassembler feature check which support
   is needed for kvm:kvm_emulate_insn tracepoint.

   +$(call feature_check,udis86)
   +ifeq ($(feature-udis86), 1)
   +  LIBTRACEEVENT_CFLAGS += -DHAVE_UDIS86
   +  EXTLIBS += -ludis86
   +else
   +  msg := $(warning No udis86 support.);
   +endif
  
  That is really an incomplete message, what package should I install?
  Perhaps we should add this there then:
  
  http://bit.ly/1hyrN52
 
 nice :-)
 
  
  Wow, that was easy, but yeah, could be made easier 8-) ;-P
 
 so something like:
 No udis86 found. Please install udis86-devel.
 
 or:
 No udis86 found, disabling kvm tracepoints instruction disassembly. Please 
 install udis86-devel.

took the first one, v4 attached, perf/core_plugins is updated

thanks,
jirka


---
Adding udis86 disassembler feature check which support
is needed for kvm:kvm_emulate_insn tracepoint.

The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e kvm:kvm_emulate_insn -a')

  --- script.kvm.old
  +++ script.kvm.new
  - qemu-system-x86 15519 [003]  5332.470049: kvm:kvm_emulate_insn: 
0:8103c596:89 b7 00 80 5f ff (prot64)
  + qemu-system-x86 15519 [003]  5332.470049: kvm:kvm_emulate_insn: 
0:8103c596: mov %esi, -0xa08000(%rdi)

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Steven Rostedt rost...@goodmis.org
Cc: David Ahern dsah...@gmail.com
---
 tools/perf/Makefile.perf   |  4 ++--
 tools/perf/config/Makefile | 11 ++-
 tools/perf/config/feature-checks/Makefile  |  8 ++--
 tools/perf/config/feature-checks/test-all.c|  5 +
 tools/perf/config/feature-checks/test-udis86.c | 11 +++
 5 files changed, 34 insertions(+), 5 deletions(-)
 create mode 100644 tools/perf/config/feature-checks/test-udis86.c

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index ca3b87d..5c4c8bd 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -712,7 +712,7 @@ $(LIB_FILE): $(LIB_OBJS)
 TE_SOURCES = $(wildcard $(TRACE_EVENT_DIR)*.[ch])
 
 LIBTRACEEVENT_FLAGS  = $(QUIET_SUBDIR1) O=$(OUTPUT)
-LIBTRACEEVENT_FLAGS += CFLAGS=-g -Wall $(EXTRA_CFLAGS)
+LIBTRACEEVENT_FLAGS += CFLAGS=-g -Wall $(EXTRA_CFLAGS) 
$(LIBTRACEEVENT_CFLAGS)
 LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ)
 
 $(LIBTRACEEVENT): $(TE_SOURCES) $(OUTPUT)PERF-CFLAGS
@@ -793,7 +793,7 @@ cscope:
 
 ### Detect prefix changes
 TRACK_CFLAGS = $(subst ','\'',$(CFLAGS)):\
- 
$(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):$(plugindir_SQ)
+ 
$(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):$(plugindir_SQ):$(LIBTRACEEVENT_CFLAGS)
 
 $(OUTPUT)PERF-CFLAGS: .FORCE-PERF-CFLAGS
@FLAGS='$(TRACK_CFLAGS)'; \
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index bae1072..ddae5c4 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -142,7 +142,8 @@ CORE_FEATURE_TESTS =\
libunwind   \
on-exit \
stackprotector-all  \
-   timerfd
+   timerfd \
+   udis86
 
 #
 # So here we detect whether test-all was rebuilt, to be able
@@ -413,6 +414,14 @@ else
   msg := $(warning No timerfd support. Disables 'perf kvm stat live');
 endif
 
+$(call feature_check,udis86)
+ifeq ($(feature-udis86), 1)
+  LIBTRACEEVENT_CFLAGS += -DHAVE_UDIS86
+  EXTLIBS += -ludis86
+else
+  msg := $(warning No udis86 found. Please install udis86-devel.)
+endif
+
 disable-python = $(eval $(disable-python_code))
 define disable-python_code
   CFLAGS += -DNO_LIBPYTHON
diff --git a/tools/perf/config/feature-checks/Makefile 
b/tools/perf/config/feature-checks/Makefile
index b8bb749..3ed2667 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -26,7 +26,8 @@ FILES=\
test-libunwind-debug-frame  \
test-on-exit\
test-stackprotector-all \
-   test-timerfd
+   test-timerfd\
+   test-udis86
 
 CC := $(CC) -MD
 
@@ -37,7 +38,7 @@ BUILD = $(CC) $(CFLAGS) $(LDFLAGS) -o $(OUTPUT)$@ $@.c
 ###
 
 test-all:
-   $(BUILD) -Werror -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 
-ldw -lelf -lnuma $(LIBUNWIND_LIBS) -lelf -laudit -I/usr/include/slang -lslang 
$(shell

Re: [RFC 0/6] perf tools: Add perf_evlist errno

2013-12-05 Thread Jiri Olsa
On Mon, Dec 02, 2013 at 05:19:18PM +0900, Namhyung Kim wrote:
 Hi Jiri,
 
 On Fri, 29 Nov 2013 12:45:04 +0100, Jiri Olsa wrote:
  hi,
  Andi reported wrong error message for :S modifier
  on kernel without event ID ioctl support.
 
  The reason was that the ioctl failed, but the error was
  printed like the mmap would:
 
  $ perf.old record -e '{cycles,cache-misses}:S' ls
  failed to mmap with 25 (Inappropriate ioctl for device)
  ls: Terminated
 
 I see same confusing error message..
 
 
  I experimentally added sort of 'libc errno' interface for
  perf_evlist to be able to get proper error message, like:
 
  $ perf record -e '{cycles,cache-misses}:S' ls
  Cannot read event group on this kernel.
  Please consider kernel update (v3.12+).
  ls: Terminated
 
  I'm not sure about this approach. Maybe it'd be better be more
  global..? So before throwing this out, sending it as RFC ;-)
 
 I like it. :)  We still need to improve this user-visible error handling.
 
 But what you mean by 'more global'?  I think the evlist APIs are pretty
 global alreay.  And we have same error handling in perf_target code too.

aah, missed the target object has that already.. I meant
to keep the same way of error handling globaly

 
 But I think it'd be better making it thread-safe even though it's not
 needed for now.  The code is growing really fast.. ;-)

ok, will repost 

thanks,
jirka
--
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 28/28] perf tools: Add udis86 disassembler feature check

2013-12-05 Thread Jiri Olsa
On Thu, Dec 05, 2013 at 10:25:02AM +0100, Ingo Molnar wrote:
 
 * Jiri Olsa jo...@redhat.com wrote:
 
  On Wed, Dec 04, 2013 at 03:50:24PM -0300, Arnaldo Carvalho de Melo wrote:
   Em Tue, Dec 03, 2013 at 02:09:42PM +0100, Jiri Olsa escreveu:
Adding udis86 disassembler feature check which support
is needed for kvm:kvm_emulate_insn tracepoint.
 
+$(call feature_check,udis86)
+ifeq ($(feature-udis86), 1)
+  LIBTRACEEVENT_CFLAGS += -DHAVE_UDIS86
+  EXTLIBS += -ludis86
+else
+  msg := $(warning No udis86 support.);
+endif
   
   That is really an incomplete message, what package should I install?
   Perhaps we should add this there then:
   
   http://bit.ly/1hyrN52
  
  nice :-)
  
   
   Wow, that was easy, but yeah, could be made easier 8-) ;-P
  
  so something like:
  No udis86 found. Please install udis86-devel.
  
  or:
  No udis86 found, disabling kvm tracepoints instruction disassembly. Please 
  install udis86-devel.
 
 1)
 
 So, the first problem I can see is in the output:
 
 Auto-detecting system features:
 ... backtrace: [ on  ]
 ... dwarf: [ on  ]
 ...fortify-source: [ on  ]
 ... glibc: [ on  ]
 ...  gtk2: [ on  ]
 ...  gtk2-infobar: [ on  ]
 ...  libaudit: [ on  ]
 ...libbfd: [ on  ]
 ...libelf: [ on  ]
 ... libelf-getphdrnum: [ on  ]
 ...   libelf-mmap: [ on  ]
 ...   libnuma: [ on  ]
 ...   libperl: [ on  ]
 ... libpython: [ on  ]
 ... libpython-version: [ on  ]
 ...  libslang: [ on  ]
 ... libunwind: [ on  ]
 ...   on-exit: [ on  ]
 ...stackprotector-all: [ on  ]
 ...   timerfd: [ on  ]
 
 config/Makefile:421: No udis86 support.
 
 such a 'no XYZ support' message should only occur if a feature test 
 failed. _If_ we decide that 'udis86' support is required for a full 
 perf build then there should be a new line saying something like:
 
 ...udis86: [ OFF ]

hum, just sent v4 that added udis86 into above list ;-)

So.. do we consider 'full perf build' to be build with all
possible libraries linked in?

then we need to cleanup above list and remove:
  on-exit
  timerfd
  libelf-getphdrnum
  libelf-mmap
  stackprotector-all
  fortify-source
  backtrace

or maybe have verbose list where we display everything (for V=1 ?)
and by default display only library checks

 
 2)
 
 The other problem I see is that I think we should start adding the 
 install-suggestions to the feature-check lines themselves.
 
 On .deb based systems it should say something like:
 
 ...   on-exit: [ on  ]
 ...stackprotector-all: [ on  ]
 ...   timerfd: [ on  ]
 ...udis86: [ OFF ]# apt-get install udis86-dev
 
 On RPM based systems it should say something like:
 
 ...   on-exit: [ on  ]
 ...stackprotector-all: [ on  ]
 ...   timerfd: [ on  ]
 ...udis86: [ OFF ]# yum install udis86-devel
 
 Or so. I think we can maintain package suggestion strings for these 
 two main distro variants.
 
 The package install strings should probably be maintained together 
 with the list of feature names in some table/list format. Such lookup 
 tables can be implemented either in Make via:
 
   
 http://www.gnu.org/savannah-checkouts/gnu/make/manual/html_node/Computed-Names.html
 
 Or via a shell command in the makefile, using Bash associative arrays 
 or such.

sounds good

jirka
--
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: [GIT PULL 00/38] perf/core improvements and fixes

2013-12-05 Thread Jiri Olsa
On Thu, Dec 05, 2013 at 11:04:29AM +0100, Ingo Molnar wrote:
 
 * Arnaldo Carvalho de Melo a...@infradead.org wrote:
 
  From: Arnaldo Carvalho de Melo a...@ghostprotocols.net
  
  Hi Ingo,
  
  Please consider pulling,
  
  - Arnaldo
  
  The following changes since commit 89e3bbd58a6186b832fe2b9419ac2f9ab90e9089:
  
Merge tag 'perf-core-for-mingo' of 
  git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core 
  (2013-12-04 10:17:17 +0100)
  
  are available in the git repository at:
  
  
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux 
  tags/perf-core-for-mingo
 
 Hm, I saw such a build failure:
 
   CC FPIC  plugin_kmem.o
   BUILDPLUGIN plugin_jbd2.so
 plugin_jbd2.o: file not recognized: File truncated
 collect2: error: ld returned 1 exit status
 make[2]: *** [plugin_jbd2.so] Error 1
 make[1]: *** [install-traceevent-plugins] Error 2
 make[1]: *** Waiting for unfinished jobs
   CC FPIC  plugin_kvm.o
   CC FPIC  plugin_mac80211.o
 
 which suggests some sort of build race ...
 
 I was doing several 'make clean; make install' runs - and the second 
 run failed. Unfortunately the failure was not reproducible after that 
 point - and I tried dozens of times. The test system has 12 CPUs.
 
 The following loop attempts to build until a failure occurs:
 
   cd tools/perf/
   while make install; do make clean; done
 
 Any ideas?

never saw that one.. starting your test on 24 CPUs server now

jirka
--
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: [GIT PULL 00/38] perf/core improvements and fixes

2013-12-05 Thread Jiri Olsa
On Thu, Dec 05, 2013 at 11:53:44AM +0100, Ingo Molnar wrote:

SNIP

 
 I saw it again on a system by running two parallel build jobs:
 
   D=/tmp/perf-1; mkdir -p $D; while make O=$D install; do make O=$D clean; 
 done
   D=/tmp/perf-2; mkdir -p $D; while make O=$D install; do make O=$D clean; 
 done
 
 one failed with:
 
   BUILDPLUGIN plugin_kmem.so
 make[2]: *** [sub-make] Error 2
 make[1]: *** [/tmp/perf-1/libtraceevent.a] Error 2
 make[1]: *** Waiting for unfinished jobs
   BUILDPLUGIN plugin_kvm.so
 
 the other with:
 
   CC FPIC  plugin_cfg80211.o
   CC   /tmp/perf-2/builtin-help.o
   CC   /tmp/perf-2/builtin-sched.o
 plugin_sched_switch.o: file not recognized: File truncated
 collect2: error: ld returned 1 exit status
 make[3]: *** [plugin_sched_switch.so] Error 1  BUILDPLUGIN 
 plugin_function.so
 
 
 and that's clearly the new plugin code.

yes, I reproduced... looks like 'plugins' target is racing
with 'install_plugins' target.. both ending up building
same objects at the same time

working on fix

thanks,
jirka
--
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: [GIT PULL 00/38] perf/core improvements and fixes

2013-12-05 Thread Jiri Olsa
On Thu, Dec 05, 2013 at 11:59:14AM +0100, Ingo Molnar wrote:
 
 * Ingo Molnar mi...@kernel.org wrote:
 
   never saw that one.. starting your test on 24 CPUs server now
  
  I saw it again on a system by running two parallel build jobs:
  
D=/tmp/perf-1; mkdir -p $D; while make O=$D install; do make O=$D clean; 
  done
D=/tmp/perf-2; mkdir -p $D; while make O=$D install; do make O=$D clean; 
  done
 
 I'm running it now with the previous perf/core - no failures so far, 
 after dozens of build passes.
 

could you please try attached change? working for me so far..

thanks,
jirka


---
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index ca3b87d..9a8cf37 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -722,7 +722,7 @@ $(LIBTRACEEVENT)-clean:
$(call QUIET_CLEAN, libtraceevent)
@$(MAKE) -C $(TRACE_EVENT_DIR) O=$(OUTPUT) clean /dev/null
 
-install-traceevent-plugins:
+install-traceevent-plugins: $(LIBTRACEEVENT)
$(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) 
install_plugins
 
 LIBLK_SOURCES = $(wildcard $(LK_PATH)*.[ch])
--
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: [GIT PULL 00/38] perf/core improvements and fixes

2013-12-05 Thread Jiri Olsa
On Thu, Dec 05, 2013 at 01:27:51PM +0100, Ingo Molnar wrote:
 
 * Jiri Olsa jo...@redhat.com wrote:
 
  On Thu, Dec 05, 2013 at 11:59:14AM +0100, Ingo Molnar wrote:
   
   * Ingo Molnar mi...@kernel.org wrote:
   
 never saw that one.. starting your test on 24 CPUs server now

I saw it again on a system by running two parallel build jobs:

  D=/tmp/perf-1; mkdir -p $D; while make O=$D install; do make O=$D 
clean; done
  D=/tmp/perf-2; mkdir -p $D; while make O=$D install; do make O=$D 
clean; done
   
   I'm running it now with the previous perf/core - no failures so far, 
   after dozens of build passes.
   
  
  could you please try attached change? working for me so far..
  
  thanks,
  jirka
  
  
  ---
  diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
  index ca3b87d..9a8cf37 100644
  --- a/tools/perf/Makefile.perf
  +++ b/tools/perf/Makefile.perf
  @@ -722,7 +722,7 @@ $(LIBTRACEEVENT)-clean:
  $(call QUIET_CLEAN, libtraceevent)
  @$(MAKE) -C $(TRACE_EVENT_DIR) O=$(OUTPUT) clean /dev/null
   
  -install-traceevent-plugins:
  +install-traceevent-plugins: $(LIBTRACEEVENT)
  $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) 
  install_plugins
   
   LIBLK_SOURCES = $(wildcard $(LK_PATH)*.[ch])
 
 It's looking good so far.
 
 I've made a commit out of it and added your SOB, is that fine with 
 you?

definitely, my test is still running ok as well

thanks a lot,
jirka
--
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 28/28] perf tools: Add udis86 disassembler feature check

2013-12-05 Thread Jiri Olsa
On Thu, Dec 05, 2013 at 11:45:46AM +0100, Ingo Molnar wrote:

SNIP

   
   1)
   
   So, the first problem I can see is in the output:
   
   Auto-detecting system features:
   ... backtrace: [ on  ]
   ... dwarf: [ on  ]
   ...fortify-source: [ on  ]
   ... glibc: [ on  ]
   ...  gtk2: [ on  ]
   ...  gtk2-infobar: [ on  ]
   ...  libaudit: [ on  ]
   ...libbfd: [ on  ]
   ...libelf: [ on  ]
   ... libelf-getphdrnum: [ on  ]
   ...   libelf-mmap: [ on  ]
   ...   libnuma: [ on  ]
   ...   libperl: [ on  ]
   ... libpython: [ on  ]
   ... libpython-version: [ on  ]
   ...  libslang: [ on  ]
   ... libunwind: [ on  ]
   ...   on-exit: [ on  ]
   ...stackprotector-all: [ on  ]
   ...   timerfd: [ on  ]
   
   config/Makefile:421: No udis86 support.
   
   such a 'no XYZ support' message should only occur if a feature test 
   failed. _If_ we decide that 'udis86' support is required for a full 
   perf build then there should be a new line saying something like:
   
   ...udis86: [ OFF ]
  
  hum, just sent v4 that added udis86 into above list ;-)
  
  So.. do we consider 'full perf build' to be build with all
  possible libraries linked in?
 
 So my worry is, how widely is libudis86 available in distros? What is 
 the package name on Debian/Ubuntu for example?

I did not find any.. :-\ I can see Fedora and Gentoo

thanks,
jirka
--
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 kvm: introduce --list-cmds for use by scripts

2014-03-14 Thread Jiri Olsa
On Thu, Mar 13, 2014 at 11:52:12AM -0400, Ramkumar Ramachandra wrote:
 Ramkumar Ramachandra wrote:
  Jiri Olsa wrote:
  On Mon, Mar 03, 2014 at 08:26:36PM -0500, Ramkumar Ramachandra wrote:
  Introduce
 
$ perf kvm --list-cmds
 
  to dump a raw list of commands for use by the completion script. In
  order to do this, introduce parse_options_subcommand() for handling
  subcommands as a special case in the parse-options machinery.
 
 Jiri? How do we proceed with this?

I think Arnaldo will process it eventually ;-)
I dont have any objections..

jirka
--
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: Speed up thread map generation

2014-03-14 Thread Jiri Olsa
On Thu, Mar 13, 2014 at 05:16:37PM -0400, Don Zickus wrote:

SNIP

 + event-fork.ptid = tgid;
 + event-fork.pid  = tgid;
 + event-fork.tid  = pid;
 + event-fork.header.type = PERF_RECORD_FORK;
 +
 + event-fork.header.size = (sizeof(event-fork) + machine-id_hdr_size);
 +
 + if (process(tool, event, synth_sample, machine) != 0)
 + return -1;
 +
 + return 0;
 +}
 +
  int perf_event__synthesize_mmap_events(struct perf_tool *tool,
  union perf_event *event,
  pid_t pid, pid_t tgid,
 @@ -287,6 +309,11 @@ static int __event__synthesize_thread(union perf_event 
 *comm_event,
   DIR *tasks;
   struct dirent dirent, *next;
   pid_t tgid;
 + union perf_event *fork_event;
 +
 + fork_event = malloc(sizeof(fork_event-fork) + machine-id_hdr_size);
 + if (fork_event == NULL)
 + return -1;

need to be freed

maybe we could move the allocation one level up,
same as for mmap_event and comm_event

otherwise I think the logic with FORK event is correct

jirka
--
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 4/5] perf tools: Add machine pointer into thread struct

2014-03-14 Thread Jiri Olsa
Need machine pointer in thread object, so we could
lookup the process thread in following patch.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Don Zickus dzic...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
---
 tools/perf/util/machine.c | 2 +-
 tools/perf/util/thread.c  | 4 +++-
 tools/perf/util/thread.h  | 5 -
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 009dfb4..6196bb9 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -311,7 +311,7 @@ static struct thread *__machine__findnew_thread(struct 
machine *machine,
if (!create)
return NULL;
 
-   th = thread__new(pid, tid);
+   th = thread__new(pid, tid, machine);
if (th != NULL) {
rb_link_node(th-rb_node, parent, p);
rb_insert_color(th-rb_node, machine-threads);
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index ac77b6c..7c1aad0 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -8,13 +8,15 @@
 #include debug.h
 #include comm.h
 
-struct thread *thread__new(pid_t pid, pid_t tid)
+struct thread *thread__new(pid_t pid, pid_t tid,
+  struct machine *machine)
 {
char *comm_str;
struct comm *comm;
struct thread *thread = zalloc(sizeof(*thread));
 
if (thread != NULL) {
+   thread-machine = machine;
thread-pid_ = pid;
thread-tid = tid;
thread-ppid = -1;
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index 77d0be2..2200557 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -7,12 +7,14 @@
 #include sys/types.h
 #include symbol.h
 #include strlist.h
+#include machine.h
 
 struct thread {
union {
struct rb_node   rb_node;
struct list_head node;
};
+   struct machine  *machine;
struct map_groups   *mg;
pid_t   pid_; /* Not all tools update this */
pid_t   tid;
@@ -29,7 +31,8 @@ struct thread {
 struct machine;
 struct comm;
 
-struct thread *thread__new(pid_t pid, pid_t tid);
+struct thread *thread__new(pid_t pid, pid_t tid,
+  struct machine *machine);
 void thread__delete(struct thread *thread);
 static inline void thread__exited(struct thread *thread)
 {
-- 
1.8.3.1

--
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 5/5] perf tools: Share process map groups within process threads

2014-03-14 Thread Jiri Olsa
Sharing map groups within all process threads. This way
there's only one copy of mmap info and it's reachale
from any thread within the process.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Don Zickus dzic...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
---
 tools/perf/util/map.h|  2 ++
 tools/perf/util/thread.c | 37 ++---
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 99a6488..d4c8df2 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -59,6 +59,8 @@ struct map_groups {
struct rb_root   maps[MAP__NR_TYPES];
struct list_head removed_maps[MAP__NR_TYPES];
struct machine   *machine;
+   /* Used for thread sharing */
+   int   refcnt;
 };
 
 static inline struct kmap *map__kmap(struct map *map)
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 7c1aad0..2599754 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -156,6 +156,16 @@ int thread__fork(struct thread *thread, struct thread 
*parent, u64 timestamp)
return 0;
 }
 
+static struct thread* thread__get_leader(struct thread *thread)
+{
+   pid_t pid = thread-pid_;
+
+   if (pid == thread-tid)
+   return thread;
+
+   return machine__findnew_thread(thread-machine, pid, pid);
+}
+
 static struct map_groups* thread__map_groups_alloc(struct thread *thread)
 {
struct map_groups* mg = zalloc(sizeof(*mg));
@@ -172,13 +182,34 @@ struct map_groups* thread__map_groups_get(struct thread 
*thread)
 {
struct map_groups* mg = thread-mg;
 
-   if (!mg)
-   mg = thread__map_groups_alloc(thread);
+   if (!mg) {
+   struct thread *leader = thread__get_leader(thread);
+
+   if (!leader)
+   return NULL;
+
+   if (leader-mg)
+   mg = leader-mg;
+   else
+   mg = thread__map_groups_alloc(leader);
+
+   if (leader != thread)
+   thread-mg = mg;
+
+   mg-refcnt++;
+   }
 
return mg;
 }
 
 void thread__map_groups_put(struct thread *thread)
 {
-   zfree(thread-mg);
+   struct map_groups* mg = thread-mg;
+
+   if (mg) {
+   BUG_ON(!mg-refcnt);
+
+   if (!--mg-refcnt)
+   zfree(thread-mg);
+   }
 }
-- 
1.8.3.1

--
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 1/5] perf tests: Add tip/pid mmap automated tests

2014-03-14 Thread Jiri Olsa
Adding automated test for memory maps lookup within
multiple machines threads.

The test creates 4 threads and separated memory maps.

It checks that we could use thread__find_addr_map
function with thread object based on TID to find
memory maps.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Don Zickus dzic...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
---
 tools/perf/Makefile.perf|   1 +
 tools/perf/perf.h   |   6 ++
 tools/perf/tests/builtin-test.c |   4 +
 tools/perf/tests/mmap-events.c  | 188 
 tools/perf/tests/tests.h|   1 +
 5 files changed, 200 insertions(+)
 create mode 100644 tools/perf/tests/mmap-events.c

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 50d875d..9324a40 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -414,6 +414,7 @@ ifeq ($(ARCH),x86)
 LIB_OBJS += $(OUTPUT)tests/dwarf-unwind.o
 endif
 endif
+LIB_OBJS += $(OUTPUT)tests/mmap-events.o
 
 BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
 BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index e18a8b5..1138c41 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -15,6 +15,9 @@
 #ifndef __NR_futex
 # define __NR_futex 240
 #endif
+#ifndef __NR_gettid
+# define __NR_gettid 224
+#endif
 #endif
 
 #if defined(__x86_64__)
@@ -29,6 +32,9 @@
 #ifndef __NR_futex
 # define __NR_futex 202
 #endif
+#ifndef __NR_gettid
+# define __NR_gettid 186
+#endif
 #endif
 
 #ifdef __powerpc__
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index b11bf8a..d7a9b3a 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -124,6 +124,10 @@ static struct test {
 #endif
 #endif
{
+   .desc = Test mmap events,
+   .func = test__mmap_events,
+   },
+   {
.func = NULL,
},
 };
diff --git a/tools/perf/tests/mmap-events.c b/tools/perf/tests/mmap-events.c
new file mode 100644
index 000..5c7fd7e
--- /dev/null
+++ b/tools/perf/tests/mmap-events.c
@@ -0,0 +1,188 @@
+#include unistd.h
+#include sys/syscall.h
+#include sys/types.h
+#include sys/mman.h
+#include pthread.h
+#include stdlib.h
+#include stdio.h
+#include debug.h
+#include tests.h
+#include machine.h
+#include thread_map.h
+#include symbol.h
+#include thread.h
+
+#define THREADS 4
+
+static int go_away;
+
+struct thread_data {
+   pthread_t   pt;
+   pid_t   tid;
+   void*map;
+   int ready[2];
+};
+
+static struct thread_data threads[THREADS];
+
+static int thread_init(struct thread_data *td)
+{
+   void *map;
+
+   map = mmap(NULL, page_size, PROT_READ|PROT_WRITE,
+  MAP_SHARED|MAP_ANONYMOUS, -1, 0);
+   if (map == MAP_FAILED) {
+   perror(mmap failed);
+   return -1;
+   }
+
+   td-map = map;
+   td-tid = syscall(SYS_gettid);
+
+   pr_debug(tid = %d, map = %p\n, td-tid, map);
+   return 0;
+}
+
+static void* thread(void *arg)
+{
+   struct thread_data *td = arg;
+   int go;
+
+   if (thread_init(td))
+   return NULL;
+
+   write(td-ready[1], go, sizeof(int));
+
+   while (!go_away) {
+   usleep(100);
+   }
+
+   munmap(td-map, page_size);
+   return NULL;
+}
+
+static int thread_create(int i)
+{
+   struct thread_data *td = threads[i];
+   int err, go;
+
+   if (pipe(td-ready))
+   return -1;
+
+   err = pthread_create(td-pt, NULL, thread, td);
+   if (!err) {
+   ssize_t ret = read(td-ready[0], go, sizeof(int));
+   err = ret != sizeof(int);
+   }
+
+   return err;
+}
+
+static int threads_create(void)
+{
+   struct thread_data *td0 = threads[0];
+   int i, err = 0;
+
+   if (thread_init(td0))
+   return -1;
+
+   for (i = 1; !err  i  THREADS; i++)
+   err = thread_create(i);
+
+   return err;
+}
+
+static int threads_destroy(void)
+{
+   struct thread_data *td0 = threads[0];
+   int i, err = 0;
+
+   munmap(td0-map, page_size);
+
+   go_away = 1;
+
+   for (i = 1; !err  i  THREADS; i++)
+   err = pthread_join(threads[i].pt, NULL);
+
+   return err;
+}
+
+typedef int (*synth_cb)(struct machine *machine);
+
+static int synth_all(struct machine *machine)
+{
+   return perf_event__synthesize_threads(NULL,
+ perf_event__process,
+ machine, 0);
+}
+
+static int synth_process(struct machine *machine)
+{
+   struct thread_map *map

[PATCH 3/5] perf tools: Allocate thread map_groups dynamicaly

2014-03-14 Thread Jiri Olsa
Moving towards sharing map groups within a process threads.

Because of this we need the map groups to be dynamically
allocated. No other functional change is intended in here.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Don Zickus dzic...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
---
 tools/perf/arch/x86/tests/dwarf-unwind.c |  2 +-
 tools/perf/ui/stdio/hist.c   |  8 -
 tools/perf/util/event.c  |  4 +--
 tools/perf/util/machine.c|  6 ++--
 tools/perf/util/map.h|  1 -
 tools/perf/util/thread.c | 52 +++-
 tools/perf/util/thread.h | 10 --
 7 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/tools/perf/arch/x86/tests/dwarf-unwind.c 
b/tools/perf/arch/x86/tests/dwarf-unwind.c
index b602ad9..d804511 100644
--- a/tools/perf/arch/x86/tests/dwarf-unwind.c
+++ b/tools/perf/arch/x86/tests/dwarf-unwind.c
@@ -23,7 +23,7 @@ static int sample_ustack(struct perf_sample *sample,
 
sp = (unsigned long) regs[PERF_REG_X86_SP];
 
-   map = map_groups__find(thread-mg, MAP__FUNCTION, (u64) sp);
+   map = map_groups__find(thread-mg, MAP__FUNCTION, (u64) sp);
if (!map) {
pr_debug(failed to get stack map\n);
return -1;
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 9bad892..880238e 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -496,7 +496,13 @@ print_entries:
break;
 
if (h-ms.map == NULL  verbose  1) {
-   __map_groups__fprintf_maps(h-thread-mg,
+   struct map_groups *mg = 
thread__map_groups_get(h-thread);
+
+   if (!mg) {
+   ret = -ENOMEM;
+   break;
+   }
+   __map_groups__fprintf_maps(mg,
   MAP__FUNCTION, verbose, fp);
fprintf(fp, %.10s end\n, graph_dotted_line);
}
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 55eebe9..197b594 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -655,7 +655,7 @@ void thread__find_addr_map(struct thread *thread,
   enum map_type type, u64 addr,
   struct addr_location *al)
 {
-   struct map_groups *mg = thread-mg;
+   struct map_groups *mg = thread__map_groups_get(thread);
bool load_map = false;
 
al-machine = machine;
@@ -664,7 +664,7 @@ void thread__find_addr_map(struct thread *thread,
al-cpumode = cpumode;
al-filtered = false;
 
-   if (machine == NULL) {
+   if ((machine == NULL) || (mg == NULL)) {
al-map = NULL;
return;
}
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index a189faf..009dfb4 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1046,8 +1046,7 @@ int machine__process_mmap2_event(struct machine *machine,
if (map == NULL)
goto out_problem;
 
-   thread__insert_map(thread, map);
-   return 0;
+   return thread__insert_map(thread, map);
 
 out_problem:
dump_printf(problem processing PERF_RECORD_MMAP2, skipping event.\n);
@@ -1093,8 +1092,7 @@ int machine__process_mmap_event(struct machine *machine, 
union perf_event *event
if (map == NULL)
goto out_problem;
 
-   thread__insert_map(thread, map);
-   return 0;
+   return thread__insert_map(thread, map);
 
 out_problem:
dump_printf(problem processing PERF_RECORD_MMAP, skipping event.\n);
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index f00f058..99a6488 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -202,5 +202,4 @@ struct map *map_groups__find_by_name(struct map_groups *mg,
 enum map_type type, const char *name);
 
 void map_groups__flush(struct map_groups *mg);
-
 #endif /* __PERF_MAP_H */
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 0358882..ac77b6c 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -15,7 +15,6 @@ struct thread *thread__new(pid_t pid, pid_t tid)
struct thread *thread = zalloc(sizeof(*thread));
 
if (thread != NULL) {
-   map_groups__init(thread-mg);
thread-pid_ = pid;
thread-tid = tid;
thread-ppid = -1;
@@ -45,12 +44,15 @@ void thread__delete(struct thread *thread)
 {
struct comm *comm

[PATCH 2/5] perf tools: Factor machine__find_thread to take tid argument

2014-03-14 Thread Jiri Olsa
Forcing the code to always search thread by pid/tid pair.

The PID value will be needed in future to determine
the process thread leader for map groups sharing.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Don Zickus dzic...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
---
 tools/perf/tests/dwarf-unwind.c |  2 +-
 tools/perf/util/machine.c   | 13 +
 tools/perf/util/machine.h   |  3 ++-
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c
index f16ea28..c059ee8 100644
--- a/tools/perf/tests/dwarf-unwind.c
+++ b/tools/perf/tests/dwarf-unwind.c
@@ -128,7 +128,7 @@ int test__dwarf_unwind(void)
if (verbose  1)
machine__fprintf(machine, stderr);
 
-   thread = machine__find_thread(machine, getpid());
+   thread = machine__find_thread(machine, getpid(), getpid());
if (!thread) {
pr_err(Could not get thread\n);
goto out;
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index eb26544..a189faf 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -327,9 +327,10 @@ struct thread *machine__findnew_thread(struct machine 
*machine, pid_t pid,
return __machine__findnew_thread(machine, pid, tid, true);
 }
 
-struct thread *machine__find_thread(struct machine *machine, pid_t tid)
+struct thread *machine__find_thread(struct machine *machine, pid_t pid,
+   pid_t tid)
 {
-   return __machine__findnew_thread(machine, 0, tid, false);
+   return __machine__findnew_thread(machine, pid, tid, false);
 }
 
 int machine__process_comm_event(struct machine *machine, union perf_event 
*event,
@@ -1114,7 +1115,9 @@ static void machine__remove_thread(struct machine 
*machine, struct thread *th)
 int machine__process_fork_event(struct machine *machine, union perf_event 
*event,
struct perf_sample *sample)
 {
-   struct thread *thread = machine__find_thread(machine, event-fork.tid);
+   struct thread *thread = machine__find_thread(machine,
+event-fork.pid,
+event-fork.tid);
struct thread *parent = machine__findnew_thread(machine,
event-fork.ppid,
event-fork.ptid);
@@ -1140,7 +1143,9 @@ int machine__process_fork_event(struct machine *machine, 
union perf_event *event
 int machine__process_exit_event(struct machine *machine, union perf_event 
*event,
struct perf_sample *sample __maybe_unused)
 {
-   struct thread *thread = machine__find_thread(machine, event-fork.tid);
+   struct thread *thread = machine__find_thread(machine,
+event-fork.pid,
+event-fork.tid);
 
if (dump_trace)
perf_event__fprintf_task(event, stdout);
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index 2e6c248..c8c74a1 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -41,7 +41,8 @@ struct map *machine__kernel_map(struct machine *machine, enum 
map_type type)
return machine-vmlinux_maps[type];
 }
 
-struct thread *machine__find_thread(struct machine *machine, pid_t tid);
+struct thread *machine__find_thread(struct machine *machine, pid_t pid,
+   pid_t tid);
 
 int machine__process_comm_event(struct machine *machine, union perf_event 
*event,
struct perf_sample *sample);
-- 
1.8.3.1

--
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/


[RFC 0/5] perf tools: Share map groups within process

2014-03-14 Thread Jiri Olsa
hi,
this patchset moves thread's map_groups to be dynamically
allocated and shared within process threads.

The main benefit would be to be able to look up memory
map from any thread that belongs to the process.

This implementes one of the solution ideas for issue
described by Don in following thread:
http://marc.info/?l=linux-kernelm=139403876017159w=2

This patches still has some loose ends, just wanted to hear
opinions for this concept.

thanks,
jirka

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Don Zickus dzic...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
---
Jiri Olsa (5):
  perf tests: Add tip/pid mmap automated tests
  perf tools: Factor machine__find_thread to take tid argument
  perf tools: Allocate thread map_groups dynamicaly
  perf tools: Add machine pointer into thread struct
  perf tools: Share process map groups within process threads

 tools/perf/Makefile.perf |   1 +
 tools/perf/arch/x86/tests/dwarf-unwind.c |   2 +-
 tools/perf/perf.h|   6 ++
 tools/perf/tests/builtin-test.c  |   4 ++
 tools/perf/tests/dwarf-unwind.c  |   2 +-
 tools/perf/tests/mmap-events.c   | 188 
+++
 tools/perf/tests/tests.h |   1 +
 tools/perf/ui/stdio/hist.c   |   8 ++-
 tools/perf/util/event.c  |   4 +-
 tools/perf/util/machine.c|  21 ---
 tools/perf/util/machine.h|   3 +-
 tools/perf/util/map.h|   3 +-
 tools/perf/util/thread.c |  87 ++---
 tools/perf/util/thread.h |  15 +++--
 14 files changed, 317 insertions(+), 28 deletions(-)
 create mode 100644 tools/perf/tests/mmap-events.c
--
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 V2] perf: Speed up thread map generation

2014-03-14 Thread Jiri Olsa
On Fri, Mar 14, 2014 at 10:43:44AM -0400, Don Zickus wrote:
 When trying to capture perf data on a system running spejbb2013,
 perf hung for about 15 minutes.  This is because it took that
 long to gather about 10,000 thread maps and process them.
 
 I don't think a user wants to wait that long.
 
 Instead, recognize that thread maps are roughly equivalent to
 pid maps and just quickly copy those instead.
 
 To do this, I synthesize 'fork' events, this eventually calls
 thread__fork() and copies the maps over.
 
 The overhead goes from 15 minutes down to about a few seconds.
 
 Signed-off-by: Don Zickus dzic...@redhat.com
 --
 V2: based on Jiri's comments, moved malloc up a level
 and made sure the memory was freed

Acked-by: Jiri Olsa jo...@redhat.com

thanks,
jirka
--
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 sched latency: prettify printed table

2014-03-17 Thread Jiri Olsa
On Sat, Mar 15, 2014 at 12:17:38PM -0400, Ramkumar Ramachandra wrote:
 Cc: Frederic Weisbecker fweis...@gmail.com
 Cc: David Ahern dsah...@gmail.com
 Cc: Jiri Olsa jo...@redhat.com
 Cc: Arnaldo Carvalho de Melo a...@redhat.com
 Signed-off-by: Ramkumar Ramachandra artag...@gmail.com
 ---
  tools/perf/builtin-sched.c | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)

ENOCHANGELOG ;-)

please provide changelog details how's the output prettified
(before/after example)

thanks,
jirka
--
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 1/5] perf tests: Add tip/pid mmap automated tests

2014-03-17 Thread Jiri Olsa
On Fri, Mar 14, 2014 at 05:24:21PM -0300, Arnaldo Carvalho de Melo wrote:
 Em Fri, Mar 14, 2014 at 03:00:02PM +0100, Jiri Olsa escreveu:
  Adding automated test for memory maps lookup within
  multiple machines threads.
 
   CC   /tmp/build/perf/arch/x86/util/tsc.o
 tests/mmap-events.c: In function ‘mmap_events’:
 tests/mmap-events.c:157:18: error: declaration of ‘thread’ shadows a global 
 declaration [-Werror=shadow]
 tests/mmap-events.c:46:14: error: shadowed declaration is here 
 [-Werror=shadow]

hum, I thought this one was fixed already.. will check

 tests/mmap-events.c: In function ‘thread’:
 tests/mmap-events.c:54:7: error: ignoring return value of ‘write’, declared 
 with attribute warn_unused_result [-Werror=unused-result]

got this one fixed in new version

thanks,
jirka
--
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 1/5] perf tests: Add tip/pid mmap automated tests

2014-03-17 Thread Jiri Olsa
On Mon, Mar 17, 2014 at 01:50:12PM +0900, Namhyung Kim wrote:
 Hi Jiri,
 
 On Fri, 14 Mar 2014 15:00:02 +0100, Jiri Olsa wrote:
  +static int thread_init(struct thread_data *td)
  +{
  +   void *map;
  +
  +   map = mmap(NULL, page_size, PROT_READ|PROT_WRITE,
  +  MAP_SHARED|MAP_ANONYMOUS, -1, 0);
 
 Shouldn't it be an executable mapping to be found by MAP__FUNCTION?

yea.. looks like my arch implies PROT_EXEC via PROT_READ, man mmap:

  On some hardware architectures (e.g., i386), PROT_WRITE implies PROT_READ.   
It  is  architecture  dependent  whether  PROT_READ
  implies PROT_EXEC or not.  Portable programs should always set PROT_EXEC if 
they intend to execute code in the new mapping.


mm/mmap.c:

/*
 * Does the application expect PROT_READ to imply PROT_EXEC?
 *
 * (the exception is when the underlying filesystem is noexec
 *  mounted, in which case we dont add PROT_EXEC.)
 */
if ((prot  PROT_READ)  (current-personality  READ_IMPLIES_EXEC))
if (!(file  (file-f_path.mnt-mnt_flags  MNT_NOEXEC)))
prot |= PROT_EXEC;


I'll set the PROT_EXEC as the man page says.


thanks,
jirka
--
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 5/5] perf tools: Share process map groups within process threads

2014-03-17 Thread Jiri Olsa
On Mon, Mar 17, 2014 at 04:25:15PM +0900, Namhyung Kim wrote:
 On Fri, 14 Mar 2014 15:00:06 +0100, Jiri Olsa wrote:
  +   if (!mg) {
  +   struct thread *leader = thread__get_leader(thread);
  +
  +   if (!leader)
  +   return NULL;
  +
  +   if (leader-mg)
  +   mg = leader-mg;
  +   else
  +   mg = thread__map_groups_alloc(leader);
  +
  +   if (leader != thread)
  +   thread-mg = mg;
  +
  +   mg-refcnt++;
 
 What's the value of mg-refcnt here in case of leader != thread and
 leader-mg was not allocated originally?  I think it's 1 - but shouldn't
 it be 2 since it's referenced from both of leader and the thread now?

right you are..

I need to initialize refcnt to 1 in thread__map_groups_alloc
and increase it only for the '(leader != thread)' case

I'll add some test for this

thanks,
jirka
--
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 3/5] perf tools: Allocate thread map_groups dynamicaly

2014-03-17 Thread Jiri Olsa
On Mon, Mar 17, 2014 at 04:13:53PM +0900, Namhyung Kim wrote:
 On Fri, 14 Mar 2014 15:00:04 +0100, Jiri Olsa wrote:
  Moving towards sharing map groups within a process threads.
 
  Because of this we need the map groups to be dynamically
  allocated. No other functional change is intended in here.
  @@ -664,7 +664,7 @@ void thread__find_addr_map(struct thread *thread,
  al-cpumode = cpumode;
  al-filtered = false;
   
  -   if (machine == NULL) {
  +   if ((machine == NULL) || (mg == NULL)) {
  al-map = NULL;
  return;
  }
 
 What about the kernel threads?  I guess they're not using thread-mg but
 machine-kmaps instead?

The machine-kmaps is used to store kernel maps - core + modules.

All threads (including kernel ones) are using thread-mg,
kernel threads have empty /proc/x/maps file.

In case the sample address is detected within kernel space,
the machine-kmaps is used instead of thread-mg:

---
  void thread__find_addr_map(struct thread *thread, ...
  {
struct map_groups *mg = thread__map_groups_get(thread);

  ...

if (cpumode == PERF_RECORD_MISC_KERNEL  perf_host) {
al-level = 'k';
mg = machine-kmaps;

  ...
al-map = map_groups__find(mg, type, al-addr);
---

jirka
--
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 4/5] perf tools: Add machine pointer into thread struct

2014-03-17 Thread Jiri Olsa
On Mon, Mar 17, 2014 at 04:17:43PM +0900, Namhyung Kim wrote:
 Hi Arnaldo,
 
 On Fri, 14 Mar 2014 11:16:12 -0300, Arnaldo Carvalho de Melo wrote:
  Em Fri, Mar 14, 2014 at 03:00:05PM +0100, Jiri Olsa escreveu:
  Need machine pointer in thread object, so we could
  lookup the process thread in following patch.
 
  Can't we use the already existing thread-mg.machine for that?
 
 It needs to know the machine when -mg is not allocated yet.

right

 
 That means we can now get rid of the mg-machine?

not really, it's heavilly used in kernel symbol handling,
to get machine details.. and there's no kernel thread
specific info, which we could use to get machine pointer

we would need to factor this part to be able to get rid
of mg-machine

jirka
--
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 5/5] perf test: squelch warnings about undefined sizeof

2014-03-18 Thread Jiri Olsa
On Tue, Mar 18, 2014 at 05:09:33PM +0900, Namhyung Kim wrote:
 On Mon, 17 Mar 2014 18:26:38 -0400, Ramkumar Ramachandra wrote:
  perf test emits the following warnings on the parse events test:
 
$ perf test
 5: parse events tests
  Warning: function sizeof not defined
  Warning: function sizeof not defined
  Warning: function sizeof not defined
  Warning: function sizeof not defined
  Warning: function sizeof not defined
  Warning: function sizeof not defined
  Warning: function sizeof not defined
  Warning: function sizeof not defined
  ...
 
  Squelch the warnings by explicitly ignoring the sizeof function.
 
 It just hides the warning leaving the real problem untouched.  If you
 really don't want to see those, I guess installing proper plugin for the
 failing events will help you (in case you didn't).

it wont' help, sizeof is special.. AFAIK we did not figure
out a way to handle that so far

but I think it was used only in one trace subsystem.. maybe we
could replace it and forbid to use it in future ;-)

jirka
--
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 2/6] perf tools: Remove thread__find_map function

2014-03-18 Thread Jiri Olsa
Because it's not used any more.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Don Zickus dzic...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
---
 tools/perf/util/thread.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index 9a07074..9b29f08 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -44,12 +44,6 @@ void thread__insert_map(struct thread *thread, struct map 
*map);
 int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp);
 size_t thread__fprintf(struct thread *thread, FILE *fp);
 
-static inline struct map *thread__find_map(struct thread *thread,
-  enum map_type type, u64 addr)
-{
-   return thread ? map_groups__find(thread-mg, type, addr) : NULL;
-}
-
 void thread__find_addr_map(struct thread *thread, struct machine *machine,
   u8 cpumode, enum map_type type, u64 addr,
   struct addr_location *al);
-- 
1.8.3.1

--
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: [PATCHSET 0/8] perf tools: Update on filtered entries' percentage output (v5)

2014-02-24 Thread Jiri Olsa
On Mon, Feb 24, 2014 at 05:09:20PM +0900, Namhyung Kim wrote:
 Hello,
 
 I added --percentage option to perf report to control display of
 percentage of filtered entries.
 
  usage: perf report [options]
 
 --percentage relative|absolute
   how to display percentage of filtered entries
 

SNIP

 
 
 Namhyung Kim (8):
   perf tools: Count periods of filtered entries separately
   perf hists: Add support for showing relative percentage
   perf report: Add --percentage option
   perf top: Add --percentage option
   perf diff: Add --percentage option
   perf tools: Add hist.percentage config option
   perf ui/tui: Add 'F' hotkey to toggle percentage output
   perf tools: Show absolute percentage by default

looks like perf diff command needs more changes to work properly
with filtering.. symbol filtering shows some weird numbers

but that issue was there before.. and will be fixed.. eventually ;-)

Acked-by: Jiri Olsa jo...@redhat.com
for the patchset

thanks,
jirka
--
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: [perf tool] record failure with 3.14-rc4

2014-02-24 Thread Jiri Olsa
On Mon, Feb 24, 2014 at 05:24:41PM +, Will Deacon wrote:
 Hi guys,
 
 If I try to run perf record as a non-root user, I end up with the following
 (unhelpful) error:
 
   $ perf record -e cycles ls
   [...]
   Not enough memory for reading perf file header
 
 This is because the addresses in /proc/kallsyms always read as 0x0 when
 viewed by a non-privileged user, causing kallsyms__get_function_start to
 return 0x0 in args.start. machine__create_kernel_maps then treats this as
 an error an returns -1 to perf_session__create_kernel_maps, causing
 perf_session__new to fail and perf to exit.
 
 The perf tool code in 3.13 is perfectly happy creating maps at 0x0, but I
 can see this has changed quite substantially in the recent merge window.
 
 Any ideas? We could fix kallsyms__get_function_start to return  0 on
 failure then fix the checks in the callers. Adrian?
hi,
not sure it's related, but i sent out rfc some time ago
for similar bad error messages:
  http://marc.info/?l=linux-kernelm=138572558210216w=2

maybe it could be updated for your case as well,
I'll try to check deeply later

jirka
--
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/


[RFC] perf tools: Fix strict alias issue for find_first_bit

2014-02-26 Thread Jiri Olsa
hi,
got issue below when compiling perf tool on i686 with gcc 4.4,
but not sure the patch is correct workaround here.

thanks for comments,
jirka


---
When compiling perf tool code with gcc 4.4.7 I'm getting
following error:

  CC   util/session.o
cc1: warnings being treated as errors
util/session.c: In function ‘perf_session_deliver_event’:
/root/linux/tools/perf/util/include/linux/bitops.h:109: error: dereferencing 
pointer ‘p’ does break strict-aliasing rules
/root/linux/tools/perf/util/include/linux/bitops.h:101: error: dereferencing 
pointer ‘p’ does break strict-aliasing rules
util/session.c:697: note: initialized from here
/root/linux/tools/perf/util/include/linux/bitops.h:101: note: initialized from 
here
make[1]: *** [util/session.o] Error 1
make: *** [util/session.o] Error 2

The aliased types here are u64 and unsigned long pointers,
which is safe for the find_first_bit processing.

This error shows up for me only for gcc 4.4 on 32bit x86,
even for -Wstrict-aliasing=3, while newer gcc are quiet
and scream here for -Wstrict-aliasing={2,1}. Looks like
newer gcc changed the rules for strict alias warnings.

The gcc documentation offers workaround for valid
aliasing by using __may_alias__ attribute:
  http://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Type-Attributes.html

Using this workaround for the find_first_bit function.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: David Ahern dsah...@gmail.com
---
 tools/perf/util/include/linux/bitops.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/include/linux/bitops.h 
b/tools/perf/util/include/linux/bitops.h
index 45cf10a..dadfa7e 100644
--- a/tools/perf/util/include/linux/bitops.h
+++ b/tools/perf/util/include/linux/bitops.h
@@ -87,13 +87,15 @@ static __always_inline unsigned long __ffs(unsigned long 
word)
return num;
 }
 
+typedef const unsigned long __attribute__((__may_alias__)) long_alias_t;
+
 /*
  * Find the first set bit in a memory region.
  */
 static inline unsigned long
 find_first_bit(const unsigned long *addr, unsigned long size)
 {
-   const unsigned long *p = addr;
+   long_alias_t *p = (long_alias_t *) addr;
unsigned long result = 0;
unsigned long tmp;
 
-- 
1.8.3.1

--
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 tools: Do not compile with -fstrict-aliasing

2014-02-26 Thread Jiri Olsa
On Wed, Feb 26, 2014 at 06:18:05PM +0100, Peter Zijlstra wrote:
 On Wed, Feb 26, 2014 at 06:14:26PM +0100, Jiri Olsa wrote:
  hi,
  got issue below when compiling perf tool on i686 with gcc 4.4,
  but not sure the patch is correct workaround here.
  
  thanks for comments,
  jirka
  
  
  ---
  When compiling perf tool code with gcc 4.4.7 I'm getting
  following error:
  
CC   util/session.o
  cc1: warnings being treated as errors
  util/session.c: In function ‘perf_session_deliver_event’:
  /root/linux/tools/perf/util/include/linux/bitops.h:109: error: 
  dereferencing pointer ‘p’ does break strict-aliasing rules
  /root/linux/tools/perf/util/include/linux/bitops.h:101: error: 
  dereferencing pointer ‘p’ does break strict-aliasing rules
  util/session.c:697: note: initialized from here
  /root/linux/tools/perf/util/include/linux/bitops.h:101: note: initialized 
  from here
  make[1]: *** [util/session.o] Error 1
  make: *** [util/session.o] Error 2
  
  The aliased types here are u64 and unsigned long pointers,
  which is safe for the find_first_bit processing.
  
  This error shows up for me only for gcc 4.4 on 32bit x86,
  even for -Wstrict-aliasing=3, while newer gcc are quiet
  and scream here for -Wstrict-aliasing={2,1}. Looks like
  newer gcc changed the rules for strict alias warnings.
  
  The gcc documentation offers workaround for valid
  aliasing by using __may_alias__ attribute:
http://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Type-Attributes.html
  
 
 The kernel builds with -fno-strict-aliasing because the C aliasing rules
 are a bunch of monkey poo. Perf tool should probably do the same.

my pleasure ;-)

thanks,
jirka


---
Switching off the strict aliasing for perf tool compilation,
because it causes compilation issues/errors for older gcc,
and to quote Peter:
  C aliasing rules are a bunch of monkey poo

We don't enable strict aliasing actively, it is forced by
-Ox option. Using -fno-strict-aliasing option at the same
time we use -O.

Removing -Wstrict-aliasing=3 option as well.

Suggested-by: Peter Zijlstra a.p.zijls...@chello.nl
Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: David Ahern dsah...@gmail.com
---
 tools/perf/config/Makefile | 2 +-
 tools/scripts/Makefile.include | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index f7c81d3..e7786c7 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -94,7 +94,7 @@ ifndef DEBUG
 endif
 
 ifeq ($(DEBUG),0)
-  CFLAGS += -O6
+  CFLAGS += -O6 -fno-strict-aliasing
 endif
 
 ifdef PARSER_DEBUG
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index 8abbef1..3667b5b 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -32,7 +32,6 @@ EXTRA_WARNINGS += -Wold-style-definition
 EXTRA_WARNINGS += -Wpacked
 EXTRA_WARNINGS += -Wredundant-decls
 EXTRA_WARNINGS += -Wshadow
-EXTRA_WARNINGS += -Wstrict-aliasing=3
 EXTRA_WARNINGS += -Wstrict-prototypes
 EXTRA_WARNINGS += -Wswitch-default
 EXTRA_WARNINGS += -Wswitch-enum
-- 
1.8.3.1
--
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: [GIT PULL 00/12] perf/core improvements and fixes

2014-02-27 Thread Jiri Olsa
On Thu, Feb 27, 2014 at 12:46:58PM +0100, Ingo Molnar wrote:
 
 * Arnaldo Carvalho de Melo a...@infradead.org wrote:
 
  From: Arnaldo Carvalho de Melo a...@ghostprotocols.net
  
  Hi Ingo,
  
  Please consider pulling,
  
  - Arnaldo
  
  The following changes since commit 7e74efcf76c16f851df5c838c143c4a1865ea9fa:
  
Merge tag 'perf-core-for-mingo' of 
  git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core 
  (2014-02-22 17:26:24 +0100)
  
  are available in the git repository at:
  
  
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux 
  tags/perf-core-for-mingo
  
  for you to fetch changes up to 1029f9fedf87fa6f52096991588fa54ffd159584:
  
perf symbols: Check compatible symtab type before loading dso (2014-02-24 
  16:25:01 -0300)
  
  
  perf/core improvements and fixes
  
  . Add support for the new DWARF unwinder library in elfutils (Jiri Olsa)
  
  . Fix build race in the generation of bison files (Jiri Olsa)
  
  . Further streamline the feature detection display, trimming it a bit to
show just the libraries detected, using VF=1 gets a more verbose output,
showing the less interesting feature checks as well (Jiri Olsa).
  
  . Check compatible symtab type before loading dso (Namhyung Kim)
  
  . Check return value of filename__read_debuglink() (Stephane Eranian)
  
  Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
  
  
  Arnaldo Carvalho de Melo (1):
perf tools: Warn the user about how to enable libunwind support
  
  Jiri Olsa (9):
perf tests: Fix *.o make tests
perf tests: Add pmu-bison.o make test
perf tools: Fix bison OUTPUT directories dependency
perf tools: Factor features display code
perf tools: Add variable display for VF make output
perf tools: Add feature check for libdw dwarf unwind
perf tools: Add libdw DWARF post unwind support
perf tools: Setup default dwarf post unwinder
perf tests: Add NO_LIBDW_DWARF_UNWIND make test
  
  Namhyung Kim (1):
perf symbols: Check compatible symtab type before loading dso
  
  Stephane Eranian (1):
perf symbols: Check return value of filename__read_debuglink()
  
   tools/perf/Makefile.perf   |  24 ++-
   tools/perf/arch/x86/Makefile   |   5 +
   tools/perf/arch/x86/util/unwind-libdw.c|  51 +
   tools/perf/config/Makefile | 232 
  +++--
   tools/perf/config/feature-checks/Makefile  |   6 +-
   tools/perf/config/feature-checks/test-all.c|   5 +
   .../feature-checks/test-libdw-dwarf-unwind.c   |  13 ++
   tools/perf/tests/make  |  25 ++-
   tools/perf/util/dso.c  |   4 +-
   tools/perf/util/symbol-elf.c   |   2 +
   tools/perf/util/symbol.c   |  61 +-
   tools/perf/util/unwind-libdw.c | 210 
  +++
   tools/perf/util/unwind-libdw.h |  21 ++
   13 files changed, 569 insertions(+), 90 deletions(-)
   create mode 100644 tools/perf/arch/x86/util/unwind-libdw.c
   create mode 100644 
  tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
   create mode 100644 tools/perf/util/unwind-libdw.c
   create mode 100644 tools/perf/util/unwind-libdw.h
 
 Pulled, thanks a lot Arnaldo!
 
 Btw., the build output looks weird now - on a system that used to pass 
 all feature tests there's this output:
 
   BUILD:   Doing 'make -j12' parallel build
 config/Makefile:288: No libdw DWARF unwind found, Please install 
 elfutils-devel/libdw-dev = 0.158 and/or set LIBDW_DIR
 
 Auto-detecting system features:
 ... dwarf: [ on  ]
 ... glibc: [ on  ]
 ...  gtk2: [ on  ]
 ...  libaudit: [ on  ]
 ...libbfd: [ on  ]
 ...libelf: [ on  ]
 ...   libnuma: [ on  ]
 ...   libperl: [ on  ]
 ... libpython: [ on  ]
 ...  libslang: [ on  ]
 ... libunwind: [ on  ]
 ...libdw-dwarf-unwind: [ OFF ]
 ... DWARF post unwind library: libunwind
 
 but:
 
Package elfutils-devel-0.156-5.fc19.x86_64 already installed and latest 
 version
 
 Also, the information content of this line is unclear to me:
 
 ... DWARF post unwind library: libunwind
 
 
 what does that line want to tell?

this tells what DWARF unwind library is compiled
in.. 'libunwind' in this case

the other choice is 'libdw', which was not detected
in your case (and thats what the 1st message tells you)

we discussed with Arnaldo, that we would not display warnings
for missing features by default.. only tell

Re: [GIT PULL 00/12] perf/core improvements and fixes

2014-02-27 Thread Jiri Olsa
On Thu, Feb 27, 2014 at 12:46:58PM +0100, Ingo Molnar wrote:
 
 * Arnaldo Carvalho de Melo a...@infradead.org wrote:
 
  From: Arnaldo Carvalho de Melo a...@ghostprotocols.net
  
  Hi Ingo,
  
  Please consider pulling,
  
  - Arnaldo
  
  The following changes since commit 7e74efcf76c16f851df5c838c143c4a1865ea9fa:
  
Merge tag 'perf-core-for-mingo' of 
  git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core 
  (2014-02-22 17:26:24 +0100)
  
  are available in the git repository at:
  
  
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux 
  tags/perf-core-for-mingo
  
  for you to fetch changes up to 1029f9fedf87fa6f52096991588fa54ffd159584:
  
perf symbols: Check compatible symtab type before loading dso (2014-02-24 
  16:25:01 -0300)
  
  
  perf/core improvements and fixes
  
  . Add support for the new DWARF unwinder library in elfutils (Jiri Olsa)
  
  . Fix build race in the generation of bison files (Jiri Olsa)
  
  . Further streamline the feature detection display, trimming it a bit to
show just the libraries detected, using VF=1 gets a more verbose output,
showing the less interesting feature checks as well (Jiri Olsa).
  
  . Check compatible symtab type before loading dso (Namhyung Kim)
  
  . Check return value of filename__read_debuglink() (Stephane Eranian)
  
  Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
  
  
  Arnaldo Carvalho de Melo (1):
perf tools: Warn the user about how to enable libunwind support
  
  Jiri Olsa (9):
perf tests: Fix *.o make tests
perf tests: Add pmu-bison.o make test
perf tools: Fix bison OUTPUT directories dependency
perf tools: Factor features display code
perf tools: Add variable display for VF make output
perf tools: Add feature check for libdw dwarf unwind
perf tools: Add libdw DWARF post unwind support
perf tools: Setup default dwarf post unwinder
perf tests: Add NO_LIBDW_DWARF_UNWIND make test
  
  Namhyung Kim (1):
perf symbols: Check compatible symtab type before loading dso
  
  Stephane Eranian (1):
perf symbols: Check return value of filename__read_debuglink()
  
   tools/perf/Makefile.perf   |  24 ++-
   tools/perf/arch/x86/Makefile   |   5 +
   tools/perf/arch/x86/util/unwind-libdw.c|  51 +
   tools/perf/config/Makefile | 232 
  +++--
   tools/perf/config/feature-checks/Makefile  |   6 +-
   tools/perf/config/feature-checks/test-all.c|   5 +
   .../feature-checks/test-libdw-dwarf-unwind.c   |  13 ++
   tools/perf/tests/make  |  25 ++-
   tools/perf/util/dso.c  |   4 +-
   tools/perf/util/symbol-elf.c   |   2 +
   tools/perf/util/symbol.c   |  61 +-
   tools/perf/util/unwind-libdw.c | 210 
  +++
   tools/perf/util/unwind-libdw.h |  21 ++
   13 files changed, 569 insertions(+), 90 deletions(-)
   create mode 100644 tools/perf/arch/x86/util/unwind-libdw.c
   create mode 100644 
  tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
   create mode 100644 tools/perf/util/unwind-libdw.c
   create mode 100644 tools/perf/util/unwind-libdw.h
 
 Pulled, thanks a lot Arnaldo!
 
 Btw., the build output looks weird now - on a system that used to pass 
 all feature tests there's this output:
 
   BUILD:   Doing 'make -j12' parallel build
 config/Makefile:288: No libdw DWARF unwind found, Please install 
 elfutils-devel/libdw-dev = 0.158 and/or set LIBDW_DIR
 
 Auto-detecting system features:
 ... dwarf: [ on  ]
 ... glibc: [ on  ]
 ...  gtk2: [ on  ]
 ...  libaudit: [ on  ]
 ...libbfd: [ on  ]
 ...libelf: [ on  ]
 ...   libnuma: [ on  ]
 ...   libperl: [ on  ]
 ... libpython: [ on  ]
 ...  libslang: [ on  ]
 ... libunwind: [ on  ]
 ...libdw-dwarf-unwind: [ OFF ]
 ... DWARF post unwind library: libunwind
 
 but:
 
Package elfutils-devel-0.156-5.fc19.x86_64 already installed and latest 
 version

forgot.. remote unwind in libdw is supported from version 0.158,
which I guess wasn't updated in FC19 yet

jirka
--
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: [GIT PULL 00/12] perf/core improvements and fixes

2014-02-27 Thread Jiri Olsa
On Thu, Feb 27, 2014 at 01:30:52PM +0100, Ingo Molnar wrote:
 
 * Jiri Olsa jo...@redhat.com wrote:
 
  On Thu, Feb 27, 2014 at 12:46:58PM +0100, Ingo Molnar wrote:
   
   * Arnaldo Carvalho de Melo a...@infradead.org wrote:
   
From: Arnaldo Carvalho de Melo a...@ghostprotocols.net


SNIP

   Pulled, thanks a lot Arnaldo!
   
   Btw., the build output looks weird now - on a system that used to pass 
   all feature tests there's this output:
   
 BUILD:   Doing 'make -j12' parallel build
   config/Makefile:288: No libdw DWARF unwind found, Please install 
   elfutils-devel/libdw-dev = 0.158 and/or set LIBDW_DIR
   
   Auto-detecting system features:
   ... dwarf: [ on  ]
   ... glibc: [ on  ]
   ...  gtk2: [ on  ]
   ...  libaudit: [ on  ]
   ...libbfd: [ on  ]
   ...libelf: [ on  ]
   ...   libnuma: [ on  ]
   ...   libperl: [ on  ]
   ... libpython: [ on  ]
   ...  libslang: [ on  ]
   ... libunwind: [ on  ]
   ...libdw-dwarf-unwind: [ OFF ]
   ... DWARF post unwind library: libunwind
   
   but:
   
  Package elfutils-devel-0.156-5.fc19.x86_64 already installed and 
   latest version
   
   Also, the information content of this line is unclear to me:
   
   ... DWARF post unwind library: libunwind
   
   
   what does that line want to tell?
  
  this tells what DWARF unwind library is compiled
  in.. 'libunwind' in this case
 
 So my (stylistic) complaint is that it's really reading weird in a 
 table generated with the following purpose:
 
   Auto-detecting system features:
 
 Also, we already know that libunwind is present, because just in the 
 line before it, it says:
 
 ... libunwind: [ on  ]
 
 So it's doubly confusing. How about not displaying that line at all? 
 Is there a strong reason to not keep 'OFF' messages on a single line?

well, on/OFF lines are only about detecting libs

this line:
'DWARF post unwind library: libunwind'

is about telling which one goes in.. could be you have both
libraries detected and need to choose one or keep default

 
  the other choice is 'libdw', which was not detected in your case 
  (and thats what the 1st message tells you)
  
  we discussed with Arnaldo, that we would not display warnings for 
  missing features by default.. only tell that there are missing 
  features and display them for verbose (VF=1) output
 
 That's probably a good plan. I'd suggest the following 'short log' for 
 failures:
 
  # Auto-detecting system features: 2 libraries are missing. Try 'make 
 VF=1' for a verbose list.
 
 I.e. that way people can notice if the count goes up or down after an 
 update. Also, that too should be a single line, so that it does not 
 spam people.

ook

jirka
--
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] x86 trace: Fix page fault tracing bug

2014-02-28 Thread Jiri Olsa
The trace_do_page_fault function trigger tracepoint
and then handles the actual page fault.

This could lead to error if the tracepoint caused page
fault. The original cr2 value gets lost and the original
page fault handler kills current process with SIGSEGV.

This happens if you record page faults with callchain
data, the user part of it will cause tracepoint handler
to page fault:

  # perf record -g -e exceptions:page_fault_user ls

Fixing this by saving the original cr2 value
and using it after tracepoint handler is done.

Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Paul Mackerras pau...@samba.org
Cc: Ingo Molnar mi...@redhat.com
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: H. Peter Anvin h...@zytor.com
Cc: Seiji Aguchi seiji.agu...@hds.com
---
 arch/x86/mm/fault.c | 25 ++---
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 9d591c8..52fad6c 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1016,11 +1016,11 @@ static inline bool smap_violation(int error_code, 
struct pt_regs *regs)
  * routines.
  */
 static void __kprobes
-__do_page_fault(struct pt_regs *regs, unsigned long error_code)
+__do_page_fault(struct pt_regs *regs, unsigned long error_code,
+   unsigned long address)
 {
struct vm_area_struct *vma;
struct task_struct *tsk;
-   unsigned long address;
struct mm_struct *mm;
int fault;
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
@@ -1028,9 +1028,6 @@ __do_page_fault(struct pt_regs *regs, unsigned long 
error_code)
tsk = current;
mm = tsk-mm;
 
-   /* Get the faulting address: */
-   address = read_cr2();
-
/*
 * Detect and handle instructions that would cause a page fault for
 * both a tracked kernel page and a userspace page.
@@ -1248,9 +1245,14 @@ dotraplinkage void __kprobes
 do_page_fault(struct pt_regs *regs, unsigned long error_code)
 {
enum ctx_state prev_state;
+   unsigned long address;
 
prev_state = exception_enter();
-   __do_page_fault(regs, error_code);
+
+   /* Get the faulting address: */
+   address = read_cr2();
+
+   __do_page_fault(regs, error_code, address);
exception_exit(prev_state);
 }
 
@@ -1267,9 +1269,18 @@ dotraplinkage void __kprobes
 trace_do_page_fault(struct pt_regs *regs, unsigned long error_code)
 {
enum ctx_state prev_state;
+   unsigned long address;
 
prev_state = exception_enter();
+
+   /*
+* The tracepoint processing could trigger another page
+* fault (user space callchain reading) and destroy the
+* original cr2 value, so read the faulting address now.
+*/
+   address = read_cr2();
+
trace_page_fault_entries(regs, error_code);
-   __do_page_fault(regs, error_code);
+   __do_page_fault(regs, error_code, address);
exception_exit(prev_state);
 }
-- 
1.7.11.7

--
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] x86 trace: Fix page fault tracing bug

2014-02-28 Thread Jiri Olsa
On Fri, Feb 28, 2014 at 04:33:40PM +0100, Jiri Olsa wrote:
 The trace_do_page_fault function trigger tracepoint
 and then handles the actual page fault.
 
 This could lead to error if the tracepoint caused page
 fault. The original cr2 value gets lost and the original
 page fault handler kills current process with SIGSEGV.
 
 This happens if you record page faults with callchain
 data, the user part of it will cause tracepoint handler
 to page fault:
 
   # perf record -g -e exceptions:page_fault_user ls
 
 Fixing this by saving the original cr2 value
 and using it after tracepoint handler is done.
 

sry, forgot..

Reported-by: Arnaldo Carvalho de Melo a...@ghostprotocols.net

jirka

 Cc: Peter Zijlstra a.p.zijls...@chello.nl
 Cc: Paul Mackerras pau...@samba.org
 Cc: Ingo Molnar mi...@redhat.com
 Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
 Cc: H. Peter Anvin h...@zytor.com
 Cc: Seiji Aguchi seiji.agu...@hds.com
 ---
  arch/x86/mm/fault.c | 25 ++---
  1 file changed, 18 insertions(+), 7 deletions(-)
 
 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
 index 9d591c8..52fad6c 100644
 --- a/arch/x86/mm/fault.c
 +++ b/arch/x86/mm/fault.c
 @@ -1016,11 +1016,11 @@ static inline bool smap_violation(int error_code, 
 struct pt_regs *regs)
   * routines.
   */
  static void __kprobes
 -__do_page_fault(struct pt_regs *regs, unsigned long error_code)
 +__do_page_fault(struct pt_regs *regs, unsigned long error_code,
 + unsigned long address)
  {
   struct vm_area_struct *vma;
   struct task_struct *tsk;
 - unsigned long address;
   struct mm_struct *mm;
   int fault;
   unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
 @@ -1028,9 +1028,6 @@ __do_page_fault(struct pt_regs *regs, unsigned long 
 error_code)
   tsk = current;
   mm = tsk-mm;
  
 - /* Get the faulting address: */
 - address = read_cr2();
 -
   /*
* Detect and handle instructions that would cause a page fault for
* both a tracked kernel page and a userspace page.
 @@ -1248,9 +1245,14 @@ dotraplinkage void __kprobes
  do_page_fault(struct pt_regs *regs, unsigned long error_code)
  {
   enum ctx_state prev_state;
 + unsigned long address;
  
   prev_state = exception_enter();
 - __do_page_fault(regs, error_code);
 +
 + /* Get the faulting address: */
 + address = read_cr2();
 +
 + __do_page_fault(regs, error_code, address);
   exception_exit(prev_state);
  }
  
 @@ -1267,9 +1269,18 @@ dotraplinkage void __kprobes
  trace_do_page_fault(struct pt_regs *regs, unsigned long error_code)
  {
   enum ctx_state prev_state;
 + unsigned long address;
  
   prev_state = exception_enter();
 +
 + /*
 +  * The tracepoint processing could trigger another page
 +  * fault (user space callchain reading) and destroy the
 +  * original cr2 value, so read the faulting address now.
 +  */
 + address = read_cr2();
 +
   trace_page_fault_entries(regs, error_code);
 - __do_page_fault(regs, error_code);
 + __do_page_fault(regs, error_code, address);
   exception_exit(prev_state);
  }
 -- 
 1.7.11.7
 
--
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/


[PATCHv2] x86 trace: Fix page fault tracing bug

2014-02-28 Thread Jiri Olsa
On Fri, Feb 28, 2014 at 04:47:08PM +0100, Peter Zijlstra wrote:
 On Fri, Feb 28, 2014 at 04:33:40PM +0100, Jiri Olsa wrote:
 
 While I like the idea of just pushing up the CR2 read; the below does
 the read too late still, exception_enter() also has a tracepoint in.

please check v2, thanks

jirka


---
The trace_do_page_fault function trigger tracepoint
and then handles the actual page fault.

This could lead to error if the tracepoint caused page
fault. The original cr2 value gets lost and the original
page fault handler kills current process with SIGSEGV.

This happens if you record page faults with callchain
data, the user part of it will cause tracepoint handler
to page fault:

  # perf record -g -e exceptions:page_fault_user ls

Fixing this by saving the original cr2 value
and using it after tracepoint handler is done.

v2: Moving the cr2 read before exception_enter, because
it could trigger tracepoint as well.

Reported-by: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Paul Mackerras pau...@samba.org
Cc: Ingo Molnar mi...@redhat.com
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: H. Peter Anvin h...@zytor.com
Cc: Seiji Aguchi seiji.agu...@hds.com
Cc: Vince Weaver vincent.wea...@maine.edu
Cc: Steven Rostedt rost...@goodmis.org
---
 arch/x86/mm/fault.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 9d591c8..dd59031 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1016,11 +1016,11 @@ static inline bool smap_violation(int error_code, 
struct pt_regs *regs)
  * routines.
  */
 static void __kprobes
-__do_page_fault(struct pt_regs *regs, unsigned long error_code)
+__do_page_fault(struct pt_regs *regs, unsigned long error_code,
+   unsigned long address)
 {
struct vm_area_struct *vma;
struct task_struct *tsk;
-   unsigned long address;
struct mm_struct *mm;
int fault;
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
@@ -1028,9 +1028,6 @@ __do_page_fault(struct pt_regs *regs, unsigned long 
error_code)
tsk = current;
mm = tsk-mm;
 
-   /* Get the faulting address: */
-   address = read_cr2();
-
/*
 * Detect and handle instructions that would cause a page fault for
 * both a tracked kernel page and a userspace page.
@@ -1248,9 +1245,11 @@ dotraplinkage void __kprobes
 do_page_fault(struct pt_regs *regs, unsigned long error_code)
 {
enum ctx_state prev_state;
+   /* Get the faulting address: */
+   unsigned long address = read_cr2();
 
prev_state = exception_enter();
-   __do_page_fault(regs, error_code);
+   __do_page_fault(regs, error_code, address);
exception_exit(prev_state);
 }
 
@@ -1267,9 +1266,16 @@ dotraplinkage void __kprobes
 trace_do_page_fault(struct pt_regs *regs, unsigned long error_code)
 {
enum ctx_state prev_state;
+   /*
+* The exception_enter and tracepoint processing could
+* trigger another page faults (user space callchain
+* reading) and destroy the original cr2 value, so read
+* the faulting address now.
+*/
+   unsigned long address = read_cr2();
 
prev_state = exception_enter();
trace_page_fault_entries(regs, error_code);
-   __do_page_fault(regs, error_code);
+   __do_page_fault(regs, error_code, address);
exception_exit(prev_state);
 }
-- 
1.7.11.7
--
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 tools: Fix crash in elf_section_by_name

2014-03-02 Thread Jiri Olsa
Fixing crash in elf_section_by_name function caused
by missing section name in elf binary.

Reported-by: Albert Strasheim alb...@cloudflare.com
Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@elte.hu
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Arnaldo Carvalho de Melo a...@redhat.com
Cc: Albert Strasheim alb...@cloudflare.com
---
 tools/perf/util/symbol-elf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 8ac4a4f..3b7dbf5 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -151,15 +151,15 @@ Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
 
gelf_getshdr(sec, shp);
str = elf_strptr(elf, ep-e_shstrndx, shp-sh_name);
-   if (!strcmp(name, str)) {
+   if (str  !strcmp(name, str)) {
if (idx)
*idx = cnt;
-   break;
+   return sec;
}
++cnt;
}
 
-   return sec;
+   return NULL;
 }
 
 #define elf_section__for_each_rel(reldata, pos, pos_mem, idx, nr_entries) \
-- 
1.8.3.1

--
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 1/3] perf: Disallow user space callchains for function trace event

2014-03-02 Thread Jiri Olsa
Disabling user callchains for function trace event.

Recent issues with user space callchains processing within
page fault handler tracing showed as Peter said 'there's
just too much fail surface'.

Related list discussions:
  http://marc.info/?t=13930208651r=1w=2
  http://marc.info/?t=13930143733r=1w=2

Suggested-by: Peter Zijlstra a.p.zijls...@chello.nl
Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Paul Mackerras pau...@samba.org
Cc: Ingo Molnar mi...@redhat.com
Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net
Cc: H. Peter Anvin h...@zytor.com
Cc: Vince Weaver vincent.wea...@maine.edu
Cc: Steven Rostedt rost...@goodmis.org
---
 kernel/trace/trace_event_perf.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
index e854f42..d5e01c3 100644
--- a/kernel/trace/trace_event_perf.c
+++ b/kernel/trace/trace_event_perf.c
@@ -31,9 +31,18 @@ static int perf_trace_event_perm(struct ftrace_event_call 
*tp_event,
}
 
/* The ftrace function trace is allowed only for root. */
-   if (ftrace_event_is_function(tp_event) 
-   perf_paranoid_tracepoint_raw()  !capable(CAP_SYS_ADMIN))
-   return -EPERM;
+   if (ftrace_event_is_function(tp_event)) {
+   if (perf_paranoid_tracepoint_raw()  !capable(CAP_SYS_ADMIN))
+   return -EPERM;
+
+   /*
+* We don't allow user space callchains for  function trace
+* event, due to issues with page faults while tracing page
+* fault handler and its overall trickiness nature.
+*/
+   if (!p_event-attr.exclude_callchain_user)
+   return -EINVAL;
+   }
 
/* No tracing, just counting, so no obvious leak */
if (!(p_event-attr.sample_type  PERF_SAMPLE_RAW))
-- 
1.8.3.1

--
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/


<    4   5   6   7   8   9   10   11   12   13   >