All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/2] perf script: Add script per-event-dump support
@ 2017-10-25  8:53 yuzhoujian
  2017-10-25  8:53 ` [PATCH v5 1/2] Add new elements for per-event-dump option yuzhoujian
  2017-10-25  8:53 ` [PATCH v5 2/2] Add the fp_selection_helper to set the fp for print functions yuzhoujian
  0 siblings, 2 replies; 7+ messages in thread
From: yuzhoujian @ 2017-10-25  8:53 UTC (permalink / raw)
  To: peterz, mingo, alexander.shishkin, jolsa, dsahern, namhyung,
	milian.wolff, arnaldo.melo, yuzhoujian, adrian.hunter, wangnan0
  Cc: linux-perf-users, linux-kernel, acme

Introduce a new option to dump trace output to files named by the
monitored events and update perf-script documentation accordingly.

Shown below is output of perf script command with the newly introduced
option.

         $perf record -e cycles -e cs -ag -- sleep 1
         $perf script --per-event-dump
         [ perf script: Wrote 0.051 MB perf.data-script-dump-cycles.txt (76 samples) ]
         [ perf script: Wrote 0.012 MB perf.data-script-dump-cs.txt (69 samples) ]
         $ls
         perf.data-script-dump-cycles.txt perf.data-script-dump-cs.txt

Without per-event-dump support, drawing flamegraphs for different events
would be a very troublesome thing. You can monitor only one event at a time
if you want to get flamegraphs for different events. Using this option, you
can get the trace output files named by the monitored events, and could draw
flamegraphs according to the event's name.

yuzhoujian (4):
Patch 1: Add new elements for per-event-dump option
Patch 2: Add the fp_selection_helper to set the fp for print functions

Changes since v4:
- Patch 1: None
- Patch 2: The fp_selection_helper will be invoked by process_event not process_sample_event 
	   Replace some printf with fprintf in process_event

Changes since v3:
- Patch 1: Remove three elements for perf_evsel struct and create the perf_script_evsel
 struct to save them.
- Patch 2: None
- Patch 3: None
- Patch 4: Free the evsel->priv by zfree().

Changes since v2:
- Patch 1: Add the last_evsel_name for per_tool struct and three elements for perf_evsel struct.
- Patch 2: None
- Patch 3: None
- Patch 4: Remove the file_name and per_event_dump_file variables.
           Add the fp_selection_helper function to select the fp and open the dump file
 for all print functions.
           Close the dump file for all the evsels and calculate the dump file's size at
 the end of the perf script.
           Solve the segmentation fault generated by perf script --per-event-dump --show-mmap-events

Changes since v1:
- Patch 1: Remove the set of script.tool.per_event_dump variable.
- Patch 2: Add the __maybe_unused attribute for the fp argument in the second patch.
- Patch 3: remove the fp_selection_helper function for setting the fp argument.
- Patch 2: split the original second patch(Makes all those related functions receive
 the FILE pointer) to two patches.
- Patch 4: modify the file name of per-event-dump to
 <ORIGINAL PERF DATA FILE NAME>-script-dump-<EVENT NAME>.txt

 tools/perf/builtin-script.c | 110 ++++++++++++++++++++++++++++++++++++--------
 tools/perf/util/evsel.h     |  11 +++++
 tools/perf/util/session.c   |  19 ++++++++
 tools/perf/util/tool.h      |   2 +
 4 files changed, 122 insertions(+), 20 deletions(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v5 1/2] Add new elements for per-event-dump option
  2017-10-25  8:53 [PATCH v5 0/2] perf script: Add script per-event-dump support yuzhoujian
@ 2017-10-25  8:53 ` yuzhoujian
  2017-10-26 13:01   ` Arnaldo Carvalho de Melo
  2017-10-25  8:53 ` [PATCH v5 2/2] Add the fp_selection_helper to set the fp for print functions yuzhoujian
  1 sibling, 1 reply; 7+ messages in thread
From: yuzhoujian @ 2017-10-25  8:53 UTC (permalink / raw)
  To: peterz, mingo, alexander.shishkin, jolsa, dsahern, namhyung,
	milian.wolff, arnaldo.melo, yuzhoujian, adrian.hunter, wangnan0
  Cc: linux-perf-users, linux-kernel, acme

This patch will add two elements for perf_tool struct: per_event_dump
is used to mark the per-event-dump option, last_evsel_name is used
to save last evsel's name. Add a new struct perf_script_evsel to
save evsel's specific data. There are three elements in this new struct:
dump_evsel_fp is used to save the file pointer of the dump_event file,
filename is used to save the file name of the dump_event file, samples
is used to save the number of samples for each evsel. The perf_script_evsel
struct will be saved in the evsel->priv. Add the OPT_BOOLEAN for per-event-dump
in the perf_data_file struct.

Changes since v4:
- none.

Changes since v3:
- remove three elements for perf_evsel struct and create a new struct:
 perf_script_evsel to save them.

Changes since v2:
- add the last_evsel_name for per_tool struct to save last evsel's name.
- add three elements for perf_evsel struct:dump_event_fp is used to save
 the file pointer of the dump_event file, filename is used to save the file
 name of the dump_event file, samples is used to save the number of samples
 for each evsel.

Changes since v1:
- remove the set for script.tool.per_event_dump variable,since the OPT_BOOLEAN
 will do the same thing.

Signed-off-by: yuzhoujian <yuzhoujian@didichuxing.com>
---
 tools/perf/builtin-script.c |  3 +++
 tools/perf/util/evsel.h     | 11 +++++++++++
 tools/perf/util/tool.h      |  2 ++
 3 files changed, 16 insertions(+)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index a3add2c..81f141f 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -2758,6 +2758,7 @@ int cmd_script(int argc, const char **argv)
 			.cpu_map	 = process_cpu_map_event,
 			.ordered_events	 = true,
 			.ordering_requires_timestamps = true,
+			.per_event_dump	 = false,
 		},
 	};
 	struct perf_data_file file = {
@@ -2828,6 +2829,8 @@ int cmd_script(int argc, const char **argv)
 		    "Show context switch events (if recorded)"),
 	OPT_BOOLEAN('\0', "show-namespace-events", &script.show_namespace_events,
 		    "Show namespace events (if recorded)"),
+	OPT_BOOLEAN('\0', "per-event-dump", &script.tool.per_event_dump,
+		    "Dump trace output to files named by the monitored events"),
 	OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
 	OPT_INTEGER(0, "max-blocks", &max_blocks,
 		    "Maximum number of code blocks to dump with brstackinsn"),
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index db65878..abe728d 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -5,6 +5,7 @@
 #include <stdbool.h>
 #include <stddef.h>
 #include <linux/perf_event.h>
+#include <stdio.h>
 #include <linux/types.h>
 #include "xyarray.h"
 #include "symbol.h"
@@ -51,6 +52,16 @@ enum {
 	PERF_EVSEL__CONFIG_TERM_MAX,
 };
 
+/*
+ * The struct perf_script_evsel is used to save the dump file's name,
+ * dump file's fp and the total number of samples for each evsel.
+ */
+struct perf_script_evsel {
+	char 		*filename;
+	FILE		*dump_evsel_fp;
+	unsigned long	samples;
+};
+
 struct perf_evsel_config_term {
 	struct list_head	list;
 	int	type;
diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h
index d549e50..2cbcee4 100644
--- a/tools/perf/util/tool.h
+++ b/tools/perf/util/tool.h
@@ -75,6 +75,8 @@ struct perf_tool {
 	bool		ordered_events;
 	bool		ordering_requires_timestamps;
 	bool		namespace_events;
+	bool		per_event_dump;
+	const char	*last_evsel_name;
 	enum show_feature_header show_feat_hdr;
 };
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v5 2/2] Add the fp_selection_helper to set the fp for print functions
  2017-10-25  8:53 [PATCH v5 0/2] perf script: Add script per-event-dump support yuzhoujian
  2017-10-25  8:53 ` [PATCH v5 1/2] Add new elements for per-event-dump option yuzhoujian
