Skip to contentSkip to conversation

perf/core improvements and fixes

GIT PULL New Arnaldo Carvalho de Melo 2 participants 8 messages Mar 31, 2015 – Apr 1, 2015 perf events

lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

Hi Ingo,

Please consider pulling,

- Arnaldo

The following changes since commit ccd41c86ad4d464d0ed4e48d80759ff85c2115b0:

perf: Fix racy group access (2015-03-27 09:49:45 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo

for you to fetch changes up to 9870d7809575515e26194f4b3df1750872a6ee60:

perf ordered_samples: Remove references to perf_{evlist,tool} and machines (2015-03-31 17:52:32 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

User visible:

- Fix 'perf script' pipe mode segfault, by always initializing ordered_events in perf_session__new. (Arnaldo Carvalho de Melo)

- Fix ppid for synthesized fork events (David Ahern)

- Fix kernel symbol resolution of callchains in S/390 by remembering the cpumode. (David Hildenbrand)

Infrastructure:

- Disable libbabeltrace check by default in the build system (Jiri Olsa)

----------------------------------------------------------------
Arnaldo Carvalho de Melo (2):
perf session: Always initialize ordered_events
perf ordered_samples: Remove references to perf_{evlist,tool} and machines

David Ahern (2):
perf tools: Refactor comm/tgid lookup perf tools: Fix ppid for synthesized fork events

David Hildenbrand (1):
perf callchain: Fix kernel symbol resolution by remembering the cpumode

Jiri Olsa (1):
perf build: Disable libbabeltrace check by default

 tools/perf/Makefile.perf         |   2 +-
 tools/perf/config/Makefile       |   5 +-
 tools/perf/util/event.c          | 147 ++++++++++++++++++++++++---------------
 tools/perf/util/event.h          |   1 -
 tools/perf/util/machine.c        |  28 ++++----
 tools/perf/util/ordered-events.c |  21 ++----
 tools/perf/util/ordered-events.h |  14 +---
 tools/perf/util/session.c        |  48 ++++++++-----
 tools/perf/util/session.h        |   1 +
 9 files changed, 144 insertions(+), 123 deletions(-)
author maintainer
#1 lore raw

PATCH 1/6 perf build: Disable libbabeltrace check by default

From: Jiri Olsa <[email protected]>

Disabling libbabeltrace check by default and replacing the NO_LIBBABELTRACE make variable with LIBBABELTRACE.

Users wanting the libbabeltrace feature need to build via:

  $ make LIBBABELTRACE=1

The reason for this is that the libababeltrace interface we use (version 1.3) hasn't been packaged/released yet, thus the failing feature check only slows down build and confuses other (non CTF) developers.

Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jeremie Galarneau <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Sebastian Andrzej Siewior <[email protected]>
Cc Tom Zanussi <[email protected]>
Cc Wang Nan <[email protected]>
---
 tools/perf/Makefile.perf   | 2 +-
 tools/perf/config/Makefile | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)
tools/perf/Makefile.perf +1 -1
index e9925e6ad1d0..c43a20517591 100644
@@ -69,7 +69,7 @@ include config/utilities.mak
 #
 # Define NO_ZLIB if you do not want to support compressed kernel modules
 #
-# Define NO_LIBBABELTRACE if you do not want libbabeltrace support
+# Define LIBBABELTRACE if you DO want libbabeltrace support
 # for CTF data format.
 #
 # Define NO_LZMA if you do not want to support compressed (xz) kernel modules
tools/perf/config/Makefile +2 -3
index cd121dfc4de9..59a98c643240 100644
@@ -95,7 +95,7 @@ ifndef NO_LIBELF
   FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) -ldw
 endif
 
-ifndef NO_LIBBABELTRACE
+ifdef LIBBABELTRACE
   # for linking with debug library, run like:
   # make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/
   ifdef LIBBABELTRACE_DIR
@@ -598,7 +598,7 @@ else
   NO_PERF_READ_VDSOX32 := 1
 endif
 
-ifndef NO_LIBBABELTRACE
+ifdef LIBBABELTRACE
   $(call feature_check,libbabeltrace)
   ifeq ($(feature-libbabeltrace), 1)
     CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
