All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
	David Ahern <dsahern@gmail.com>
Subject: [PATCH 1/2] perf tools: Introduce machines__new/delete()
Date: Thu, 28 May 2015 11:39:03 +0900	[thread overview]
Message-ID: <1432780744-8777-2-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1432780744-8777-1-git-send-email-namhyung@kernel.org>

Create and maintain struct machines in struct perf_tool and pass it to
struct perf_session.  This is a preparation of sharing machines among
sessions in case of multi-thread report.

Suggested-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/builtin-annotate.c      |  5 +++++
 tools/perf/builtin-buildid-cache.c | 14 ++++++++++++--
 tools/perf/builtin-buildid-list.c  | 16 +++++++++++++---
 tools/perf/builtin-diff.c          | 16 ++++++++++++++--
 tools/perf/builtin-evlist.c        | 18 +++++++++++++++---
 tools/perf/builtin-inject.c        |  5 +++++
 tools/perf/builtin-kmem.c          |  4 ++++
 tools/perf/builtin-kvm.c           | 12 ++++++++++++
 tools/perf/builtin-lock.c          |  7 ++++++-
 tools/perf/builtin-mem.c           | 12 +++++++++---
 tools/perf/builtin-record.c        |  8 +++++++-
 tools/perf/builtin-report.c        |  9 ++++++++-
 tools/perf/builtin-sched.c         |  8 +++++++-
 tools/perf/builtin-script.c        | 32 ++++++++++++++++++++++++--------
 tools/perf/builtin-timechart.c     | 12 +++++++++---
 tools/perf/builtin-top.c           | 15 ++++++++++++---
 tools/perf/builtin-trace.c         |  8 +++++++-
 tools/perf/util/data-convert-bt.c  |  8 +++++++-
 tools/perf/util/machine.c          | 15 +++++++++++++++
 tools/perf/util/machine.h          |  3 +++
 tools/perf/util/tool.h             |  2 ++
 21 files changed, 196 insertions(+), 33 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 761f902473b7..e14a8a4d2f8d 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -345,6 +345,10 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	setup_browser(true);
 
+	annotate.tool.machines = machines__new();
+	if (annotate.tool.machines == NULL)
+		return -1;
+
 	annotate.session = perf_session__new(&file, false, &annotate.tool);
 	if (annotate.session == NULL)
 		return -1;
@@ -384,6 +388,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 	 * up we'll get here.
 	 *
 	 * perf_session__delete(session);
+	 * machines__delete(annotate.tool.machines);
 	 */
 	return ret;
 }
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index d47a0cdc71c9..ff3eac1830fc 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -317,6 +317,9 @@ int cmd_buildid_cache(int argc, const char **argv,
 		.mode  = PERF_DATA_MODE_READ,
 	};
 	struct perf_session *session = NULL;