@ 2017-10-25  8:53 ` yuzhoujian
  2017-11-03 14:17   ` [tip:perf/core] perf script: Allow creating per-event dump files tip-bot for Arnaldo Carvalho de Melo
  2017-11-03 14:19   ` [tip:perf/core] perf script: Print information about per-event-dump files tip-bot for Arnaldo Carvalho de Melo
  1 sibling, 2 replies; 7+ messages in thread
From: yuzhoujian @ 2017-10-25  8:53 UTC (permalink / raw)
  To: peterz, mingo, alexander.shishkin, jolsa, dsahern, namhyung,
	milian.wolff, arnaldo.melo, yuzhoujian, adrian.hunter, wangnan0
  Cc: linux-perf-users, linux-kernel, acme

This patch will make all print functions receive the fp, add the fp_selection_helper
function to select the fp(stdout or the dump_event fp) and open the dump file for
all print functions. When the perf script is over, closes the dump_event file and
calculates its size.

Changes since v4:
- the fp_selection_helper will be invoked by process_event not process_sample_event
- replace some printf with fprintf in process_event

Changes since v3:
- free the evsel->priv by zfree()

Changes since v2:
- remove the file_name variable and get the data file name from struct perf_session
- remove the per_event_dump_file variable and get the dump_event fp from struct
 perf_evsel
- add the fp_selection_helper function to select the fp(stdout or the dump_event
 fp) and open the dump file for all print functions if evname and last evsel name is not
 the same.
- close the dump file for all the evsels and calculate the dump file's size at the end of
 the perf script.
- solve the segmentation fault generated by perf script --per-event-dump --show-mmap-events

Changes since v1:
- modify the dump file name to <ORIGINAL PERF DATA FILE NAME>-script-dump-<EVENT NAME>.txt
 ect. perf.data-script-dump-cycles.txt, perf.data-script-dump-cs.txt
- split the original patch(Make all those related functions receive the file pointer)
 to two patches, and this is the second part of the original one.

Signed-off-by: yuzhoujian <yuzhoujian@didichuxing.com>
---
 tools/perf/builtin-script.c | 107 +++++++++++++++++++++++++++++++++++---------
 tools/perf/util/session.c   |  19 ++++++++
 2 files changed, 106 insertions(+), 20 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 81f141f..8d98349 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1431,6 +1431,50 @@ static int data_src__fprintf(u64 data_src, FILE *fp)
 	return fprintf(fp, "%-*s", maxlen, out);
 }
 
+static FILE *fp_selection_helper(struct perf_script *script, struct perf_evsel *evsel)
+{
+	const char *evname;
+	char *filename;
+	FILE *fp;
+	struct perf_tool *tool = &script->tool;
+	struct perf_script_evsel *ps;
+
+	evname = perf_evsel__name(evsel);
+	if (tool->per_event_dump) {
+		ps = (struct perf_script_evsel *)evsel->priv;
+
+		/* if evname and last evsel name is not the same, opens another dump file. */
+		if (evname != tool->last_evsel_name) {
+			if (asprintf(&filename, "%s%s%s%s", script->session->file->path,
+				"-script-dump-", evname, ".txt") < 0)
+				BUG_ON("fail to add the suffix for dump file's name!\n");
+
+			fp = fopen(filename, "a+");
+			if (!fp)
+				BUG_ON("fail to open the dump file!\n");
+
+			if (!ps) {
+				ps = zalloc(sizeof(struct perf_script_evsel));
+				if (!ps)
+					BUG_ON("fail to create a perf_script_evsel struct!\n");
+				ps->samples = 0;
+			}
+			ps->filename = filename;
+			ps->dump_evsel_fp = fp;
+			tool->last_evsel_name = evname;
+			evsel->priv = ps;
+		} else {
+			if (ps->dump_evsel_fp)
+				fp = ps->dump_evsel_fp;
+			else
+				BUG_ON("fail to get the dump file's fp!\n");
+		}
+	} else {
+		fp = stdout;
+	}
+	return fp;
+}
+
 static void process_event(struct perf_script *script,
 			  struct perf_sample *sample, struct perf_evsel *evsel,
 			  struct addr_location *al,
@@ -1439,15 +1483,25 @@ static void process_event(struct perf_script *script,
 	struct thread *thread = al->thread;
 	struct perf_event_attr *attr = &evsel->attr;
 	unsigned int type = output_type(attr->type);
-	FILE *fp = stdout;
+	struct perf_script_evsel *ps;
+	struct perf_tool *tool = &script->tool;
+	FILE *fp;
+
+	fp = fp_selection_helper(script, evsel);
 
 	if (output[type].fields == 0)
 		return;
 
+	if (tool->per_event_dump) {
+		ps = (struct perf_script_evsel *)evsel->priv;
+		ps->samples++;
+		evsel->priv = ps;
+	}
+
 	perf_sample__fprintf_start(sample, thread, evsel, fp);
 
 	if (PRINT_FIELD(PERIOD))
-		printf("%10" PRIu64 " ", sample->period);
+		fprintf(fp, "%10" PRIu64 " ", sample->period);
 
 	if (PRINT_FIELD(EVNAME)) {
 		const char *evname = perf_evsel__name(evsel);
@@ -1455,7 +1509,7 @@ static void process_event(struct perf_script *script,
 		if (!script->name_width)
 			script->name_width = perf_evlist__max_name_len(script->session->evlist);
 
-		printf("%*s: ", script->name_width,
+		fprintf(fp, "%*s: ", script->name_width,
 		       evname ? evname : "[unknown]");
 	}
 
@@ -1513,8 +1567,8 @@ static void process_event(struct perf_script *script,
 	perf_sample__fprintf_insn(sample, attr, thread, machine, fp);
 
 	if (PRINT_FIELD(PHYS_ADDR))
-		printf("%16" PRIx64, sample->phys_addr);
-	printf("\n");
+		fprintf(fp, "%16" PRIx64, sample->phys_addr);
+	fprintf(fp, "\n");
 }
 
 static struct scripting_ops	*scripting_ops;
@@ -1671,6 +1725,7 @@ static int process_comm_event(struct perf_tool *tool,
 	struct perf_script *script = container_of(tool, struct perf_script, tool);
 	struct perf_session *session = script->session;
 	struct perf_evsel *evsel = perf_evlist__id2evsel(session->evlist, sample->id);
+	FILE *fp;
 	int ret = -1;
 
 	thread = machine__findnew_thread(machine, event->comm.pid, event->comm.tid);
@@ -1688,8 +1743,9 @@ static int process_comm_event(struct perf_tool *tool,
 		sample->tid = event->comm.tid;
 		sample->pid = event->comm.pid;
 	}
-	perf_sample__fprintf_start(sample, thread, evsel, stdout);
-	perf_event__fprintf(event, stdout);
+	fp = fp_selection_helper(script, evsel);
+	perf_sample__fprintf_start(sample, thread, evsel, fp);
+	perf_event__fprintf(event, fp);
 	ret = 0;
 out:
 	thread__put(thread);
@@ -1705,6 +1761,7 @@ static int process_namespaces_event(struct perf_tool *tool,
 	struct perf_script *script = container_of(tool, struct perf_script, tool);
 	struct perf_session *session = script->session;
 	struct perf_evsel *evsel = perf_evlist__id2evsel(session->evlist, sample->id);
+	FILE *fp;
 	int ret = -1;
 
 	thread = machine__findnew_thread(machine, event->namespaces.pid,
@@ -1723,8 +1780,9 @@ static int process_namespaces_event(struct perf_tool *tool,
 		sample->tid = event->namespaces.tid;
 		sample->pid = event->namespaces.pid;
 	}
-	perf_sample__fprintf_start(sample, thread, evsel, stdout);
-	perf_event__fprintf(event, stdout);
+	fp = fp_selection_helper(script, evsel);
+	perf_sample__fprintf_start(sample, thread, evsel, fp);
+	perf_event__fprintf(event, fp);
 	ret = 0;
 out:
 	thread__put(thread);
@@ -1740,6 +1798,7 @@ static int process_fork_event(struct perf_tool *tool,
 	struct perf_script *script = container_of(tool, struct perf_script, tool);
 	struct perf_session *session = script->session;
 	struct perf_evsel *evsel = perf_evlist__id2evsel(session->evlist, sample->id);
+	FILE *fp;
 
 	if (perf_event__process_fork(tool, event, sample, machine) < 0)
 		return -1;
@@ -1756,8 +1815,9 @@ static int process_fork_event(struct perf_tool *tool,
 		sample->tid = event->fork.tid;
 		sample->pid = event->fork.pid;
 	}
-	perf_sample__fprintf_start(sample, thread, evsel, stdout);
-	perf_event__fprintf(event, stdout);
+	fp = fp_selection_helper(script, evsel);
+	perf_sample__fprintf_start(sample, thread, evsel, fp);
+	perf_event__fprintf(event, fp);
 	thread__put(thread);
 
 	return 0;
@@ -1772,6 +1832,7 @@ static int process_exit_event(struct perf_tool *tool,
 	struct perf_script *script = container_of(tool, struct perf_script, tool);
 	struct perf_session *session = script->session;
 	struct perf_evsel *evsel = perf_evlist__id2evsel(session->evlist, sample->id);
+	FILE *fp;
 
 	thread = machine__findnew_thread(machine, event->fork.pid, event->fork.tid);
 	if (thread == NULL) {
@@ -1785,8 +1846,9 @@ static int process_exit_event(struct perf_tool *tool,
 		sample->tid = event->fork.tid;
 		sample->pid = event->fork.pid;
 	}
-	perf_sample__fprintf_start(sample, thread, evsel, stdout);
-	perf_event__fprintf(event, stdout);
+	fp = fp_selection_helper(script, evsel);
+	perf_sample__fprintf_start(sample, thread, evsel, fp);
+	perf_event__fprintf(event, fp);
 
 	if (perf_event__process_exit(tool, event, sample, machine) < 0)
 		err = -1;
@@ -1804,6 +1866,7 @@ static int process_mmap_event(struct perf_tool *tool,
 	struct perf_script *script = container_of(tool, struct perf_script, tool);
 	struct perf_session *session = script->session;
 	struct perf_evsel *evsel = perf_evlist__id2evsel(session->evlist, sample->id);
+	FILE *fp;
 
 	if (perf_event__process_mmap(tool, event, sample, machine) < 0)
 		return -1;
@@ -1820,8 +1883,9 @@ static int process_mmap_event(struct perf_tool *tool,
 		sample->tid = event->mmap.tid;
 		sample->pid = event->mmap.pid;
 	}
-	perf_sample__fprintf_start(sample, thread, evsel, stdout);
-	perf_event__fprintf(event, stdout);
+	fp = fp_selection_helper(script, evsel);
+	perf_sample__fprintf_start(sample, thread, evsel, fp);
+	perf_event__fprintf(event, fp);
 	thread__put(thread);
 	return 0;
 }
@@ -1835,6 +1899,7 @@ static int process_mmap2_event(struct perf_tool *tool,
 	struct perf_script *script = container_of(tool, struct perf_script, tool);
 	struct perf_session *session = script->session;
 	struct perf_evsel *evsel = perf_evlist__id2evsel(session->evlist, sample->id);
+	FILE *fp;
 
 	if (perf_event__process_mmap2(tool, event, sample, machine) < 0)
 		return -1;
@@ -1851,8 +1916,9 @@ static int process_mmap2_event(struct perf_tool *tool,
 		sample->tid = event->mmap2.tid;
 		sample->pid = event->mmap2.pid;
 	}
-	perf_sample__fprintf_start(sample, thread, evsel, stdout);
-	perf_event__fprintf(event, stdout);
+	fp = fp_selection_helper(script, evsel);
+	perf_sample__fprintf_start(sample, thread, evsel, fp);
+	perf_event__fprintf(event, fp);
 	thread__put(thread);
 	return 0;
 }
@@ -1866,6 +1932,7 @@ static int process_switch_event(struct perf_tool *tool,
 	struct perf_script *script = container_of(tool, struct perf_script, tool);
 	struct perf_session *session = script->session;
 	struct perf_evsel *evsel = perf_evlist__id2evsel(session->evlist, sample->id);
+	FILE *fp;
 
 	if (perf_event__process_switch(tool, event, sample, machine) < 0)
 		return -1;
@@ -1876,9 +1943,9 @@ static int process_switch_event(struct perf_tool *tool,
 		pr_debug("problem processing SWITCH event, skipping it.\n");
 		return -1;
 	}
-
-	perf_sample__fprintf_start(sample, thread, evsel, stdout);
-	perf_event__fprintf(event, stdout);
+	fp = fp_selection_helper(script, evsel);
+	perf_sample__fprintf_start(sample, thread, evsel, fp);
+	perf_event__fprintf(event, fp);
 	thread__put(thread);
 	return 0;
 }
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index b3fd62f..0a4784f 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -8,6 +8,8 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/mman.h>
+#include <sys/stat.h>
+#include <stdio.h>
 
 #include "evlist.h"
 #include "evsel.h"
@@ -1828,6 +1830,9 @@ static int __perf_session__process_events(struct perf_session *session,
 {
 	struct ordered_events *oe = &session->ordered_events;
 	struct perf_tool *tool = session->tool;
+	struct perf_evlist *evlist = session->evlist;
+	struct perf_evsel *evsel;
+	struct perf_script_evsel *ps;
 	int fd = perf_data_file__fd(session->file);
 	u64 head, page_offset, file_offset, file_pos, size;
 	int err, mmap_prot, mmap_flags, map_idx = 0;
@@ -1835,6 +1840,7 @@ static int __perf_session__process_events(struct perf_session *session,
 	char *buf, *mmaps[NUM_MMAPS];
 	union perf_event *event;
 	struct ui_progress prog;
+	struct stat statbuf;
 	s64 skip;
 
 	perf_tool__fill_defaults(tool);
@@ -1940,6 +1946,19 @@ static int __perf_session__process_events(struct perf_session *session,
 	ordered_events__reinit(&session->ordered_events);
 	auxtrace__free_events(session);
 	session->one_mmap = false;
+	/* Closes the dump_event file and calculates its size at last. */
+	if (tool->per_event_dump) {
+		evlist__for_each_entry(evlist, evsel) {
+			ps = (struct perf_script_evsel *)evsel->priv;
+			if (!ps)
+				BUG_ON("fail to get the perf_script_evsel\n");
+			stat(ps->filename, &statbuf);
+			fprintf(stderr, "[ perf script: Wrote %.3f MB %s (%" PRIu64 " samples) ]\n",
+				statbuf.st_size / 1024.0 / 1024.0, ps->filename, ps->samples);
+			fclose(ps->dump_evsel_fp);
+			zfree(&evsel->priv);
+		}
+	}
 	return err;
 }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v5 1/2] Add new elements for per-event-dump option
  2017-10-25  8:53 ` [PATCH v5 1/2] Add new elements for per-event-dump option yuzhoujian
