Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4aa65636 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by Ingo Molnar
Browse files

perf session: Move kmaps to perf_session



There is still some more work to do to disentangle map creation
from DSO loading, but this happens only for the kernel, and for
the early adopters of perf diff, where this disentanglement
matters most, we'll be testing different kernels, so no problem
here.

Further clarification: right now we create the kernel maps for
the various modules and discontiguous kernel text maps when
loading the DSO, we should do it as a two step process, first
creating the maps, for multiple mappings with the same DSO
store, then doing the dso load just once, for the first hit on
one of the maps sharing this DSO backing store.

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1260741029-4430-6-git-send-email-acme@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent b3165f41
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -463,7 +463,7 @@ static struct perf_event_ops event_ops = {
static int __cmd_annotate(void)
static int __cmd_annotate(void)
{
{
	struct perf_session *session = perf_session__new(input_name, O_RDONLY,
	struct perf_session *session = perf_session__new(input_name, O_RDONLY,
							 force);
							 force, &symbol_conf);
	int ret;
	int ret;


	if (session == NULL)
	if (session == NULL)
+2 −2
Original line number Original line Diff line number Diff line
@@ -54,8 +54,8 @@ static int perf_file_section__process_buildids(struct perf_file_section *self,
static int __cmd_buildid_list(void)
static int __cmd_buildid_list(void)
{
{
	int err = -1;
	int err = -1;
	struct perf_session *session = perf_session__new(input_name, O_RDONLY, force);
	struct perf_session *session = perf_session__new(input_name, O_RDONLY,

							 force, NULL);
	if (session == NULL)
	if (session == NULL)
		return -1;
		return -1;


+19 −22
Original line number Original line Diff line number Diff line
@@ -364,19 +364,6 @@ static struct perf_event_ops event_ops = {
	.sample_type_check	= sample_type_check,
	.sample_type_check	= sample_type_check,
};
};


static int read_events(void)
{
	int err;
	struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0);

	if (session == NULL)
		return -ENOMEM;

	err = perf_session__process_events(session, &event_ops);
	perf_session__delete(session);
	return err;
}

static double fragmentation(unsigned long n_req, unsigned long n_alloc)
static double fragmentation(unsigned long n_req, unsigned long n_alloc)
{
{
	if (n_alloc == 0)
	if (n_alloc == 0)
@@ -385,7 +372,8 @@ static double fragmentation(unsigned long n_req, unsigned long n_alloc)
		return 100.0 - (100.0 * n_req / n_alloc);
		return 100.0 - (100.0 * n_req / n_alloc);
}
}


static void __print_result(struct rb_root *root, int n_lines, int is_caller)
static void __print_result(struct rb_root *root, struct perf_session *session,
			   int n_lines, int is_caller)
{
{
	struct rb_node *next;
	struct rb_node *next;


@@ -406,7 +394,7 @@ static void __print_result(struct rb_root *root, int n_lines, int is_caller)
		if (is_caller) {
		if (is_caller) {
			addr = data->call_site;
			addr = data->call_site;
			if (!raw_ip)
			if (!raw_ip)
				sym = map_groups__find_function(kmaps, addr, NULL);
				sym = map_groups__find_function(&session->kmaps, session, addr, NULL);
		} else
		} else
			addr = data->ptr;
			addr = data->ptr;


@@ -447,12 +435,12 @@ static void print_summary(void)
	printf("Cross CPU allocations: %lu/%lu\n", nr_cross_allocs, nr_allocs);
	printf("Cross CPU allocations: %lu/%lu\n", nr_cross_allocs, nr_allocs);
}
}


static void print_result(void)
static void print_result(struct perf_session *session)
{
{
	if (caller_flag)
	if (caller_flag)
		__print_result(&root_caller_sorted, caller_lines, 1);
		__print_result(&root_caller_sorted, session, caller_lines, 1);
	if (alloc_flag)
	if (alloc_flag)
		__print_result(&root_alloc_sorted, alloc_lines, 0);
		__print_result(&root_alloc_sorted, session, alloc_lines, 0);
	print_summary();
	print_summary();
}
}


@@ -520,12 +508,21 @@ static void sort_result(void)


static int __cmd_kmem(void)
static int __cmd_kmem(void)
{
{
	int err;
	struct perf_session *session = perf_session__new(input_name, O_RDONLY,
							 0, NULL);
	if (session == NULL)
		return -ENOMEM;

	setup_pager();
	setup_pager();
	read_events();
	err = perf_session__process_events(session, &event_ops);
	if (err != 0)
		goto out_delete;
	sort_result();
	sort_result();
	print_result();
	print_result(session);

out_delete:
	return 0;
	perf_session__delete(session);
	return err;
}
}


static const char * const kmem_usage[] = {
static const char * const kmem_usage[] = {
+1 −1
Original line number Original line Diff line number Diff line
@@ -442,7 +442,7 @@ static int __cmd_record(int argc, const char **argv)
		exit(-1);
		exit(-1);
	}
	}


	session = perf_session__new(output_name, O_WRONLY, force);
	session = perf_session__new(output_name, O_WRONLY, force, NULL);
	if (session == NULL) {
	if (session == NULL) {
		pr_err("Not enough memory for reading perf file header\n");
		pr_err("Not enough memory for reading perf file header\n");
		return -1;
		return -1;
+8 −6
Original line number Original line Diff line number Diff line
@@ -414,6 +414,7 @@ static int call__match(struct symbol *sym)
}
}


static struct symbol **resolve_callchain(struct thread *thread,
static struct symbol **resolve_callchain(struct thread *thread,
					 struct perf_session *session,
					 struct ip_callchain *chain,
					 struct ip_callchain *chain,
					 struct symbol **parent)
					 struct symbol **parent)
{
{
@@ -447,8 +448,8 @@ static struct symbol **resolve_callchain(struct thread *thread,
			continue;
			continue;
		}
		}


		thread__find_addr_location(thread, cpumode, MAP__FUNCTION,
		thread__find_addr_location(thread, session, cpumode,
					   ip, &al, NULL);
					   MAP__FUNCTION, ip, &al, NULL);
		if (al.sym != NULL) {
		if (al.sym != NULL) {
			if (sort__has_parent && !*parent &&
			if (sort__has_parent && !*parent &&
			    call__match(al.sym))
			    call__match(al.sym))
@@ -467,6 +468,7 @@ static struct symbol **resolve_callchain(struct thread *thread,
 */
 */


static int hist_entry__add(struct addr_location *al,
static int hist_entry__add(struct addr_location *al,
			   struct perf_session *session,
			   struct ip_callchain *chain, u64 count)
			   struct ip_callchain *chain, u64 count)
{
{
	struct symbol **syms = NULL, *parent = NULL;
	struct symbol **syms = NULL, *parent = NULL;
@@ -474,7 +476,7 @@ static int hist_entry__add(struct addr_location *al,
	struct hist_entry *he;
	struct hist_entry *he;


	if ((sort__has_parent || callchain) && chain)
	if ((sort__has_parent || callchain) && chain)
		syms = resolve_callchain(al->thread, chain, &parent);
		syms = resolve_callchain(al->thread, session, chain, &parent);


	he = __hist_entry__add(al, parent, count, &hit);
	he = __hist_entry__add(al, parent, count, &hit);
	if (he == NULL)
	if (he == NULL)
@@ -650,7 +652,7 @@ static int process_sample_event(event_t *event, struct perf_session *session)


	cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
	cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;


	thread__find_addr_location(thread, cpumode,
	thread__find_addr_location(thread, session, cpumode,
				   MAP__FUNCTION, data.ip, &al, NULL);
				   MAP__FUNCTION, data.ip, &al, NULL);
	/*
	/*
	 * We have to do this here as we may have a dso with no symbol hit that
	 * We have to do this here as we may have a dso with no symbol hit that
@@ -669,7 +671,7 @@ static int process_sample_event(event_t *event, struct perf_session *session)
	if (sym_list && al.sym && !strlist__has_entry(sym_list, al.sym->name))
	if (sym_list && al.sym && !strlist__has_entry(sym_list, al.sym->name))
		return 0;
		return 0;


	if (hist_entry__add(&al, data.callchain, data.period)) {
	if (hist_entry__add(&al, session, data.callchain, data.period)) {
		pr_debug("problem incrementing symbol count, skipping event\n");
		pr_debug("problem incrementing symbol count, skipping event\n");
		return -1;
		return -1;
	}
	}
@@ -763,7 +765,7 @@ static int __cmd_report(void)
	int ret;
	int ret;
	struct perf_session *session;
	struct perf_session *session;


	session = perf_session__new(input_name, O_RDONLY, force);
	session = perf_session__new(input_name, O_RDONLY, force, &symbol_conf);
	if (session == NULL)
	if (session == NULL)
		return -ENOMEM;
		return -ENOMEM;


Loading