+	struct perf_tool tool = {
+		.machines = NULL,
+	};
 
 	const struct option buildid_cache_options[] = {
 	OPT_STRING('a', "add", &add_name_list_str,
@@ -352,9 +355,14 @@ int cmd_buildid_cache(int argc, const char **argv,
 		file.path = missing_filename;
 		file.force = force;
 
-		session = perf_session__new(&file, false, NULL);
-		if (session == NULL)
+		ret = -1;
+
+		tool.machines = machines__new();
+		if (tool.machines == NULL)
 			return -1;
+		session = perf_session__new(&file, false, &tool);
+		if (session == NULL)
+			goto out;
 	}
 
 	if (symbol__init(session ? &session->header.env : NULL) < 0)
@@ -443,6 +451,8 @@ int cmd_buildid_cache(int argc, const char **argv,
 out:
 	if (session)
 		perf_session__delete(session);
+	if (tool.machines)
+		machines__delete(tool.machines);
 
 	return ret;
 }
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c
index 9fe93c8d4fcf..2ab7d20a30a4 100644
--- a/tools/perf/builtin-buildid-list.c
+++ b/tools/perf/builtin-buildid-list.c
@@ -58,6 +58,8 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
 		.mode  = PERF_DATA_MODE_READ,
 		.force = force,
 	};
+	struct perf_tool *tool = &build_id__mark_dso_hit_ops;
+	int ret = -1;
 
 	symbol__elf_init();
 	/*
@@ -66,10 +68,14 @@ 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(&file, false, &build_id__mark_dso_hit_ops);
-	if (session == NULL)
+	tool->machines = machines__new();
+	if (tool->machines == NULL)
 		return -1;
 
+	session = perf_session__new(&file, false, tool);
+	if (session == NULL)
+		goto out_delete;
+
 	/*
 	 * We take all buildids when the file contains AUX area tracing data
 	 * because we do not decode the trace because it would take too long.
@@ -86,9 +92,13 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
 		perf_session__process_events(session);
 
 	perf_session__fprintf_dsos_buildid(session, stdout, dso__skip_buildid, with_hits);
+	ret = 0;
+
 	perf_session__delete(session);
+out_delete:
+	machines__delete(tool->machines);
 out:
-	return 0;
+	return ret;
 }
 
 int cmd_buildid_list(int argc, const char **argv,
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 0fe54a633a5e..a4431f096697 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -743,10 +743,17 @@ static int __cmd_diff(void)
 	int ret = -EINVAL, i;
 
 	data__for_each_file(i, d) {
+		ret = -ENOMEM;
+
+		tool.machines = machines__new();
+		if (tool.machines == NULL) {
+			pr_err("Failed to allocate machines\n");
+			goto out_delete;
+		}
+
 		d->session = perf_session__new(&d->file, false, &tool);
 		if (!d->session) {
 			pr_err("Failed to open %s\n", d->file.path);
-			ret = -1;
 			goto out_delete;
 		}
 
@@ -763,8 +770,13 @@ static int __cmd_diff(void)
 
  out_delete:
 	data__for_each_file(i, d) {
-		if (d->session)
+		if (d->session) {
+			struct machines *machines = &d->session->machines;
+
 			perf_session__delete(d->session);
+			if (machines)
+				machines__delete(machines);
+		}
 
 		data__free(d);
 	}
diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
index 695ec5a50cf2..d742f987fde2 100644
--- a/tools/perf/builtin-evlist.c
+++ b/tools/perf/builtin-evlist.c
@@ -26,16 +26,28 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
 		.mode = PERF_DATA_MODE_READ,
 		.force = details->force,
 	};
+	struct perf_tool tool = {
+		.machines = NULL,
+	};
+	int ret = -1;
 
-	session = perf_session__new(&file, 0, NULL);
-	if (session == NULL)
+	tool.machines = machines__new();
+	if (tool.machines == NULL)
 		return -1;
 
+	session = perf_session__new(&file, 0, &tool);
+	if (session == NULL)
+		goto out;
+
 	evlist__for_each(session->evlist, pos)
 		perf_evsel__fprintf(pos, details, stdout);
 
+	ret = 0;
+
 	perf_session__delete(session);
-	return 0;
+out:
+	machines__delete(tool.machines);
+	return ret;
 }
 
 int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused)
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 52ec66b23607..4dc8164b4927 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -625,6 +625,10 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	inject.tool.ordered_events = inject.sched_stat;
 
+	inject.tool.machines = machines__new();
+	if (inject.tool.machines == NULL)
+		return -1;
+
 	file.path = inject.input_name;
 	inject.session = perf_session__new(&file, true, &inject.tool);
 	if (inject.session == NULL)
@@ -636,6 +640,7 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
 	ret = __cmd_inject(&inject);
 
 	perf_session__delete(inject.session);
+	machines__delete(inject.tool.machines);
 
 	return ret;
 }
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 254614b10c4a..979a032fe85f 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -1908,6 +1908,9 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	file.path = input_name;
 
+	perf_kmem.machines = machines__new();
+	if (perf_kmem.machines == NULL)
+		return -1;
 	kmem_session = session = perf_session__new(&file, false, &perf_kmem);
 	if (session == NULL)
 		return -1;
@@ -1963,6 +1966,7 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
 
 out_delete:
 	perf_session__delete(session);
+	machines__delete(perf_kmem.machines);
 
 	return ret;
 }
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 15fecd3dc5d8..ca8836392af2 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1053,6 +1053,10 @@ static int read_events(struct perf_kvm_stat *kvm)
 	};
 
 	kvm->tool = eops;
+	kvm->tool.machines = machines__new();
+	if (kvm->tool.machines == NULL)
+		return -1;
+
 	kvm->session = perf_session__new(&file, false, &kvm->tool);
 	if (!kvm->session) {
 		pr_err("Initializing perf session failed\n");
@@ -1381,6 +1385,12 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
 	if (perf_evlist__create_maps(kvm->evlist, &kvm->opts.target) < 0)
 		usage_with_options(live_usage, live_options);
 
+	kvm->tool.machines = machines__new();
+	if (kvm->tool.machines == NULL) {
+		err = -1;
+		goto out;
+	}
+
 	/*
 	 * perf session
 	 */
@@ -1406,6 +1416,8 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
 	if (kvm->session)
 		perf_session__delete(kvm->session);
 	kvm->session = NULL;
+	if (kvm->tool.machines)
+		machines__delete(kvm->tool.machines);
 	if (kvm->evlist)
 		perf_evlist__delete(kvm->evlist);
 
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index de16aaed516e..aa0011f5c0aa 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -866,10 +866,13 @@ static int __cmd_report(bool display_info)
 		.force = force,
 	};
 
+	eops.machines = machines__new();
+	if (eops.machines == NULL)
+		return -1;
 	session = perf_session__new(&file, false, &eops);
 	if (!session) {
 		pr_err("Initializing perf session failed\n");
-		return -1;
+		goto out_delete_machine;
 	}
 
 	symbol__init(&session->header.env);
@@ -899,6 +902,8 @@ static int __cmd_report(bool display_info)
 
 out_delete:
 	perf_session__delete(session);
+out_delete_machine:
+	machines__delete(eops.machines);
 	return err;
 }
 
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index da2ec06f0742..3399907a7d8d 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -126,12 +126,16 @@ static int report_raw_events(struct perf_mem *mem)
 	};
 	int err = -EINVAL;
 	int ret;
-	struct perf_session *session = perf_session__new(&file, false,
-							 &mem->tool);
+	struct perf_session *session;
 
-	if (session == NULL)
+	mem->tool.machines = machines__new();
+	if (mem->tool.machines == NULL)
 		return -1;
 