@ 2017-10-26 13:01   ` Arnaldo Carvalho de Melo
  2017-10-26 13:46     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-10-26 13:01 UTC (permalink / raw)
  To: yuzhoujian
  Cc: peterz, mingo, alexander.shishkin, jolsa, dsahern, namhyung,
	milian.wolff, arnaldo.melo, yuzhoujian, adrian.hunter, wangnan0,
	linux-perf-users, linux-kernel, acme

Em Wed, Oct 25, 2017 at 04:53:18PM +0800, yuzhoujian escreveu:
> This patch will add two elements for perf_tool struct: per_event_dump
> is used to mark the per-event-dump option, last_evsel_name is used
> to save last evsel's name. Add a new struct perf_script_evsel to
> save evsel's specific data. There are three elements in this new struct:
> dump_evsel_fp is used to save the file pointer of the dump_event file,
> filename is used to save the file name of the dump_event file, samples
> is used to save the number of samples for each evsel. The perf_script_evsel
> struct will be saved in the evsel->priv. Add the OPT_BOOLEAN for per-event-dump
> in the perf_data_file struct.
> 
> Changes since v4:
> - none.
> 
> Changes since v3:
> - remove three elements for perf_evsel struct and create a new struct:
>  perf_script_evsel to save them.
> 
> Changes since v2:
> - add the last_evsel_name for per_tool struct to save last evsel's name.
> - add three elements for perf_evsel struct:dump_event_fp is used to save
>  the file pointer of the dump_event file, filename is used to save the file
>  name of the dump_event file, samples is used to save the number of samples
>  for each evsel.
> 
> Changes since v1:
> - remove the set for script.tool.per_event_dump variable,since the OPT_BOOLEAN
>  will do the same thing.
> 
> Signed-off-by: yuzhoujian <yuzhoujian@didichuxing.com>
> ---
>  tools/perf/builtin-script.c |  3 +++
>  tools/perf/util/evsel.h     | 11 +++++++++++
>  tools/perf/util/tool.h      |  2 ++
>  3 files changed, 16 insertions(+)
> 
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index a3add2c..81f141f 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -2758,6 +2758,7 @@ int cmd_script(int argc, const char **argv)
>  			.cpu_map	 = process_cpu_map_event,
>  			.ordered_events	 = true,
>  			.ordering_requires_timestamps = true,
> +			.per_event_dump	 = false,

No need for this, if you simply don't init it, it will be set to false.

>  		},
>  	};
>  	struct perf_data_file file = {
> @@ -2828,6 +2829,8 @@ int cmd_script(int argc, const char **argv)
>  		    "Show context switch events (if recorded)"),
>  	OPT_BOOLEAN('\0', "show-namespace-events", &script.show_namespace_events,
>  		    "Show namespace events (if recorded)"),
> +	OPT_BOOLEAN('\0', "per-event-dump", &script.tool.per_event_dump,
> +		    "Dump trace output to files named by the monitored events"),

this becomes:

+	OPT_BOOLEAN('\0', "per-event-dump", &script.per_event_dump,
+		    "Dump trace output to files named by the monitored events"),

>  	OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
>  	OPT_INTEGER(0, "max-blocks", &max_blocks,
>  		    "Maximum number of code blocks to dump with brstackinsn"),
> diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
> index db65878..abe728d 100644
> --- a/tools/perf/util/evsel.h
> +++ b/tools/perf/util/evsel.h
> @@ -5,6 +5,7 @@
>  #include <stdbool.h>
>  #include <stddef.h>
>  #include <linux/perf_event.h>
> +#include <stdio.h>
>  #include <linux/types.h>
>  #include "xyarray.h"
>  #include "symbol.h"
> @@ -51,6 +52,16 @@ enum {
>  	PERF_EVSEL__CONFIG_TERM_MAX,
>  };
>  
> +/*
> + * The struct perf_script_evsel is used to save the dump file's name,
> + * dump file's fp and the total number of samples for each evsel.
> + */
> +struct perf_script_evsel {
> +	char 		*filename;
> +	FILE		*dump_evsel_fp;
> +	unsigned long	samples;
> +};
> +

Don't pollute evsel.h with things that specific to some tool, this is
not the place to put this.

>  struct perf_evsel_config_term {
>  	struct list_head	list;
>  	int	type;
> diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h
> index d549e50..2cbcee4 100644
> --- a/tools/perf/util/tool.h
> +++ b/tools/perf/util/tool.h
> @@ -75,6 +75,8 @@ struct perf_tool {
>  	bool		ordered_events;
>  	bool		ordering_requires_timestamps;
>  	bool		namespace_events;
> +	bool		per_event_dump;
> +	const char	*last_evsel_name;
>  	enum show_feature_header show_feat_hdr;

Ditto, this should be in struct perf_script.

I'm cooking a patch...

>  };
>  
> -- 
> 1.8.3.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v5 1/2] Add new elements for per-event-dump option
  2017-10-26 13:01   ` Arnaldo Carvalho de Melo
