Skip to contentSkip to conversation

perf tool: Various fixes and version 2 on clock_gettime

PATCH In review David Ahern 3 participants 14 messages Sep 23, 2013 – Oct 15, 2013 perf events

lore
Share & tools
lore
#0 lore raw

cover perf tool: Various fixes and version 2 on clock_gettime

Arnaldo:

Various bug fixes hit working on the mmap write change and version 2 on the clock_gettime beautifier. One other problem I was not able to resolve is with perf-trace not displaying comms when processing files. eg.,

     0.025 ( 0.000 ms): :7137/7137  ... [continued]: ioctl()) = 0
     0.045 ( 0.014 ms): :7137/7137 ioctl(fd: 14, cmd: 44672                                              ) = 0
     0.055 ( 0.008 ms): :7137/7137 ioctl(fd: 14, cmd: 44672

Other commands like perf-script display comms just fine, so it is something about perf-trace.

David Ahern (5):
perf trace: Handle MSG_WAITFORONE not defined
perf tool: Explicitly add libdl dependency
perf trace: Add mmap2 handler
perf tool: Add default handler for mmap2 events
perf trace: Add beautifier for clock_gettime's clk_id argument - v2

 tools/perf/builtin-trace.c |   11 +++++++++++
 tools/perf/config/Makefile |    2 +-
 tools/perf/util/session.c  |    2 ++
 3 files changed, 14 insertions(+), 1 deletion(-)
Signature · 1 line
1.7.10.1
#1 lore raw

PATCH 1/5 perf trace: Handle MSG_WAITFORONE not defined

Needed for compiles on Fedora 12 for example.

---
 tools/perf/builtin-trace.c |    3 +++
 1 file changed, 3 insertions(+)
tools/perf/builtin-trace.c +3 -0
index f869c87..9c7f017 100644
@@ -340,6 +340,9 @@ static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size,
 #ifndef MSG_PROBE
 #define MSG_PROBE	     0x10
 #endif
+#ifndef MSG_WAITFORONE
+#define MSG_WAITFORONE	0x10000
+#endif
 #ifndef MSG_SENDPAGE_NOTLAST
 #define MSG_SENDPAGE_NOTLAST 0x20000
 #endif
Signature · 1 line
1.7.10.1
#2 lore raw

[tip:perf/core] perf trace: Handle MSG_WAITFORONE not defined

perf trace: Handle MSG_WAITFORONE not defined
Commit-ID:  b6e8f8f4674be5a32f78027ec6e432f5ea33921e
Gitweb:     http://git.kernel.org/tip/b6e8f8f4674be5a32f78027ec6e432f5ea33921e
Author:     David Ahern <[email protected]>
AuthorDate: Sun, 22 Sep 2013 19:44:56 -0600
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 9 Oct 2013 17:42:37 -0300

perf trace: Handle MSG_WAITFORONE not defined

Needed for compiles on Fedora 12 for example.

---
 tools/perf/builtin-trace.c | 3 +++
 1 file changed, 3 insertions(+)
tools/perf/builtin-trace.c +3 -0
index 39a947a..3ca6a85 100644
@@ -363,6 +363,9 @@ static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size,
 #ifndef MSG_PROBE
 #define MSG_PROBE	     0x10
 #endif
+#ifndef MSG_WAITFORONE
+#define MSG_WAITFORONE	0x10000
+#endif
 #ifndef MSG_SENDPAGE_NOTLAST
 #define MSG_SENDPAGE_NOTLAST 0x20000
 #endif
#3 lore raw

PATCH 2/5 perf tool: Explicitly add libdl dependency

In reply to David Ahern

Fixes compile failure on Fedora 12.

---
 tools/perf/config/Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/config/Makefile +1 -1
index 6850529..85fc870 100644
@@ -87,7 +87,7 @@ CFLAGS += -Wall
 CFLAGS += -Wextra
 CFLAGS += -std=gnu99
 
-EXTLIBS = -lelf -lpthread -lrt -lm
+EXTLIBS = -lelf -lpthread -lrt -lm -ldl
 
 ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y)
   CFLAGS += -fstack-protector-all
Signature · 1 line
1.7.10.1
#4 lore raw

Re: [PATCH 2/5] perf tool: Explicitly add libdl dependency

Arnaldo:

I am not seeing this one in your tree. Any objections to it? It is required to fix static compiles. e.g.,

make LDFLAGS=-static NO_LIBPYTHON=1 NO_LIBPERL=1

David

Quoted 21 lines · David Ahern