@@ -607,7 +607,6 @@ ifndef NO_LIBBABELTRACE
     $(call detected,CONFIG_LIBBABELTRACE)
   else
     msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
-    NO_LIBBABELTRACE := 1
   endif
 endif
 
Signature · 1 line
1.9.3
author maintainer
#2 lore raw

PATCH 2/6 perf callchain: Fix kernel symbol resolution by remembering the cpumode

In reply to Arnaldo Carvalho de Melo

From: David Hildenbrand <[email protected]>

Commit 2e77784bb7d8 ("perf callchain: Move cpumode resolve code to add_callchain_ip") promised "No change in behavior.".

As this commit breaks callchains on s390x (symbols not getting resolved, observed when profiling the kernel), this statement is wrong. The cpumode must be kept when iterating over all ips, otherwise the default (PERF_RECORD_MISC_USER) will be used by error.

Cc Adrian Hunter <[email protected]>
Cc Andi Kleen <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Hendrik Brueckner <[email protected]>
Cc Kan Liang <[email protected]>
Cc Martin Schwidefsky <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 tools/perf/util/machine.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
tools/perf/util/machine.c +14 -14
index e3353307330c..e45c8f33a8fd 100644
@@ -1408,29 +1408,27 @@ struct mem_info *sample__resolve_mem(struct perf_sample *sample,
 static int add_callchain_ip(struct thread *thread,
 			    struct symbol **parent,
 			    struct addr_location *root_al,
-			    bool branch_history,
+			    u8 *cpumode,
 			    u64 ip)
 {
 	struct addr_location al;
 
 	al.filtered = 0;
 	al.sym = NULL;
-	if (branch_history)
+	if (!cpumode) {
 		thread__find_cpumode_addr_location(thread, MAP__FUNCTION,
 						   ip, &al);
-	else {
-		u8 cpumode = PERF_RECORD_MISC_USER;
-
+	} else {
 		if (ip >= PERF_CONTEXT_MAX) {
 			switch (ip) {
 			case PERF_CONTEXT_HV:
-				cpumode = PERF_RECORD_MISC_HYPERVISOR;
+				*cpumode = PERF_RECORD_MISC_HYPERVISOR;
 				break;
 			case PERF_CONTEXT_KERNEL:
-				cpumode = PERF_RECORD_MISC_KERNEL;
+				*cpumode = PERF_RECORD_MISC_KERNEL;
 				break;
 			case PERF_CONTEXT_USER:
-				cpumode = PERF_RECORD_MISC_USER;
+				*cpumode = PERF_RECORD_MISC_USER;
 				break;
 			default:
 				pr_debug("invalid callchain context: "
@@ -1444,8 +1442,8 @@ static int add_callchain_ip(struct thread *thread,
 			}
 			return 0;
 		}
-		thread__find_addr_location(thread, cpumode, MAP__FUNCTION,
-				   ip, &al);
+		thread__find_addr_location(thread, *cpumode, MAP__FUNCTION,
+					   ip, &al);
 	}
 
 	if (al.sym != NULL) {
@@ -1538,6 +1536,7 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
 {
 	struct ip_callchain *chain = sample->callchain;
 	int chain_nr = min(max_stack, (int)chain->nr);
+	u8 cpumode = PERF_RECORD_MISC_USER;
 	int i, j, err;
 	u64 ip;
 
@@ -1584,7 +1583,7 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
 					ip = lbr_stack->entries[0].to;
 			}
 
-			err = add_callchain_ip(thread, parent, root_al, false, ip);
+			err = add_callchain_ip(thread, parent, root_al, &cpumode, ip);
 			if (err)
 				return (err < 0) ? err : 0;
 		}
@@ -1604,6 +1603,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 	struct branch_stack *branch = sample->branch_stack;
 	struct ip_callchain *chain = sample->callchain;
 	int chain_nr = min(max_stack, (int)chain->nr);
+	u8 cpumode = PERF_RECORD_MISC_USER;
 	int i, j, err;
 	int skip_idx = -1;
 	int first_call = 0;
@@ -1669,10 +1669,10 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 
 		for (i = 0; i < nr; i++) {
 			err = add_callchain_ip(thread, parent, root_al,
-					       true, be[i].to);
+					       NULL, be[i].to);
 			if (!err)
 				err = add_callchain_ip(thread, parent, root_al,
-						       true, be[i].from);
+						       NULL, be[i].from);
 			if (err == -EINVAL)
 				break;
 			if (err)
@@ -1701,7 +1701,7 @@ check_calls:
 #endif
 		ip = chain->ips[j];
 
-		err = add_callchain_ip(thread, parent, root_al, false, ip);
+		err = add_callchain_ip(thread, parent, root_al, &cpumode, ip);
 
 		if (err)
 			return (err < 0) ? err : 0;
Signature · 1 line
1.9.3
author maintainer
#3 lore raw

PATCH 3/6 perf tools: Refactor comm/tgid lookup

In reply to Arnaldo Carvalho de Melo

From: David Ahern <[email protected]>

Rather than parsing /proc/pid/status file one line at a time, read it into a buffer in one shot and search for all strings in one pass.

tgid conversion also simplified -- removing the isspace walk. As noted by Arnaldo those are not needed for atoi == strtol calls.

---
 tools/perf/util/event.c | 72 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 44 insertions(+), 28 deletions(-)
tools/perf/util/event.c +44 -28
index d5efa5092ce6..023dd3548a94 100644
@@ -49,48 +49,64 @@ static struct perf_sample synth_sample = {
 	.period	   = 1,
 };
 
+/*
+ * Assumes that the first 4095 bytes of /proc/pid/stat contains
+ * the comm and tgid.
+ */
 static pid_t perf_event__get_comm_tgid(pid_t pid, char *comm, size_t len)
 {
 	char filename[PATH_MAX];
-	char bf[BUFSIZ];
-	FILE *fp;
-	size_t size = 0;
+	char bf[4096];
+	int fd;
+	size_t size = 0, n;
 	pid_t tgid = -1;
+	char *nl, *name, *tgids;
 
 	snprintf(filename, sizeof(filename), "/proc/%d/status", pid);
 
-	fp = fopen(filename, "r");
-	if (fp == NULL) {
+	fd = open(filename, O_RDONLY);
+	if (fd < 0) {
 		pr_debug("couldn't open %s\n", filename);
 		return 0;
 	}
 
-	while (!comm[0] || (tgid < 0)) {
-		if (fgets(bf, sizeof(bf), fp) == NULL) {
-			pr_warning("couldn't get COMM and pgid, malformed %s\n",
-				   filename);
-			break;
-		}
+	n = read(fd, bf, sizeof(bf) - 1);
+	close(fd);
+	if (n <= 0) {
+		pr_warning("Couldn't get COMM and tgid for pid %d\n",
+			   pid);
+		return -1;
+	}
+	bf[n] = '\0';
 
-		if (memcmp(bf, "Name:", 5) == 0) {
-			char *name = bf + 5;
-			while (*name && isspace(*name))
-				++name;
-			size = strlen(name) - 1;
-			if (size >= len)
-				size = len - 1;
-			memcpy(comm, name, size);
-			comm[size] = '\0';
-
-		} else if (memcmp(bf, "Tgid:", 5) == 0) {
-			char *tgids = bf + 5;
-			while (*tgids && isspace(*tgids))
-				++tgids;
-			tgid = atoi(tgids);
-		}
+	name = strstr(bf, "Name:");
+	tgids = strstr(bf, "Tgid:");
+
+	if (name) {
+		name += 5;  /* strlen("Name:") */
+
+		while (*name && isspace(*name))
+			++name;
+
+		nl = strchr(name, '\n');
+		if (nl)
+			*nl = '\0';
+
+		size = strlen(name);
+		if (size >= len)
+			size = len - 1;
+		memcpy(comm, name, size);
+		comm[size] = '\0';
+	} else {
+		pr_debug("Name: string not found for pid %d\n", pid);
 	}
 
-	fclose(fp);
+	if (tgids) {
+		tgids += 5;  /* strlen("Tgid:") */
+		tgid = atoi(tgids);
+	} else {
+		pr_debug("Tgid: string not found for pid %d\n", pid);
+	}
 
 	return tgid;
 }
Signature · 1 line
1.9.3
author maintainer
#4 lore raw

PATCH 4/6 perf tools: Fix ppid for synthesized fork events

In reply to Arnaldo Carvalho de Melo

From: David Ahern <[email protected]>

363b785f38 added synthesized fork events and set a thread's parent id to itself. Since we are already processing /proc/<pid>/status the ppid can be determined properly. Make it so.

---
 tools/perf/util/event.c | 83 +++++++++++++++++++++++++++++--------------------
 1 file changed, 50 insertions(+), 33 deletions(-)
tools/perf/util/event.c +50 -33
index 023dd3548a94..5516236df6ab 100644
@@ -51,29 +51,32 @@ static struct perf_sample synth_sample = {
 
 /*
  * Assumes that the first 4095 bytes of /proc/pid/stat contains
- * the comm and tgid.
+ * the comm, tgid and ppid.
  */
-static pid_t perf_event__get_comm_tgid(pid_t pid, char *comm, size_t len)
+static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len,
+				    pid_t *tgid, pid_t *ppid)
 {
 	char filename[PATH_MAX];
 	char bf[4096];
 	int fd;
 	size_t size = 0, n;
-	pid_t tgid = -1;
-	char *nl, *name, *tgids;
+	char *nl, *name, *tgids, *ppids;
+
+	*tgid = -1;
+	*ppid = -1;
 
 	snprintf(filename, sizeof(filename), "/proc/%d/status", pid);
 
 	fd = open(filename, O_RDONLY);
 	if (fd < 0) {
 		pr_debug("couldn't open %s\n", filename);
-		return 0;
+		return -1;
 	}
 
 	n = read(fd, bf, sizeof(bf) - 1);
 	close(fd);
 	if (n <= 0) {
-		pr_warning("Couldn't get COMM and tgid for pid %d\n",
+		pr_warning("Couldn't get COMM, tigd and ppid for pid %d\n",
 			   pid);
 		return -1;
 	}
@@ -81,6 +84,7 @@ static pid_t perf_event__get_comm_tgid(pid_t pid, char *comm, size_t len)
 
 	name = strstr(bf, "Name:");
 	tgids = strstr(bf, "Tgid:");
+	ppids = strstr(bf, "PPid:");
 
 	if (name) {
 		name += 5;  /* strlen("Name:") */
@@ -103,32 +107,45 @@ static pid_t perf_event__get_comm_tgid(pid_t pid, char *comm, size_t len)
 
 	if (tgids) {
 		tgids += 5;  /* strlen("Tgid:") */
-		tgid = atoi(tgids);
+		*tgid = atoi(tgids);
 	} else {
 		pr_debug("Tgid: string not found for pid %d\n", pid);
 	}
 
-	return tgid;
+	if (ppids) {
+		ppids += 5;  /* strlen("PPid:") */
+		*ppid = atoi(ppids);
+	} else {
+		pr_debug("PPid: string not found for pid %d\n", pid);
+	}
+
+	return 0;
 }
 
-static pid_t perf_event__prepare_comm(union perf_event *event, pid_t pid,
-					 struct machine *machine)
+static int perf_event__prepare_comm(union perf_event *event, pid_t pid,
+				    struct machine *machine,
+				    pid_t *tgid, pid_t *ppid)
 {
 	size_t size;
-	pid_t tgid;
+
+	*ppid = -1;
 
 	memset(&event->comm, 0, sizeof(event->comm));
 
-	if (machine__is_host(machine))
-		tgid = perf_event__get_comm_tgid(pid, event->comm.comm,
-						 sizeof(event->comm.comm));
-	else
-		tgid = machine->pid;
+	if (machine__is_host(machine)) {
+		if (perf_event__get_comm_ids(pid, event->comm.comm,
+					     sizeof(event->comm.comm),
+					     tgid, ppid) != 0) {
+			return -1;
+		}
+	} else {
+		*tgid = machine->pid;
+	}
 
-	if (tgid < 0)
-		goto out;
+	if (*tgid < 0)
+		return -1;
 
-	event->comm.pid = tgid;
+	event->comm.pid = *tgid;
 	event->comm.header.type = PERF_RECORD_COMM;
 
 	size = strlen(event->comm.comm) + 1;
@@ -138,8 +155,8 @@ static pid_t perf_event__prepare_comm(union perf_event *event, pid_t pid,
 				(sizeof(event->comm.comm) - size) +
 				machine->id_hdr_size);
 	event->comm.tid = pid;
-out:
-	return tgid;
+
+	return 0;
 }
 
 static pid_t perf_event__synthesize_comm(struct perf_tool *tool,
@@ -147,27 +164,27 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool,
 					 perf_event__handler_t process,
 					 struct machine *machine)
 {
-	pid_t tgid = perf_event__prepare_comm(event, pid, machine);
+	pid_t tgid, ppid;
 
-	if (tgid == -1)
-		goto out;
+	if (perf_event__prepare_comm(event, pid, machine, &tgid, &ppid) != 0)
+		return -1;
 
 	if (process(tool, event, &synth_sample, machine) != 0)
 		return -1;
 
-out:
 	return tgid;
 }
 
 static int perf_event__synthesize_fork(struct perf_tool *tool,
-				       union perf_event *event, pid_t pid,
-				       pid_t tgid, perf_event__handler_t process,
+				       union perf_event *event,
+				       pid_t pid, pid_t tgid, pid_t ppid,
+				       perf_event__handler_t process,
 				       struct machine *machine)
 {
 	memset(&event->fork, 0, sizeof(event->fork) + machine->id_hdr_size);
 
-	event->fork.ppid = tgid;
-	event->fork.ptid = tgid;
+	event->fork.ppid = ppid;
+	event->fork.ptid = ppid;
 	event->fork.pid  = tgid;
 	event->fork.tid  = pid;
 	event->fork.header.type = PERF_RECORD_FORK;
@@ -359,7 +376,7 @@ static int __event__synthesize_thread(union perf_event *comm_event,
 	char filename[PATH_MAX];
 	DIR *tasks;
 	struct dirent dirent, *next;
-	pid_t tgid;
+	pid_t tgid, ppid;
 
 	/* special case: only send one comm event using passed in pid */
 	if (!full) {
@@ -394,12 +411,12 @@ static int __event__synthesize_thread(union perf_event *comm_event,
 		if (*end)
 			continue;
 
-		tgid = perf_event__prepare_comm(comm_event, _pid, machine);
-		if (tgid == -1)
+		if (perf_event__prepare_comm(comm_event, _pid, machine,
+					     &tgid, &ppid) != 0)
 			return -1;
 
 		if (perf_event__synthesize_fork(tool, fork_event, _pid, tgid,
-						process, machine) < 0)
+						ppid, process, machine) < 0)
 			return -1;
 		/*
 		 * Send the prepared comm event
Signature · 1 line
1.9.3
author maintainer
#5 lore raw

PATCH 5/6 perf session: Always initialize ordered_events

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

Even when it is not used to actually reorder events, some of its fields are used, like session->ordered_events->tool, to shorten function signatures where tool, for instance, was being passed, as the tool is needed for the ordered_events code, we need it there and might as well use it for other perf_session needs.

This fixes a problem where 'perf script' had some condition that made session->ordered_events not to be initialized even with its script->tool ordered_events related flags asking for it to be, which looks like another bug and needs to be investigated further.

Always initializing session->ordered_events at least leaves the current assumptions in place, so do it now.

---
 tools/perf/util/session.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/util/session.c +2 -3
index adf0740c563b..89c66797abe4 100644
@@ -110,6 +110,8 @@ struct perf_session *perf_session__new(struct perf_data_file *file,
 
 	session->repipe = repipe;
 	machines__init(&session->machines);
+	ordered_events__init(&session->ordered_events, &session->machines,
+			     session->evlist, tool, ordered_events__deliver_event);
 
 	if (file) {
 		if (perf_data_file__open(file))
@@ -139,9 +141,6 @@ struct perf_session *perf_session__new(struct perf_data_file *file,
 	    tool->ordered_events && !perf_evlist__sample_id_all(session->evlist)) {
 		dump_printf("WARNING: No sample_id_all support, falling back to unordered processing\n");
 		tool->ordered_events = false;
-	} else {
-		ordered_events__init(&session->ordered_events, &session->machines,
-				     session->evlist, tool, ordered_events__deliver_event);
 	}
 
 	return session;
Signature · 1 line
1.9.3
author maintainer
#6 lore raw

PATCH 6/6 perf ordered_samples: Remove references to perf_{evlist,tool} and machines

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

As these can be obtained from the ordered_events pointer, via container_of, reducing the cross section of ordered_samples.

These were added to ordered_samples in:

commit b7b61cbebd789a3dbca522e3fdb727fe5c95593f
Author: Arnaldo Carvalho de Melo <[email protected]>
Date: Tue Mar 3 11:58:45 2015 -0300

perf ordered_events: Shorten function signatures

By keeping pointers to machines, evlist and tool in ordered_events.

But that was more a transitional patch while moving stuff out from perf_session.c to ordered_events.c and possibly not even needed by then, as we could use the container_of() method and instead of having the nr_unordered_samples stats in events_stats, we can have it in ordered_samples.

---
 tools/perf/util/event.h          |  1 -
 tools/perf/util/ordered-events.c | 21 ++++--------------
 tools/perf/util/ordered-events.h | 14 +++---------
 tools/perf/util/session.c        | 47 +++++++++++++++++++++++++---------------
 tools/perf/util/session.h        |  1 +
 5 files changed, 37 insertions(+), 47 deletions(-)
tools/perf/util/event.h +0 -1
index c4ffe2bd0738..09b9e8d3fcf7 100644
@@ -242,7 +242,6 @@ struct events_stats {
 	u32 nr_invalid_chains;
 	u32 nr_unknown_id;
 	u32 nr_unprocessable_samples;
-	u32 nr_unordered_events;
 };
 
 struct attr_event {
tools/perf/util/ordered-events.c +4 -17
index 6002fa3fcf77..52be201b9b25 100644
@@ -2,7 +2,6 @@
 #include <linux/compiler.h>
 #include <linux/string.h>
 #include "ordered-events.h"
-#include "evlist.h"
 #include "session.h"
 #include "asm/bug.h"
 #include "debug.h"
@@ -167,7 +166,7 @@ int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
 		pr_oe_time(oe->last_flush, "last flush, last_flush_type %d\n",
 			   oe->last_flush_type);
 
-		oe->evlist->stats.nr_unordered_events++;
+		oe->nr_unordered_events++;
 	}
 
 	oevent = ordered_events__new_event(oe, timestamp, event);
@@ -187,7 +186,6 @@ static int __ordered_events__flush(struct ordered_events *oe)
 {
 	struct list_head *head = &oe->events;
 	struct ordered_event *tmp, *iter;
-	struct perf_sample sample;
 	u64 limit = oe->next_flush;
 	u64 last_ts = oe->last ? oe->last->timestamp : 0ULL;
 	bool show_progress = limit == ULLONG_MAX;
@@ -206,15 +204,9 @@ static int __ordered_events__flush(struct ordered_events *oe)
 
 		if (iter->timestamp > limit)
 			break;
-
-		ret = perf_evlist__parse_sample(oe->evlist, iter->event, &sample);
+		ret = oe->deliver(oe, iter);
 		if (ret)
-			pr_err("Can't parse sample, err = %d\n", ret);
-		else {
-			ret = oe->deliver(oe, iter, &sample);
-			if (ret)
-				return ret;
-		}
+			return ret;
 
 		ordered_events__delete(oe, iter);
 		oe->last_flush = iter->timestamp;
@@ -292,18 +284,13 @@ int ordered_events__flush(struct ordered_events *oe, enum oe_flush how)
 	return err;
 }
 
-void ordered_events__init(struct ordered_events *oe, struct machines *machines,
-			  struct perf_evlist *evlist, struct perf_tool *tool,
-			  ordered_events__deliver_t deliver)
+void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver)
 {
 	INIT_LIST_HEAD(&oe->events);
 	INIT_LIST_HEAD(&oe->cache);
 	INIT_LIST_HEAD(&oe->to_free);
 	oe->max_alloc_size = (u64) -1;
 	oe->cur_alloc_size = 0;
-	oe->evlist	   = evlist;
-	oe->machines	   = machines;
-	oe->tool	   = tool;
 	oe->deliver	   = deliver;
 }
 
tools/perf/util/ordered-events.h +3 -11
index 173e13f28c08..f403991e3bfd 100644
@@ -3,10 +3,7 @@
 
 #include <linux/types.h>
 
-struct perf_tool;
-struct perf_evlist;
 struct perf_sample;
-struct machines;
 
 struct ordered_event {
 	u64			timestamp;
@@ -25,8 +22,7 @@ enum oe_flush {
 struct ordered_events;
 
 typedef int (*ordered_events__deliver_t)(struct ordered_events *oe,
-					 struct ordered_event *event,
-					 struct perf_sample *sample);
+					 struct ordered_event *event);
 
 struct ordered_events {
 	u64			last_flush;
@@ -39,13 +35,11 @@ struct ordered_events {
 	struct list_head	to_free;
 	struct ordered_event	*buffer;
 	struct ordered_event	*last;
-	struct machines		*machines;
-	struct perf_evlist	*evlist;
-	struct perf_tool	*tool;
 	ordered_events__deliver_t deliver;
 	int			buffer_idx;
 	unsigned int		nr_events;
 	enum oe_flush		last_flush_type;
+	u32			nr_unordered_events;
 	bool                    copy_on_queue;
 };
 
@@ -53,9 +47,7 @@ int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
 			  struct perf_sample *sample, u64 file_offset);
 void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event);
 int ordered_events__flush(struct ordered_events *oe, enum oe_flush how);
-void ordered_events__init(struct ordered_events *oe, struct machines *machines,
-			  struct perf_evlist *evlsit, struct perf_tool *tool,
-			  ordered_events__deliver_t deliver);
+void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver);
 void ordered_events__free(struct ordered_events *oe);
 
 static inline
tools/perf/util/session.c +29 -18

116 lines not on this page · raw message

tools/perf/util/session.h +1 -0
index 1310998f8318..d5fa7b7916ef 100644
@@ -26,6 +26,7 @@ struct perf_session {
 	u64			one_mmap_offset;
 	struct ordered_events	ordered_events;
 	struct perf_data_file	*file;
+	struct perf_tool	*tool;
 };
 
 #define PRINT_IP_OPT_IP		(1<<0)
Signature · 1 line
1.9.3
#7 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 52 lines · Arnaldo Carvalho de Melo

Hi Ingo,

Please consider pulling,

- Arnaldo

The following changes since commit ccd41c86ad4d464d0ed4e48d80759ff85c2115b0:

perf: Fix racy group access (2015-03-27 09:49:45 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo

for you to fetch changes up to 9870d7809575515e26194f4b3df1750872a6ee60:

perf ordered_samples: Remove references to perf_{evlist,tool} and machines (2015-03-31 17:52:32 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

User visible:

- Fix 'perf script' pipe mode segfault, by always initializing ordered_events in perf_session__new. (Arnaldo Carvalho de Melo)

- Fix ppid for synthesized fork events (David Ahern)

- Fix kernel symbol resolution of callchains in S/390 by remembering the cpumode. (David Hildenbrand)

Infrastructure:

- Disable libbabeltrace check by default in the build system (Jiri Olsa)

----------------------------------------------------------------
Arnaldo Carvalho de Melo (2):
perf session: Always initialize ordered_events
perf ordered_samples: Remove references to perf_{evlist,tool} and machines

David Ahern (2):
perf tools: Refactor comm/tgid lookup perf tools: Fix ppid for synthesized fork events

David Hildenbrand (1):
perf callchain: Fix kernel symbol resolution by remembering the cpumode

Jiri Olsa (1):
perf build: Disable libbabeltrace check by default

Quoted 10 lines
 tools/perf/Makefile.perf         |   2 +-
 tools/perf/config/Makefile       |   5 +-
 tools/perf/util/event.c          | 147 ++++++++++++++++++++++++---------------
 tools/perf/util/event.h          |   1 -
 tools/perf/util/machine.c        |  28 ++++----
 tools/perf/util/ordered-events.c |  21 ++----
 tools/perf/util/ordered-events.h |  14 +---
 tools/perf/util/session.c        |  48 ++++++++-----
 tools/perf/util/session.h        |   1 +
 9 files changed, 144 insertions(+), 123 deletions(-)

Pulled, thanks a lot Arnaldo!

Ingo