@ 2017-10-26 13:46     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-10-26 13:46 UTC (permalink / raw)
  To: yuzhoujian
  Cc: Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Jiri Olsa,
	David Ahern, Namhyung Kim, Milian Wolff, yuzhoujian,
	Adrian Hunter, Wang Nan, linux-perf-users, linux-kernel

Em Thu, Oct 26, 2017 at 10:01:43AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Wed, Oct 25, 2017 at 04:53:18PM +0800, yuzhoujian escreveu:
> > +	bool		per_event_dump;
> > +	const char	*last_evsel_name;
> >  	enum show_feature_header show_feat_hdr;
 
> Ditto, this should be in struct perf_script.
 
> I'm cooking a patch...

So, please take a look at my perf/core branch, I've reimplemented it the way I
had suggested, should work as you intended, and I added the missing entry to
tools/perf/Documentation/perf-script.txt, its man page:

[root@jouet ~]# mkdir tt
[root@jouet ~]# cd tt
[root@jouet tt]# perf sched record sleep 5
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 4.450 MB perf.data (16177 samples) ]
[root@jouet tt]# perf evlist
sched:sched_switch
sched:sched_stat_wait
sched:sched_stat_sleep
sched:sched_stat_iowait
sched:sched_stat_runtime
sched:sched_process_fork
sched:sched_wakeup
sched:sched_wakeup_new
sched:sched_migrate_task
# Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
[root@jouet tt]# perf script | head
            perf 24359 [003] 203964.311770:       sched:sched_wakeup: perf:24360 [120] success=1 CPU:001
         swapper     0 [001] 203964.311778:       sched:sched_switch: swapper/1:0 [120] R ==> perf:24360 [120]
            perf 24359 [003] 203964.311804: sched:sched_stat_runtime: comm=perf pid=24359 runtime=716900 [ns] vruntime=9190193330 [ns]
            perf 24359 [003] 203964.311806:       sched:sched_switch: perf:24359 [120] S ==> swapper/3:0 [120]
         swapper     0 [000] 203964.312036:       sched:sched_wakeup: chrome:20356 [120] success=1 CPU:000
         swapper     0 [000] 203964.312041:       sched:sched_switch: swapper/0:0 [120] R ==> chrome:20356 [120]
          chrome 20356 [000] 203964.312079: sched:sched_stat_runtime: comm=chrome pid=20356 runtime=39381 [ns] vruntime=7598655260580 [ns]
            perf 24360 [001] 203964.312079: sched:sched_stat_runtime: comm=perf pid=24360 runtime=304174 [ns] vruntime=917028583 [ns]
          chrome 20356 [000] 203964.312086:       sched:sched_wakeup: kworker/0:23:12157 [120] success=1 CPU:000
          chrome 20356 [000] 203964.312096: sched:sched_stat_runtime: comm=chrome pid=20356 runtime=3531 [ns] vruntime=7598655264111 [ns]