Fixes compile failure on Fedora 12.

---
  tools/perf/config/Makefile |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/config/Makefile +1 -1
index 6850529..85fc870 100644
@@ -87,7 +87,7 @@ CFLAGS += -Wall
  CFLAGS += -Wextra
  CFLAGS += -std=gnu99
 
-EXTLIBS = -lelf -lpthread -lrt -lm
+EXTLIBS = -lelf -lpthread -lrt -lm -ldl
 
  ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y)
    CFLAGS += -fstack-protector-all
#5 lore raw

[tip:perf/urgent] perf tools: Explicitly add libdl dependency

In reply to David Ahern
perf tools: Explicitly add libdl dependency
Commit-ID:  6d19912c9bc0ae0ba5f7dd32c714ea7cc3339c81
Gitweb:     http://git.kernel.org/tip/6d19912c9bc0ae0ba5f7dd32c714ea7cc3339c81
Author:     David Ahern <[email protected]>
AuthorDate: Sun, 22 Sep 2013 19:44:57 -0600
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 25 Sep 2013 12:39:27 -0300

perf tools: Explicitly add libdl dependency

Fixes compile failure on Fedora 12.

---
 tools/perf/config/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/config/Makefile +1 -1
index 346ee92..5f6f9b3 100644
@@ -87,7 +87,7 @@ CFLAGS += -Wall
 CFLAGS += -Wextra
 CFLAGS += -std=gnu99
 
-EXTLIBS = -lelf -lpthread -lrt -lm
+EXTLIBS = -lelf -lpthread -lrt -lm -ldl
 
 ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y)
   CFLAGS += -fstack-protector-all
#6 lore raw

PATCH 3/5 perf trace: Add mmap2 handler

In reply to David Ahern

5c5e854b changed perf_event__synthesize_mmap_events to generate MMAP2 events. Since perf-trace does not have a handler for it it dies with a segfault when trying to process files:

perf trace -i /tmp/perf.data
Segmentation fault

---
 tools/perf/builtin-trace.c |    1 +
 1 file changed, 1 insertion(+)
tools/perf/builtin-trace.c +1 -0
index 9c7f017..f61c968 100644
@@ -1383,6 +1383,7 @@ static int trace__replay(struct trace *trace)
 
 	trace->tool.sample	  = trace__process_sample;
 	trace->tool.mmap	  = perf_event__process_mmap;
+	trace->tool.mmap2	  = perf_event__process_mmap2;
 	trace->tool.comm	  = perf_event__process_comm;
 	trace->tool.exit	  = perf_event__process_exit;
 	trace->tool.fork	  = perf_event__process_fork;
Signature · 1 line
1.7.10.1
#7 lore raw

Re: [PATCH 3/5] perf trace: Add mmap2 handler

Arnaldo:

I see this is you perf core tree; the problem exists in Linus' tree so it is needed in your urgent tree as well.

David

Quoted 25 lines · David Ahern

5c5e854b changed perf_event__synthesize_mmap_events to generate MMAP2 events. Since perf-trace does not have a handler for it it dies with a segfault when trying to process files:

perf trace -i /tmp/perf.data
Segmentation fault

---
  tools/perf/builtin-trace.c |    1 +
  1 file changed, 1 insertion(+)
tools/perf/builtin-trace.c +1 -0
index 9c7f017..f61c968 100644
@@ -1383,6 +1383,7 @@ static int trace__replay(struct trace *trace)
 
  	trace->tool.sample	  = trace__process_sample;
  	trace->tool.mmap	  = perf_event__process_mmap;
+	trace->tool.mmap2	  = perf_event__process_mmap2;
  	trace->tool.comm	  = perf_event__process_comm;
  	trace->tool.exit	  = perf_event__process_exit;
  	trace->tool.fork	  = perf_event__process_fork;
#8 lore raw

Re: [PATCH 3/5] perf trace: Add mmap2 handler

Em Mon, Sep 23, 2013 at 06:22:37PM -0600, David Ahern escreveu:

Quoted 4 lines

Arnaldo:

I see this is you perf core tree; the problem exists in Linus' tree so it is needed in your urgent tree as well.

Sure, reproduced the segfault, cherry picked this patch from perf/core, segfault fixes, thanks.

- Arnaldo

Quoted 28 lines

David

Quoted 25 lines · David Ahern

5c5e854b changed perf_event__synthesize_mmap_events to generate MMAP2 events. Since perf-trace does not have a handler for it it dies with a segfault when trying to process files:

