Commit 876650e6 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

perf machine: Introduce struct machines

That consolidates the grouping of host + guests, isolating a bit more of
functionality now centered on 'perf_session' that can be used
independently in tools that don't need a 'perf_session' instance, but
needs to have all the thread/map/symbol machinery.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-c700rsiphpmzv8klogojpfut@git.kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 28a6b6aa
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -571,7 +571,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
		       "Check /proc/modules permission or run as root.\n");

	if (perf_guest) {
		machines__process(&session->machines,
		machines__process_guests(&session->machines,
					 perf_event__synthesize_guest_os, tool);
	}

+1 −1
Original line number Diff line number Diff line
@@ -372,7 +372,7 @@ static int __cmd_report(struct perf_report *rep)
	if (ret)
		goto out_delete;

	kernel_map = session->host_machine.vmlinux_maps[MAP__FUNCTION];
	kernel_map = session->machines.host.vmlinux_maps[MAP__FUNCTION];
	kernel_kmap = map__kmap(kernel_map);
	if (kernel_map == NULL ||
	    (kernel_map->dso->hit &&
+2 −2
Original line number Diff line number Diff line
@@ -966,10 +966,10 @@ static int __cmd_top(struct perf_top *top)
	if (perf_target__has_task(&opts->target))
		perf_event__synthesize_thread_map(&top->tool, top->evlist->threads,
						  perf_event__process,
						  &top->session->host_machine);
						  &top->session->machines.host);
	else
		perf_event__synthesize_threads(&top->tool, perf_event__process,
					       &top->session->host_machine);
					       &top->session->machines.host);
	perf_top__start_counters(top);
	top->session->evlist = top->evlist;
	perf_session__set_id_hdr_size(top->session);
+7 −10
Original line number Diff line number Diff line
@@ -75,13 +75,11 @@ static struct {
	{ "[kernel]", kernel_syms, ARRAY_SIZE(kernel_syms) },
};

static struct machine *setup_fake_machine(void)
static struct machine *setup_fake_machine(struct machines *machines)
{
	struct rb_root machine_root = RB_ROOT;
	struct machine *machine;
	struct machine *machine = machines__find(machines, HOST_KERNEL_ID);
	size_t i;

	machine = machines__findnew(&machine_root, HOST_KERNEL_ID);
	if (machine == NULL) {
		pr_debug("Not enough memory for machine setup\n");
		return NULL;
@@ -435,6 +433,7 @@ static void print_hists(struct hists *hists)
int test__hists_link(void)
{
	int err = -1;
	struct machines machines;
	struct machine *machine = NULL;
	struct perf_evsel *evsel, *first;
        struct perf_evlist *evlist = perf_evlist__new(NULL, NULL);
@@ -452,8 +451,10 @@ int test__hists_link(void)
	/* default sort order (comm,dso,sym) will be used */
	setup_sorting(NULL, NULL);

	machines__init(&machines);

	/* setup threads/dso/map/symbols also */
	machine = setup_fake_machine();
	machine = setup_fake_machine(&machines);
	if (!machine)
		goto out;

@@ -492,11 +493,7 @@ int test__hists_link(void)
out:
	/* tear down everything */
	perf_evlist__delete(evlist);

	if (machine) {
		machine__delete_threads(machine);
		machine__delete(machine);
	}
	machines__exit(&machines);

	return err;
}
+6 −6
Original line number Diff line number Diff line
@@ -287,12 +287,12 @@ static int dsos__write_buildid_table(struct perf_header *header, int fd)
	struct perf_session *session = container_of(header,
			struct perf_session, header);
	struct rb_node *nd;
	int err = machine__write_buildid_table(&session->host_machine, fd);
	int err = machine__write_buildid_table(&session->machines.host, fd);

	if (err)
		return err;

	for (nd = rb_first(&session->machines); nd; nd = rb_next(nd)) {
	for (nd = rb_first(&session->machines.guests); nd; nd = rb_next(nd)) {
		struct machine *pos = rb_entry(nd, struct machine, rb_node);
		err = machine__write_buildid_table(pos, fd);
		if (err)
@@ -448,9 +448,9 @@ static int perf_session__cache_build_ids(struct perf_session *session)
	if (mkdir(debugdir, 0755) != 0 && errno != EEXIST)
		return -1;

	ret = machine__cache_build_ids(&session->host_machine, debugdir);
	ret = machine__cache_build_ids(&session->machines.host, debugdir);

	for (nd = rb_first(&session->machines); nd; nd = rb_next(nd)) {
	for (nd = rb_first(&session->machines.guests); nd; nd = rb_next(nd)) {
		struct machine *pos = rb_entry(nd, struct machine, rb_node);
		ret |= machine__cache_build_ids(pos, debugdir);
	}
@@ -467,9 +467,9 @@ static bool machine__read_build_ids(struct machine *machine, bool with_hits)
static bool perf_session__read_build_ids(struct perf_session *session, bool with_hits)
{
	struct rb_node *nd;
	bool ret = machine__read_build_ids(&session->host_machine, with_hits);
	bool ret = machine__read_build_ids(&session->machines.host, with_hits);

	for (nd = rb_first(&session->machines); nd; nd = rb_next(nd)) {
	for (nd = rb_first(&session->machines.guests); nd; nd = rb_next(nd)) {
		struct machine *pos = rb_entry(nd, struct machine, rb_node);
		ret |= machine__read_build_ids(pos, with_hits);
	}
Loading