[root@jouet tt]# ls
perf.data
[root@jouet tt]# perf script --per-event-dump
[root@jouet tt]# ls
perf.data                                perf.data.sched:sched_stat_runtime.dump  perf.data.sched:sched_wakeup.dump
perf.data.sched:sched_migrate_task.dump  perf.data.sched:sched_stat_sleep.dump    perf.data.sched:sched_wakeup_new.dump
perf.data.sched:sched_process_fork.dump  perf.data.sched:sched_stat_wait.dump
perf.data.sched:sched_stat_iowait.dump   perf.data.sched:sched_switch.dump
[root@jouet tt]# head -5 perf.data.sched:sched_switch.dump
         swapper     0 [001] 203964.311778:       sched:sched_switch: swapper/1:0 [120] R ==> perf:24360 [120]
            perf 24359 [003] 203964.311806:       sched:sched_switch: perf:24359 [120] S ==> swapper/3:0 [120]
         swapper     0 [000] 203964.312041:       sched:sched_switch: swapper/0:0 [120] R ==> chrome:20356 [120]
          chrome 20356 [000] 203964.312097:       sched:sched_switch: chrome:20356 [120] R ==> kworker/0:23:12157 [120]
    kworker/0:23 12157 [000] 203964.312110:       sched:sched_switch: kworker/0:23:12157 [120] t ==> chrome:20356 [120]