perf trace -i /tmp/perf.data
Segmentation fault

---
 tools/perf/builtin-trace.c |    1 +
 1 file changed, 1 insertion(+)
tools/perf/builtin-trace.c +1 -0
index 9c7f017..f61c968 100644
@@ -1383,6 +1383,7 @@ static int trace__replay(struct trace *trace)
 
 	trace->tool.sample	  = trace__process_sample;
 	trace->tool.mmap	  = perf_event__process_mmap;
+	trace->tool.mmap2	  = perf_event__process_mmap2;
 	trace->tool.comm	  = perf_event__process_comm;
 	trace->tool.exit	  = perf_event__process_exit;
 	trace->tool.fork	  = perf_event__process_fork;
#9 lore raw

[tip:perf/urgent] perf trace: Add mmap2 handler

In reply to David Ahern
perf trace: Add mmap2 handler
Commit-ID:  384c671e33a7ddf905f2c60b433b9883f0e5a605
Gitweb:     http://git.kernel.org/tip/384c671e33a7ddf905f2c60b433b9883f0e5a605
Author:     David Ahern <[email protected]>
AuthorDate: Sun, 22 Sep 2013 19:44:58 -0600
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 24 Sep 2013 14:15:51 -0300

perf trace: Add mmap2 handler

5c5e854b changed perf_event__synthesize_mmap_events to generate MMAP2 events. Since perf-trace does not have a handler for it it dies with a segfault when trying to process files:

perf trace -i /tmp/perf.data
Segmentation fault

---
 tools/perf/builtin-trace.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/builtin-trace.c +1 -0
index fd48534..71aa3e3 100644
@@ -1055,6 +1055,7 @@ static int trace__replay(struct trace *trace)
 
 	trace->tool.sample	  = trace__process_sample;
 	trace->tool.mmap	  = perf_event__process_mmap;
+	trace->tool.mmap2	  = perf_event__process_mmap2;
 	trace->tool.comm	  = perf_event__process_comm;
 	trace->tool.exit	  = perf_event__process_exit;
 	trace->tool.fork	  = perf_event__process_fork;
#10 lore raw

PATCH 4/5 perf tool: Add default handler for mmap2 events

In reply to David Ahern

Commands that do not implement an mmap2 handler should at least not die with a segfault when processing files with MMAP2 events.

---
 tools/perf/util/session.c |    2 ++
 1 file changed, 2 insertions(+)
tools/perf/util/session.c +2 -0
index 78646da..6c1d444 100644
@@ -256,6 +256,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
 		tool->sample = process_event_sample_stub;
 	if (tool->mmap == NULL)
 		tool->mmap = process_event_stub;
+	if (tool->mmap2 == NULL)
+		tool->mmap2 = process_event_stub;
 	if (tool->comm == NULL)
 		tool->comm = process_event_stub;
 	if (tool->fork == NULL)
Signature · 1 line
1.7.10.1
#11 lore raw

[tip:perf/urgent] perf tools: Add default handler for mmap2 events

perf tools: Add default handler for mmap2 events
Commit-ID:  6adb0b0ae26fcc35cfec068d71f13863faac5b44
Gitweb:     http://git.kernel.org/tip/6adb0b0ae26fcc35cfec068d71f13863faac5b44
Author:     David Ahern <[email protected]>
AuthorDate: Sun, 22 Sep 2013 19:44:59 -0600
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 4 Oct 2013 15:16:04 -0300

perf tools: Add default handler for mmap2 events

Commands that do not implement an mmap2 handler should at least not die with a segfault when processing files with MMAP2 events.

---
 tools/perf/util/session.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/util/session.c +2 -0
index 70ffa41..37c4718 100644
@@ -256,6 +256,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
 		tool->sample = process_event_sample_stub;
 	if (tool->mmap == NULL)
 		tool->mmap = process_event_stub;
+	if (tool->mmap2 == NULL)
+		tool->mmap2 = process_event_stub;
 	if (tool->comm == NULL)
 		tool->comm = process_event_stub;
 	if (tool->fork == NULL)
#12 lore raw

PATCH 5/5 perf trace: Add beautifier for clock_gettime's clk_id argument - v2

In reply to David Ahern

Before:
0.030 ( 0.002 ms): 2571 clock_gettime(which_clock: 1, tp: 0x7f3b45729cd0 ) = 0

After:
0.030 ( 0.002 ms): 2571 clock_gettime(which_clock: MONOTONIC, tp: 0x7f3b45729cd0 ) = 0