+	session = perf_session__new(&file, false, &mem->tool);
+	if (session == NULL)
+		goto out_delete_machine;
+
 	if (mem->cpu_list) {
 		ret = perf_session__cpu_bitmap(session, mem->cpu_list,
 					       mem->cpu_bitmap);
@@ -152,6 +156,8 @@ static int report_raw_events(struct perf_mem *mem)
 
 out_delete:
 	perf_session__delete(session);
+out_delete_machine:
+	machines__delete(mem->tool.machines);
 	return err;
 }
 
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 25934b9d368f..7ab67139859b 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -667,10 +667,14 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
 	else
 		signal(SIGUSR2, SIG_IGN);
 
+	tool->machines = machines__new();
+	if (tool->machines == NULL)
+		return -1;
+
 	session = perf_session__new(file, false, tool);
 	if (session == NULL) {
 		pr_err("Perf session creation failed.\n");
-		return -1;
+		goto out_delete_machines;
 	}
 
 	fd = perf_data_file__fd(file);
@@ -929,6 +933,8 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
 
 out_delete_session:
 	perf_session__delete(session);
+out_delete_machines:
+	machines__delete(tool->machines);
 	return status;
 }
 
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 5e53eee5a9a7..8baafb0a561e 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -766,9 +766,13 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 	file.force = report.force;
 
 repeat:
+	report.tool.machines = machines__new();
+	if (report.tool.machines == NULL)
+		return -1;
+
 	session = perf_session__new(&file, false, &report.tool);
 	if (session == NULL)
-		return -1;
+		goto error_delete;
 
 	if (report.queue_size) {
 		ordered_events__set_alloc_size(&session->ordered_events,
@@ -883,11 +887,14 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 	ret = __cmd_report(&report);
 	if (ret == K_SWITCH_INPUT_DATA) {
 		perf_session__delete(session);
+		machines__delete(report.tool.machines);
 		goto repeat;
 	} else
 		ret = 0;
 
 error:
 	perf_session__delete(session);
+error_delete:
+	machines__delete(report.tool.machines);
 	return ret;
 }
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 33962612a5e9..f7cea0460656 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1531,10 +1531,14 @@ static int perf_sched__read_events(struct perf_sched *sched)
 	};
 	int rc = -1;
 
+	sched->tool.machines = machines__new();
+	if (sched->tool.machines == NULL)
+		return -1;
+
 	session = perf_session__new(&file, false, &sched->tool);
 	if (session == NULL) {
 		pr_debug("No Memory for session\n");
-		return -1;
+		goto out_delete_machine;
 	}
 
 	symbol__init(&session->header.env);
@@ -1557,6 +1561,8 @@ static int perf_sched__read_events(struct perf_sched *sched)
 	rc = 0;
 out_delete:
 	perf_session__delete(session);
+out_delete_machine:
+	machines__delete(sched->tool.machines);
 	return rc;
 }
 
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 24809787369f..80f7496e0742 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1388,21 +1388,27 @@ int find_scripts(char **scripts_array, char **scripts_path_array)
 		.path = input_name,
 		.mode = PERF_DATA_MODE_READ,
 	};
+	struct perf_tool tool = {
+		.machines = NULL,
+	};
 	char *temp;
-	int i = 0;
+	int i = -1;
 
-	session = perf_session__new(&file, false, NULL);
-	if (!session)
+	tool.machines = machines__new();
+	if (tool.machines == NULL)
 		return -1;
 
+	session = perf_session__new(&file, false, &tool);
+	if (!session)
+		goto out;
+
 	snprintf(scripts_path, MAXPATHLEN, "%s/scripts", perf_exec_path());
 
 	scripts_dir = opendir(scripts_path);
-	if (!scripts_dir) {
-		perf_session__delete(session);
-		return -1;
-	}
+	if (!scripts_dir)
+		goto out_session;
 
+	i = 0;
 	for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) {
 		snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path,
 			 lang_dirent.d_name);
@@ -1440,7 +1446,11 @@ int find_scripts(char **scripts_array, char **scripts_path_array)
 	}
 
 	closedir(scripts_dir);
+
+out_session:
 	perf_session__delete(session);
+out:
+	machines__delete(tool.machines);
 	return i;
 }
 
@@ -1802,9 +1812,13 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
 	if (!script_name)
 		setup_pager();
 
+	script.tool.machines = machines__new();
+	if (script.tool.machines == NULL)
+		return -1;
+
 	session = perf_session__new(&file, false, &script.tool);
 	if (session == NULL)
-		return -1;
+		goto out_delete_machine;
 
 	if (header || header_only) {
 		perf_session__fprintf_info(session, stdout, show_full_info);
@@ -1890,6 +1904,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
 
 out_delete:
 	perf_session__delete(session);
+out_delete_machine:
+	machines__delete(script.tool.machines);
 
 	if (script_started)
 		cleanup_scripting();
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 30e59620179d..52cac7796014 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -1603,13 +1603,17 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name)
 		.force = tchart->force,
 	};
 
-	struct perf_session *session = perf_session__new(&file, false,
-							 &tchart->tool);
+	struct perf_session *session;
 	int ret = -EINVAL;
 
-	if (session == NULL)
+	tchart->tool.machines = machines__new();
+	if (tchart->tool.machines == NULL)
 		return -1;
 
+	session = perf_session__new(&file, false, &tchart->tool);
+	if (session == NULL)
+		goto out_delete_machine;
+
 	symbol__init(&session->header.env);
 
 	(void)perf_header__process_sections(&session->header,
@@ -1640,6 +1644,8 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name)
 		(tchart->last_time - tchart->first_time) / 1000000000.0, output_name);
 out_delete:
 	perf_session__delete(session);