[root@jouet tt]# 
[root@jouet tt]# head -5 perf.data.sched:sched_stat_runtime.dump
            perf 24359 [003] 203964.311804: sched:sched_stat_runtime: comm=perf pid=24359 runtime=716900 [ns] vruntime=9190193330 [ns]
          chrome 20356 [000] 203964.312079: sched:sched_stat_runtime: comm=chrome pid=20356 runtime=39381 [ns] vruntime=7598655260580 [ns]
            perf 24360 [001] 203964.312079: sched:sched_stat_runtime: comm=perf pid=24360 runtime=304174 [ns] vruntime=917028583 [ns]
          chrome 20356 [000] 203964.312096: sched:sched_stat_runtime: comm=chrome pid=20356 runtime=3531 [ns] vruntime=7598655264111 [ns]
    kworker/0:23 12157 [000] 203964.312108: sched:sched_stat_runtime: comm=kworker/0:23 pid=12157 runtime=7327 [ns] vruntime=110992086009578 [ns]
[root@jouet tt]# 

- Arnaldo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [tip:perf/core] perf script: Allow creating per-event dump files
  2017-10-25  8:53 ` [PATCH v5 2/2] Add the fp_selection_helper to set the fp for print functions yuzhoujian
@ 2017-11-03 14:17   ` tip-bot for Arnaldo Carvalho de Melo
  2017-11-03 14:19   ` [tip:perf/core] perf script: Print information about per-event-dump files tip-bot for Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 7+ messages in thread
From: tip-bot for Arnaldo Carvalho de Melo @ 2017-11-03 14:17 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: namhyung, yuzhoujian, jolsa, adrian.hunter, hpa, mingo, tglx,
	dsahern, acme, linux-kernel, wangnan0

Commit-ID:  a14390fde64e862c4fe8b92ecb293ee4b12d5bfe
Gitweb:     https://git.kernel.org/tip/a14390fde64e862c4fe8b92ecb293ee4b12d5bfe
Author:     Arnaldo Carvalho de Melo <acme@redhat.com>
AuthorDate: Thu, 26 Oct 2017 10:30:20 -0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 27 Oct 2017 09:10:10 -0300

perf script: Allow creating per-event dump files

Introduce a new option to dump trace output to files named by the
monitored events and update perf-script documentation accordingly.

Shown below is output of perf script command with the newly introduced
option.

         $ perf record -e cycles -e cs -ag -- sleep 1
         $ perf script --per-event-dump
         $ ls
         perf.data.cycles.dump perf.data.cs.dump

Without per-event-dump support, drawing flamegraphs for different events
would require post processing to separate events. You can monitor only
one event at a time if you want to get flamegraphs for different events.
Using this option, you can get the trace output files named by the
monitored events, and could draw flamegraphs according to the event's
name.

Based-on-a-patch-by: yuzhoujian <yuzhoujian@didichuxing.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1508921599-10832-3-git-send-email-yuzhoujian@didichuxing.com
Link: http://lkml.kernel.org/n/tip-8ngzsjdhgiovkupl3r5yy570@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-script.txt |  4 +++
 tools/perf/builtin-script.c              | 59 +++++++++++++++++++++++++++++++-
 2 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index 25e6773..2811fcf 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -325,6 +325,10 @@ include::itrace.txt[]
 	Set the maximum number of program blocks to print with brstackasm for
 	each sample.
 
+--per-event-dump::
+	Create per event files with a "perf.data.EVENT.dump" name instead of
+        printing to stdout, useful, for instance, for generating flamegraphs.
+
 --inline::
 	If a callgraph address belongs to an inlined function, the inline stack
 	will be printed. Each entry has function name and file/line. Enabled by
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index b27f216..fb5e49b 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1392,6 +1392,7 @@ struct perf_script {
 	bool			show_switch_events;
 	bool			show_namespace_events;
 	bool			allocated;
+	bool			per_event_dump;
 	struct cpu_map		*cpus;
 	struct thread_map	*threads;
 	int			name_width;
@@ -1438,7 +1439,7 @@ static void process_event(struct perf_script *script,
 	struct thread *thread = al->thread;
 	struct perf_event_attr *attr = &evsel->attr;
 	unsigned int type = output_type(attr->type);
-	FILE *fp = stdout;
+	FILE *fp = evsel->priv;
 
 	if (output[type].fields == 0)
 		return;
@@ -1887,6 +1888,52 @@ static void sig_handler(int sig __maybe_unused)
 	session_done = 1;
 }
 
+static void perf_script__fclose_per_event_dump(struct perf_script *script)
+{
+	struct perf_evlist *evlist = script->session->evlist;
+	struct perf_evsel *evsel;
+
+	evlist__for_each_entry(evlist, evsel) {
+		if (!evsel->priv)
+			break;
+		fclose(evsel->priv);
+		evsel->priv = NULL;
+	}
+}
+
+static int perf_script__fopen_per_event_dump(struct perf_script *script)
+{
+	struct perf_evsel *evsel;
+
+	evlist__for_each_entry(script->session->evlist, evsel) {
+		char filename[PATH_MAX];
+		snprintf(filename, sizeof(filename), "%s.%s.dump",
+			 script->session->file->path, perf_evsel__name(evsel));
+		evsel->priv = fopen(filename, "w");
+		if (evsel->priv == NULL)
+			goto out_err_fclose;
+	}
+
+	return 0;
+
+out_err_fclose:
+	perf_script__fclose_per_event_dump(script);
+	return -1;
+}
+
+static int perf_script__setup_per_event_dump(struct perf_script *script)
+{
+	struct perf_evsel *evsel;
+
+	if (script->per_event_dump)
+		return perf_script__fopen_per_event_dump(script);
+
+	evlist__for_each_entry(script->session->evlist, evsel)
+		evsel->priv = stdout;
+
+	return 0;
+}
+
 static int __cmd_script(struct perf_script *script)
 {
 	int ret;
@@ -1908,8 +1955,16 @@ static int __cmd_script(struct perf_script *script)
 	if (script->show_namespace_events)
 		script->tool.namespaces = process_namespaces_event;
 
+	if (perf_script__setup_per_event_dump(script)) {
+		pr_err("Couldn't create the per event dump files\n");
+		return -1;
+	}
+
 	ret = perf_session__process_events(script->session);
 
+	if (script->per_event_dump)
+		perf_script__fclose_per_event_dump(script);
+
 	if (debug_mode)
 		pr_err("Misordered timestamps: %" PRIu64 "\n", nr_unordered);
 
@@ -2827,6 +2882,8 @@ int cmd_script(int argc, const char **argv)
 		    "Show context switch events (if recorded)"),
 	OPT_BOOLEAN('\0', "show-namespace-events", &script.show_namespace_events,
 		    "Show namespace events (if recorded)"),
+	OPT_BOOLEAN('\0', "per-event-dump", &script.per_event_dump,
+		    "Dump trace output to files named by the monitored events"),
 	OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
 	OPT_INTEGER(0, "max-blocks", &max_blocks,
 		    "Maximum number of code blocks to dump with brstackinsn"),

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [tip:perf/core] perf script: Print information about per-event-dump files
  2017-10-25  8:53 ` [PATCH v5 2/2] Add the fp_selection_helper to set the fp for print functions yuzhoujian
  2017-11-03 14:17   ` [tip:perf/core] perf script: Allow creating per-event dump files tip-bot for Arnaldo Carvalho de Melo
@ 2017-11-03 14:19   ` tip-bot for Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 7+ messages in thread
From: tip-bot for Arnaldo Carvalho de Melo @ 2017-11-03 14:19 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, yuzhoujian, acme, namhyung, wangnan0, linux-kernel, hpa,
	adrian.hunter, dsahern, jolsa, tglx