v2: Update to use the STRARRAY option

Cc Adrian Hunter <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/builtin-trace.c |    7 +++++++
 1 file changed, 7 insertions(+)
tools/perf/builtin-trace.c +7 -0
index f61c968..636a506 100644
@@ -280,6 +280,12 @@ static DEFINE_STRARRAY(rlimit_resources);
 static const char *sighow[] = { "BLOCK", "UNBLOCK", "SETMASK", };
 static DEFINE_STRARRAY(sighow);
 
+static const char *clockid[] = {
+	"REALTIME", "MONOTONIC", "PROCESS_CPUTIME_ID", "THREAD_CPUTIME_ID",
+	"MONOTONIC_RAW", "REALTIME_COARSE", "MONOTONIC_COARSE",
+};
+static DEFINE_STRARRAY(clockid);
+
 static const char *socket_families[] = {
 	"UNSPEC", "LOCAL", "INET", "AX25", "IPX", "APPLETALK", "NETROM",
 	"BRIDGE", "ATMPVC", "X25", "INET6", "ROSE", "DECnet", "NETBEUI",
@@ -566,6 +572,7 @@ static struct syscall_fmt {
 	{ .name	    = "arch_prctl", .errmsg = true, .alias = "prctl", },
 	{ .name	    = "brk",	    .hexret = true,
 	  .arg_scnprintf = { [0] = SCA_HEX, /* brk */ }, },
+	{ .name     = "clock_gettime",  .errmsg = true, STRARRAY(0, clk_id, clockid), },
 	{ .name	    = "connect",    .errmsg = true, },
 	{ .name	    = "epoll_ctl",  .errmsg = true, STRARRAY(1, op, epoll_ctl_ops), },
 	{ .name	    = "eventfd2",   .errmsg = true,
Signature · 1 line
1.7.10.1
#13 lore raw

[tip:perf/core] perf trace: Add beautifier for clock_gettime' s clk_id argument

perf trace: Add beautifier for clock_gettime's clk_id argument
Commit-ID:  4f8c1b74c5fdac35ee4480685d42030446724848
Gitweb:     http://git.kernel.org/tip/4f8c1b74c5fdac35ee4480685d42030446724848
Author:     David Ahern <[email protected]>
AuthorDate: Sun, 22 Sep 2013 19:45:00 -0600
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 9 Oct 2013 17:41:42 -0300

perf trace: Add beautifier for clock_gettime's clk_id argument

Before:
0.030 ( 0.002 ms): 2571 clock_gettime(which_clock: 1, tp: 0x7f3b45729cd0 ) = 0

After:
0.030 ( 0.002 ms): 2571 clock_gettime(which_clock: MONOTONIC, tp: 0x7f3b45729cd0 ) = 0

v2: Update to use the STRARRAY option

Cc Adrian Hunter <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/builtin-trace.c | 7 +++++++
 1 file changed, 7 insertions(+)
tools/perf/builtin-trace.c +7 -0
index 76d9427..39a947a 100644
@@ -297,6 +297,12 @@ static DEFINE_STRARRAY(rlimit_resources);
 static const char *sighow[] = { "BLOCK", "UNBLOCK", "SETMASK", };
 static DEFINE_STRARRAY(sighow);
 
+static const char *clockid[] = {
+	"REALTIME", "MONOTONIC", "PROCESS_CPUTIME_ID", "THREAD_CPUTIME_ID",
+	"MONOTONIC_RAW", "REALTIME_COARSE", "MONOTONIC_COARSE",
+};
+static DEFINE_STRARRAY(clockid);
+
 static const char *socket_families[] = {
 	"UNSPEC", "LOCAL", "INET", "AX25", "IPX", "APPLETALK", "NETROM",
 	"BRIDGE", "ATMPVC", "X25", "INET6", "ROSE", "DECnet", "NETBEUI",
@@ -603,6 +609,7 @@ static struct syscall_fmt {
 	{ .name	    = "arch_prctl", .errmsg = true, .alias = "prctl", },
 	{ .name	    = "brk",	    .hexret = true,
 	  .arg_scnprintf = { [0] = SCA_HEX, /* brk */ }, },
+	{ .name     = "clock_gettime",  .errmsg = true, STRARRAY(0, clk_id, clockid), },
 	{ .name	    = "connect",    .errmsg = true, },
 	{ .name	    = "epoll_ctl",  .errmsg = true, STRARRAY(1, op, epoll_ctl_ops), },
 	{ .name	    = "eventfd2",   .errmsg = true,