+out_delete_machine:
+	machines__delete(tchart->tool.machines);
 	return ret;
 }
 
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index ea6e7bd04f9a..9d99bebae955 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -933,12 +933,19 @@ static int __cmd_top(struct perf_top *top)
 {
 	struct record_opts *opts = &top->record_opts;
 	pthread_t thread;
-	int ret;
+	int ret = -1;
+	struct perf_tool tool = {
+		.machines = NULL,
+	};
 
-	top->session = perf_session__new(NULL, false, NULL);
-	if (top->session == NULL)
+	tool.machines = machines__new();
+	if (tool.machines == NULL)
 		return -1;
 
+	top->session = perf_session__new(NULL, false, &tool);
+	if (top->session == NULL)
+		goto out_delete_machine;
+
 	machines__set_symbol_filter(&top->session->machines, symbol_filter);
 
 	if (!objdump_path) {
@@ -1008,6 +1015,8 @@ static int __cmd_top(struct perf_top *top)
 out_delete:
 	perf_session__delete(top->session);
 	top->session = NULL;
+out_delete_machine:
+	machines__delete(tool.machines);
 
 	return ret;
 }
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index e30d0ed1e60f..0e2c60af7cb6 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2413,9 +2413,13 @@ static int trace__replay(struct trace *trace)
 	/* add tid to output */
 	trace->multiple_threads = true;
 
+	trace->tool.machines = machines__new();
+	if (trace->tool.machines == NULL)
+		return -1;
+
 	session = perf_session__new(&file, false, &trace->tool);
 	if (session == NULL)
-		return -1;
+		goto out_delete;
 
 	if (symbol__init(&session->header.env) < 0)
 		goto out;
@@ -2475,6 +2479,8 @@ static int trace__replay(struct trace *trace)
 
 out:
 	perf_session__delete(session);
+out_delete:
+	machines__delete(trace->tool.machines);
 
 	return err;
 }
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index 5bfc1198ab46..270e0298c9f3 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -1133,10 +1133,14 @@ int bt_convert__perf2ctf(const char *input, const char *path, bool force)
 	if (ctf_writer__init(cw, path))
 		return -1;
 
+	c.tool.machines = machines__new();
+	if (c.tool.machines == NULL)
+		goto free_writer;
+
 	/* perf.data session */
 	session = perf_session__new(&file, 0, &c.tool);
 	if (!session)