Commit-ID:  642ee1c6df4c8571d8a6846a2623fb54f925ef92
Gitweb:     https://git.kernel.org/tip/642ee1c6df4c8571d8a6846a2623fb54f925ef92
Author:     Arnaldo Carvalho de Melo <acme@redhat.com>
AuthorDate: Mon, 30 Oct 2017 13:11:15 -0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 30 Oct 2017 13:11:15 -0300

perf script: Print information about per-event-dump files

For a file generated by "perf sched record sleep 50":

  # perf script --per-event-dump
  [ perf script: Wrote 23.121 MB perf.data.sched:sched_switch.dump (206015 samples) ]
  [ perf script: Wrote 0.000 MB perf.data.sched:sched_stat_wait.dump (0 samples) ]
  [ perf script: Wrote 0.000 MB perf.data.sched:sched_stat_sleep.dump (0 samples) ]
  [ perf script: Wrote 0.000 MB perf.data.sched:sched_stat_iowait.dump (0 samples) ]
  [ perf script: Wrote 17.680 MB perf.data.sched:sched_stat_runtime.dump (129342 samples) ]
  [ perf script: Wrote 0.000 MB perf.data.sched:sched_process_fork.dump (24 samples) ]
  [ perf script: Wrote 11.328 MB perf.data.sched:sched_wakeup.dump (106770 samples) ]
  [ perf script: Wrote 0.000 MB perf.data.sched:sched_wakeup_new.dump (24 samples) ]
  [ perf script: Wrote 2.477 MB perf.data.sched:sched_migrate_task.dump (20434 samples) ]
  #

Similar to what is generated by 'perf record'.

Based-on-a-patch-by: yuzhoujian <yuzhoujian@didichuxing.com>
Suggested-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1508921599-10832-3-git-send-email-yuzhoujian@didichuxing.com
Link: http://lkml.kernel.org/n/tip-xuketkkjuk2c0qz546ypd1u7@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-script.c | 77 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 69 insertions(+), 8 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index fb5e49b..4d198f7 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -210,6 +210,51 @@ static struct {
 	},
 };
 
+struct perf_evsel_script {
+       char *filename;
+       FILE *fp;
+       u64  samples;
+};
+
+static struct perf_evsel_script *perf_evsel_script__new(struct perf_evsel *evsel,
+							struct perf_data_file *file)
+{
+	struct perf_evsel_script *es = malloc(sizeof(*es));
+
+	if (es != NULL) {
+		if (asprintf(&es->filename, "%s.%s.dump", file->path, perf_evsel__name(evsel)) < 0)
+			goto out_free;
+		es->fp = fopen(es->filename, "w");
+		if (es->fp == NULL)
+			goto out_free_filename;
+		es->samples = 0;
+	}
+
+	return es;
+out_free_filename:
+	zfree(&es->filename);
+out_free:
+	free(es);
+	return NULL;
+}
+
+static void perf_evsel_script__delete(struct perf_evsel_script *es)
+{
+	zfree(&es->filename);
+	fclose(es->fp);
+	es->fp = NULL;
+	free(es);
+}
+
+static int perf_evsel_script__fprintf(struct perf_evsel_script *es, FILE *fp)
+{
+	struct stat st;
+
+	fstat(fileno(es->fp), &st);
+	return fprintf(fp, "[ perf script: Wrote %.3f MB %s (%" PRIu64 " samples) ]\n",
+		       st.st_size / 1024.0 / 1024.0, es->filename, es->samples);
+}
+
 static inline int output_type(unsigned int type)
 {
 	switch (type) {
@@ -1439,11 +1484,14 @@ static void process_event(struct perf_script *script,
 	struct thread *thread = al->thread;
 	struct perf_event_attr *attr = &evsel->attr;
 	unsigned int type = output_type(attr->type);
-	FILE *fp = evsel->priv;
+	struct perf_evsel_script *es = evsel->priv;
+	FILE *fp = es->fp;
 
 	if (output[type].fields == 0)
 		return;
 
+	++es->samples;
+
 	perf_sample__fprintf_start(sample, thread, evsel, fp);
 
 	if (PRINT_FIELD(PERIOD))
@@ -1896,7 +1944,7 @@ static void perf_script__fclose_per_event_dump(struct perf_script *script)
 	evlist__for_each_entry(evlist, evsel) {
 		if (!evsel->priv)
 			break;
-		fclose(evsel->priv);
+		perf_evsel_script__delete(evsel->priv);
 		evsel->priv = NULL;
 	}
 }
@@ -1906,10 +1954,7 @@ static int perf_script__fopen_per_event_dump(struct perf_script *script)
 	struct perf_evsel *evsel;
 
 	evlist__for_each_entry(script->session->evlist, evsel) {
-		char filename[PATH_MAX];
-		snprintf(filename, sizeof(filename), "%s.%s.dump",
-			 script->session->file->path, perf_evsel__name(evsel));
-		evsel->priv = fopen(filename, "w");
+		evsel->priv = perf_evsel_script__new(evsel, script->session->file);
 		if (evsel->priv == NULL)
 			goto out_err_fclose;
 	}
@@ -1924,16 +1969,32 @@ out_err_fclose:
 static int perf_script__setup_per_event_dump(struct perf_script *script)
 {
 	struct perf_evsel *evsel;
+	static struct perf_evsel_script es_stdout;
 
 	if (script->per_event_dump)
 		return perf_script__fopen_per_event_dump(script);
 
+	es_stdout.fp = stdout;
+
 	evlist__for_each_entry(script->session->evlist, evsel)
-		evsel->priv = stdout;
+		evsel->priv = &es_stdout;
 
 	return 0;
 }
 
+static void perf_script__exit_per_event_dump_stats(struct perf_script *script)
+{
+	struct perf_evsel *evsel;
+
+	evlist__for_each_entry(script->session->evlist, evsel) {
+		struct perf_evsel_script *es = evsel->priv;
+
+		perf_evsel_script__fprintf(es, stdout);
+		perf_evsel_script__delete(es);
+		evsel->priv = NULL;
+	}
+}
+
 static int __cmd_script(struct perf_script *script)
 {
 	int ret;
@@ -1963,7 +2024,7 @@ static int __cmd_script(struct perf_script *script)
 	ret = perf_session__process_events(script->session);
 
 	if (script->per_event_dump)
-		perf_script__fclose_per_event_dump(script);
+		perf_script__exit_per_event_dump_stats(script);
 
 	if (debug_mode)
 		pr_err("Misordered timestamps: %" PRIu64 "\n", nr_unordered);

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-11-03 14:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-25  8:53 [PATCH v5 0/2] perf script: Add script per-event-dump support yuzhoujian
2017-10-25  8:53 ` [PATCH v5 1/2] Add new elements for per-event-dump option yuzhoujian
2017-10-26 13:01   ` Arnaldo Carvalho de Melo
2017-10-26 13:46     ` Arnaldo Carvalho de Melo
2017-10-25  8:53 ` [PATCH v5 2/2] Add the fp_selection_helper to set the fp for print functions yuzhoujian
2017-11-03 14:17   ` [tip:perf/core] perf script: Allow creating per-event dump files tip-bot for Arnaldo Carvalho de Melo
2017-11-03 14:19   ` [tip:perf/core] perf script: Print information about per-event-dump files tip-bot for Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.