-		goto free_writer;
+		goto free_machines;
 
 	if (c.queue_size) {
 		ordered_events__set_alloc_size(&session->ordered_events,
@@ -1176,6 +1180,8 @@ int bt_convert__perf2ctf(const char *input, const char *path, bool force)
 
 free_session:
 	perf_session__delete(session);
+free_machines:
+	machines__delete(c.tool.machines);
 free_writer:
 	ctf_writer__cleanup(cw);
 	pr_err("Error during conversion setup.\n");
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 308656be8ddb..d770b705cb16 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -163,6 +163,21 @@ void machines__exit(struct machines *machines)
 	/* XXX exit guest */
 }
 
+struct machines *machines__new(void)
+{
+	struct machines *machines = zalloc(sizeof(*machines));
+
+	if (machines)
+		machines__init(machines);
+	return machines;
+}
+
+void machines__delete(struct machines *machines)
+{
+	machines__exit(machines);
+	free(machines);
+}
+
 struct machine *machines__add(struct machines *machines, pid_t pid,
 			      const char *root_dir)
 {
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index f0f6bd420237..81494371f459 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -102,6 +102,9 @@ struct machines {
 void machines__init(struct machines *machines);
 void machines__exit(struct machines *machines);
 
+struct machines *machines__new(void);
+void machines__delete(struct machines *machines);
+
 void machines__process_guests(struct machines *machines,
 			      machine__process_t process, void *data);
 
diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h
index 7f282ad1d2bd..2d399eba236b 100644
--- a/tools/perf/util/tool.h
+++ b/tools/perf/util/tool.h
@@ -12,6 +12,7 @@ struct perf_evsel;
 struct perf_sample;
 struct perf_tool;
 struct machine;
+struct machines;
 struct ordered_events;
 
 typedef int (*event_sample)(struct perf_tool *tool, union perf_event *event,
@@ -35,6 +36,7 @@ typedef s64 (*event_op3)(struct perf_tool *tool, union perf_event *event,
 			 struct perf_session *session);
 
 struct perf_tool {
+	struct machines *machines;
 	event_sample	sample,
 			read;
 	event_op	mmap,
-- 
2.4.1


  reply	other threads:[~2015-05-28  2:50 UTC|newest]

Thread overview: 221+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18  0:30 [RFC/PATCHSET 00/40] perf tools: Speed-up perf report by using multi thread (v4) Namhyung Kim
2015-05-18  0:30 ` [PATCH 01/40] perf tools: Use a software dummy event to track task/mmap events Namhyung Kim
2015-05-18  0:30 ` [PATCH 02/40] perf tools: Add rm_rf() utility function Namhyung Kim
2015-05-18  0:30 ` [PATCH 03/40] perf tools: Introduce copyfile_offset() function Namhyung Kim
2015-05-18 12:57   ` Arnaldo Carvalho de Melo
2015-05-19  6:20     ` Namhyung Kim
2015-05-20 12:24   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-05-18  0:30 ` [PATCH 04/40] perf tools: Create separate mmap for dummy tracking event Namhyung Kim
2015-05-18 18:07   ` Jiri Olsa
2015-05-19  6:24     ` Namhyung Kim
2015-05-18  0:30 ` [PATCH 05/40] perf tools: Introduce perf_evlist__mmap_track() Namhyung Kim
2015-05-18 18:09   ` Jiri Olsa
2015-05-19  6:28     ` Namhyung Kim
2015-05-18  0:30 ` [PATCH 06/40] perf tools: Add HEADER_DATA_INDEX feature Namhyung Kim
2015-05-18 18:17   ` Jiri Olsa
2015-05-19  6:34     ` Namhyung Kim
2015-05-18  0:30 ` [PATCH 07/40] perf tools: Handle indexed data file properly Namhyung Kim
2015-05-18 18:37   ` Jiri Olsa
2015-05-19  6:40     ` Namhyung Kim
2015-05-18  0:30 ` [PATCH 08/40] perf record: Add --index option for building index table Namhyung Kim
2015-05-18  0:30 ` [PATCH 09/40] perf report: Skip dummy tracking event Namhyung Kim
2015-05-18  0:30 ` [PATCH 10/40] perf tools: Introduce thread__comm(_str)_by_time() helpers Namhyung Kim
2015-05-18  0:30 ` [PATCH 11/40] perf tools: Add a test case for thread comm handling Namhyung Kim
2015-05-18 19:29   ` Jiri Olsa
2015-05-19  6:42     ` Namhyung Kim
2015-05-18  0:30 ` [PATCH 12/40] perf tools: Use thread__comm_by_time() when adding hist entries Namhyung Kim
2015-05-18  0:30 ` [PATCH 13/40] perf tools: Convert dead thread list into rbtree Namhyung Kim
2015-05-18 19:34   ` Jiri Olsa
2015-05-19  6:45     ` Namhyung Kim
2015-05-18  0:30 ` [PATCH 14/40] perf tools: Introduce machine__find*_thread_by_time() Namhyung Kim
2015-05-18 19:50   ` Jiri Olsa
2015-05-18 19:56     ` Jiri Olsa
2015-05-19  6:57     ` Namhyung Kim
2015-05-18  0:30 ` [PATCH 15/40] perf tools: Add a test case for timed thread handling Namhyung Kim
2015-05-18  0:30 ` [PATCH 16/40] perf tools: Reducing arguments of hist_entry_iter__add() Namhyung Kim
2015-05-18 12:55   ` Arnaldo Carvalho de Melo
2015-05-19  7:01     ` Namhyung Kim
2015-05-19  8:04       ` [PATCH] " Namhyung Kim
2015-05-19 14:03         ` Arnaldo Carvalho de Melo
2015-05-27 16:47         ` [tip:perf/core] perf hists: " tip-bot for Namhyung Kim
2015-05-18  0:30 ` [PATCH 17/40] perf tools: Maintain map groups list in a leader thread Namhyung Kim
2015-05-18  0:30 ` [PATCH 18/40] perf tools: Introduce thread__find_addr_location_by_time() and friends Namhyung Kim
2015-05-18  0:30 ` [PATCH 19/40] perf callchain: Use " Namhyung Kim
2015-05-18  0:30 ` [PATCH 20/40] perf tools: Add a test case for timed map groups handling Namhyung Kim
2015-05-18  0:30 ` [PATCH 21/40] perf tools: Save timestamp of a map creation Namhyung Kim
2015-05-18  0:30 ` [PATCH 22/40] perf tools: Introduce map_groups__{insert,find}_by_time() Namhyung Kim
2015-05-18  0:30 ` [PATCH 23/40] perf tools: Use map_groups__find_addr_by_time() Namhyung Kim
2015-05-18  0:30 ` [PATCH 24/40] perf tools: Add testcase for managing maps with time Namhyung Kim
2015-05-18  0:30 ` [PATCH 25/40] perf tools: Protect dso symbol loading using a mutex Namhyung Kim
2015-05-20 12:25   ` [tip:perf/core] perf symbols: " tip-bot for Namhyung Kim
2015-05-18  0:30 ` [PATCH 26/40] perf tools: Protect dso cache tree using dso->lock Namhyung Kim
2015-05-20 12:25   ` [tip:perf/core] perf symbols: Protect dso cache tree using dso-> lock tip-bot for Namhyung Kim
2015-05-18  0:30 ` [PATCH 27/40] perf tools: Protect dso cache fd with a mutex Namhyung Kim
2015-05-20 12:25   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-05-18  0:30 ` [PATCH 28/40] perf callchain: Maintain libunwind's address space in map_groups Namhyung Kim
2015-05-18  0:30 ` [PATCH 29/40] perf tools: Add dso__data_get/put_fd() Namhyung Kim
2015-05-18  0:30 ` [PATCH 30/40] perf session: Pass struct events stats to event processing functions Namhyung Kim
2015-05-18  0:30 ` [PATCH 31/40] perf hists: Pass hists struct to hist_entry_iter struct Namhyung Kim
2015-05-18  0:30 ` [PATCH 32/40] perf tools: Move BUILD_ID_SIZE definition to perf.h Namhyung Kim
2015-05-18  0:30 ` [PATCH 33/40] perf session: Separate struct machines from session Namhyung Kim
2015-05-18 12:52   ` Arnaldo Carvalho de Melo
2015-05-19  7:28     ` Namhyung Kim
2015-05-19 22:46       ` Arnaldo Carvalho de Melo
2015-05-19 23:58         ` Namhyung Kim
2015-05-28  2:39           ` [RFC 0/2] " Namhyung Kim
2015-05-28  2:39             ` Namhyung Kim [this message]
2015-05-28  2:39             ` [PATCH 2/2] " Namhyung Kim
2015-05-18  0:30 ` [PATCH 34/40] perf report: Parallelize perf report using multi-thread Namhyung Kim
2015-05-19 10:12   ` Jiri Olsa
2015-05-19 14:58     ` Namhyung Kim
2015-05-18  0:30 ` [PATCH 35/40] perf record: Synthesize COMM event for a command line workload Namhyung Kim
2015-05-18 12:45   ` Arnaldo Carvalho de Melo
2015-05-19  7:46     ` Namhyung Kim
2015-05-19 14:02       ` Arnaldo Carvalho de Melo
2015-05-19 15:12         ` Namhyung Kim
2015-05-19 16:30           ` Arnaldo Carvalho de Melo
2015-05-19 19:49           ` Jiri Olsa
2015-05-19 20:18             ` Arnaldo Carvalho de Melo
2015-05-19 23:56               ` Namhyung Kim
2015-05-20  0:22                 ` Arnaldo Carvalho de Melo
2015-05-20  0:56                   ` Namhyung Kim
2015-05-20  1:16                     ` Arnaldo Carvalho de Melo
2015-05-18  0:30 ` [PATCH 36/40] perf tools: Fix progress ui to support multi thread Namhyung Kim
2015-05-18  0:30 ` [PATCH 37/40] perf report: Add --multi-thread option and config item Namhyung Kim
2015-05-18  0:30 ` [PATCH 38/40] perf session: Handle index files generally Namhyung Kim
2015-05-19 22:27   ` David Ahern
2015-05-20  0:05     ` Namhyung Kim
2015-05-20  7:20       ` [PATCH 41/40] perf report: Add --num-thread option to control number of thread Namhyung Kim
2015-05-18  0:30 ` [PATCH 39/40] perf data: Implement 'index' subcommand Namhyung Kim
2015-05-18  0:30 ` [PATCH Not-for-merge 40/40] perf tools: Disable thread refcount due to bug Namhyung Kim
2015-05-18  1:23   ` Arnaldo Carvalho de Melo
2015-05-18 12:21     ` Namhyung Kim
2015-05-18 12:30       ` Arnaldo Carvalho de Melo
  -- strict thread matches above, loose matches on Subject: below --
2015-03-03  3:07 [RFC/PATCHSET 00/38] perf tools: Speed-up perf report by using multi thread (v3) Namhyung Kim
2015-03-03  3:07 ` [PATCH 01/38] perf tools: Use a software dummy event to track task/mmap events Namhyung Kim
2015-03-03  3:07 ` [PATCH 02/38] perf tools: Add rm_rf() utility function Namhyung Kim
2015-03-03  3:07 ` [PATCH 03/38] perf tools: Introduce copyfile_offset() function Namhyung Kim
2015-03-04 14:58   ` Jiri Olsa
2015-03-03  3:07 ` [PATCH 04/38] perf tools: Create separate mmap for dummy tracking event Namhyung Kim
2015-03-03  3:07 ` [PATCH 05/38] perf tools: Introduce perf_evlist__mmap_track() Namhyung Kim
2015-03-03  3:07 ` [PATCH 06/38] perf tools: Add HEADER_DATA_INDEX feature Namhyung Kim
2015-03-03  3:07 ` [PATCH 07/38] perf tools: Handle indexed data file properly Namhyung Kim
2015-03-04 16:19   ` Jiri Olsa
2015-03-06  4:17     ` Namhyung Kim
2015-03-03  3:07 ` [PATCH 08/38] perf record: Add --index option for building index table Namhyung Kim
2015-03-05  7:56   ` Jiri Olsa
2015-03-06  4:19     ` Namhyung Kim
2015-03-03  3:07 ` [PATCH 09/38] perf report: Skip dummy tracking event Namhyung Kim
2015-03-03  3:07 ` [PATCH 10/38] perf tools: Pass session arg to perf_event__preprocess_sample() Namhyung Kim
2015-03-03 13:59   ` Arnaldo Carvalho de Melo
2015-03-03 14:18     ` Namhyung Kim
2015-03-03  3:07 ` [PATCH 11/38] perf script: Pass session arg to ->process_event callback Namhyung Kim
2015-03-03  3:07 ` [PATCH 12/38] perf tools: Introduce thread__comm_time() helpers Namhyung Kim
2015-03-03 16:28   ` Frederic Weisbecker
2015-03-04  0:02     ` Namhyung Kim
2015-03-05 16:08       ` Frederic Weisbecker
2015-03-06  4:38         ` Namhyung Kim
2015-03-06 12:48           ` Arnaldo Carvalho de Melo
2015-03-10  6:55             ` Namhyung Kim
2015-03-03  3:07 ` [PATCH 13/38] perf tools: Add a test case for thread comm handling Namhyung Kim
2015-03-03  3:07 ` [PATCH 14/38] perf tools: Use thread__comm_time() when adding hist entries Namhyung Kim
2015-03-03  3:07 ` [PATCH 15/38] perf tools: Convert dead thread list into rbtree Namhyung Kim
2015-03-03  3:07 ` [PATCH 16/38] perf tools: Introduce machine__find*_thread_time() Namhyung Kim
2015-03-03  3:07 ` [PATCH 17/38] perf tools: Add a test case for timed thread handling Namhyung Kim
2015-03-03  3:07 ` [PATCH 18/38] perf tools: Reducing arguments of hist_entry_iter__add() Namhyung Kim
2015-03-03  3:07 ` [PATCH 19/38] perf tools: Pass session to hist_entry_iter struct Namhyung Kim
2015-03-03  3:07 ` [PATCH 20/38] perf tools: Maintain map groups list in a leader thread Namhyung Kim
2015-03-03  3:07 ` [PATCH 21/38] perf tools: Introduce session__find_addr_location() and friends Namhyung Kim
2015-03-03  3:07 ` [PATCH 22/38] perf callchain: Use " Namhyung Kim
2015-03-03 14:01   ` Arnaldo Carvalho de Melo
2015-03-03  3:07 ` [PATCH 23/38] perf tools: Add a test case for timed map groups handling Namhyung Kim
2015-03-03  3:07 ` [PATCH 24/38] perf tools: Protect dso symbol loading using a mutex Namhyung Kim
2015-03-03  3:07 ` [PATCH 25/38] perf tools: Protect dso cache tree using dso->lock Namhyung Kim
2015-03-03  3:07 ` [PATCH 26/38] perf tools: Protect dso cache fd with a mutex Namhyung Kim
2015-03-03  3:07 ` [PATCH 27/38] perf callchain: Maintain libunwind's address space in map_groups Namhyung Kim
2015-03-03  3:07 ` [PATCH 28/38] perf tools: Add dso__data_get/put_fd() Namhyung Kim
2015-03-03  3:07 ` [PATCH 29/38] perf session: Pass struct events stats to event processing functions Namhyung Kim
2015-03-03  3:07 ` [PATCH 30/38] perf hists: Pass hists struct to hist_entry_iter struct Namhyung Kim
2015-03-03  3:07 ` [PATCH 31/38] perf tools: Move BUILD_ID_SIZE definition to perf.h Namhyung Kim
2015-03-03  3:07 ` [PATCH 32/38] perf report: Parallelize perf report using multi-thread Namhyung Kim
2015-03-03  3:07 ` [PATCH 33/38] perf tools: Add missing_threads rb tree Namhyung Kim
2015-03-03  3:07 ` [PATCH 34/38] perf record: Synthesize COMM event for a command line workload Namhyung Kim
2015-03-03  3:07 ` [PATCH 35/38] perf tools: Fix progress ui to support multi thread Namhyung Kim
2015-03-03  3:07 ` [PATCH 36/38] perf report: Add --multi-thread option and config item Namhyung Kim
2015-03-03  3:07 ` [PATCH 37/38] perf session: Handle index files generally Namhyung Kim
2015-03-03  3:07 ` [PATCH 38/38] perf data: Implement 'index' subcommand Namhyung Kim
2015-01-29  8:06 [RFC/PATCHSET 00/42] perf tools: Speed-up perf report by using multi thread (v2) Namhyung Kim
2015-01-29  8:06 ` [PATCH 01/42] perf tools: Support to read compressed module from build-id cache Namhyung Kim
2015-01-30 14:32   ` Jiri Olsa
2015-02-02 15:03     ` Namhyung Kim
2015-01-30 18:33   ` [tip:perf/core] perf symbols: " tip-bot for Namhyung Kim
2015-01-29  8:06 ` [PATCH 02/42] perf tools: Do not use __perf_session__process_events() directly Namhyung Kim
2015-01-30 18:32   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-01-29  8:06 ` [PATCH 03/42] perf record: Show precise number of samples Namhyung Kim
2015-01-30 18:32   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-01-29  8:06 ` [PATCH 04/42] perf header: Set header version correctly Namhyung Kim
2015-01-30 18:33   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-01-29  8:06 ` [PATCH 05/42] perf tools: Set attr.task bit for a tracking event Namhyung Kim
2015-01-30 18:33   ` [tip:perf/core] perf evsel: " tip-bot for Namhyung Kim
2015-01-29  8:06 ` [PATCH 06/42] perf tools: Use a software dummy event to track task/mmap events Namhyung Kim
2015-01-29  8:06 ` [PATCH 07/42] perf tools: Use perf_data_file__fd() consistently Namhyung Kim
2015-01-30 18:33   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-01-29  8:06 ` [PATCH 08/42] perf tools: Add rm_rf() utility function Namhyung Kim
2015-01-30 15:02   ` Jiri Olsa
2015-05-20 12:24     ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-01-29  8:06 ` [PATCH 09/42] perf tools: Introduce copyfile_offset() function Namhyung Kim
2015-01-29  8:06 ` [PATCH 10/42] perf tools: Create separate mmap for dummy tracking event Namhyung Kim
2015-01-29  8:06 ` [PATCH 11/42] perf tools: Introduce perf_evlist__mmap_track() Namhyung Kim
2015-01-29  8:06 ` [PATCH 12/42] perf tools: Add HEADER_DATA_INDEX feature Namhyung Kim
2015-01-29  8:06 ` [PATCH 13/42] perf tools: Handle indexed data file properly Namhyung Kim
2015-01-29  8:06 ` [PATCH 14/42] perf record: Add --index option for building index table Namhyung Kim
2015-02-01 18:06   ` Jiri Olsa
2015-02-02  8:34     ` Adrian Hunter
2015-02-02  9:15       ` Jiri Olsa
2015-02-02  9:52         ` Adrian Hunter
2015-02-02 10:05           ` Jiri Olsa
2015-02-02 12:07             ` Adrian Hunter
2015-02-02 12:13               ` Jiri Olsa
2015-02-02 14:56                 ` Namhyung Kim
2015-02-02 17:30                   ` Jiri Olsa
2015-02-03  8:42                     ` Adrian Hunter
2015-01-29  8:06 ` [PATCH 15/42] perf report: Skip dummy tracking event Namhyung Kim
2015-01-29  8:06 ` [PATCH 16/42] perf tools: Pass session arg to perf_event__preprocess_sample() Namhyung Kim
2015-01-29  8:06 ` [PATCH 17/42] perf script: Pass session arg to ->process_event callback Namhyung Kim
2015-01-29  8:06 ` [PATCH 18/42] perf tools: Introduce thread__comm_time() helpers Namhyung Kim
2015-01-29  8:07 ` [PATCH 19/42] perf tools: Add a test case for thread comm handling Namhyung Kim
2015-01-29  8:07 ` [PATCH 20/42] perf tools: Use thread__comm_time() when adding hist entries Namhyung Kim
2015-01-29  8:07 ` [PATCH 21/42] perf tools: Convert dead thread list into rbtree Namhyung Kim
2015-01-29  8:07 ` [PATCH 22/42] perf tools: Introduce machine__find*_thread_time() Namhyung Kim
2015-01-29  8:07 ` [PATCH 23/42] perf tools: Add a test case for timed thread handling Namhyung Kim
2015-01-29  8:07 ` [PATCH 24/42] perf tools: Maintain map groups list in a leader thread Namhyung Kim
2015-01-29  8:07 ` [PATCH 25/42] perf tools: Introduce thread__find_addr_location_time() and friends Namhyung Kim
2015-01-29  8:07 ` [PATCH 26/42] perf tools: Add a test case for timed map groups handling Namhyung Kim
2015-01-29  8:07 ` [PATCH 27/42] perf tools: Protect dso symbol loading using a mutex Namhyung Kim
2015-01-29 12:34   ` Arnaldo Carvalho de Melo
2015-01-29 12:48     ` Namhyung Kim
2015-01-29  8:07 ` [PATCH 28/42] perf tools: Protect dso cache tree using dso->lock Namhyung Kim
2015-01-29  8:07 ` [PATCH 29/42] perf tools: Protect dso cache fd with a mutex Namhyung Kim
2015-01-29 12:31   ` Arnaldo Carvalho de Melo
2015-01-29 13:19     ` Namhyung Kim
2015-01-29 16:23       ` Arnaldo Carvalho de Melo
2015-01-30  0:51         ` Namhyung Kim
2015-01-29  8:07 ` [PATCH 30/42] perf session: Pass struct events stats to event processing functions Namhyung Kim
2015-01-29  8:07 ` [PATCH 31/42] perf hists: Pass hists struct to hist_entry_iter functions Namhyung Kim
2015-01-29  8:07 ` [PATCH 32/42] perf tools: Move BUILD_ID_SIZE definition to perf.h Namhyung Kim
2015-01-29  8:07 ` [PATCH 33/42] perf report: Parallelize perf report using multi-thread Namhyung Kim
2015-01-29  8:07 ` [PATCH 34/42] perf tools: Add missing_threads rb tree Namhyung Kim
2015-01-29  8:07 ` [PATCH 35/42] perf record: Synthesize COMM event for a command line workload Namhyung Kim
2015-01-29  8:07 ` [PATCH 36/42] perf tools: Fix progress ui to support multi thread Namhyung Kim
2015-01-29  8:07 ` [PATCH 37/42] perf report: Add --multi-thread option and config item Namhyung Kim
2015-01-29  8:07 ` [PATCH 38/42] perf session: Handle index files generally Namhyung Kim
2015-01-29  8:07 ` [PATCH 39/42] perf tools: Convert lseek + read to pread Namhyung Kim
2015-01-30 18:34   ` [tip:perf/core] perf symbols: " tip-bot for Namhyung Kim
2015-01-29  8:07 ` [PATCH 40/42] perf callchain: Save eh/debug frame offset for dwarf unwind Namhyung Kim
2015-01-29 12:38   ` Arnaldo Carvalho de Melo
2015-01-29 13:23     ` Namhyung Kim
2015-01-29 19:22   ` Arnaldo Carvalho de Melo
2015-01-30 18:32   ` [tip:perf/core] perf callchain: Cache eh/ debug " tip-bot for Namhyung Kim
2015-01-29  8:07 ` [PATCH 41/42] perf tools: Add new perf data command Namhyung Kim
2015-01-29  8:07 ` [PATCH 42/42] perf data: Implement 'index' subcommand Namhyung Kim
2015-01-29 19:56 ` [RFC/PATCHSET 00/42] perf tools: Speed-up perf report by using multi thread (v2) Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432780744-8777-2-git-send-email-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=dsahern@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.