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

Commit 93d5731d authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by Jiri Olsa
Browse files

perf tools: Allocate thread map_groups's dynamically



Moving towards sharing map groups within a process threads.

Because of this we need the map groups to be dynamically allocated. No
other functional change is intended in here.

Based on a patch by Jiri Olsa, but this time _just_ making the
conversion from statically allocating thread->mg to turning it into a
pointer and instead of initializing it at thread's constructor,
introduce a constructor/destructor for the map_groups class and
call at thread creation time.

Later we will introduce the get/put methods when we move to sharing
those map_groups, when the get/put refcounting semantics will be needed.

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@kernel.org>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1397490723-1992-3-git-send-email-jolsa@redhat.com


Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
parent 4e85edfc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ static int sample_ustack(struct perf_sample *sample,

	sp = (unsigned long) regs[PERF_REG_X86_SP];

	map = map_groups__find(&thread->mg, MAP__FUNCTION, (u64) sp);
	map = map_groups__find(thread->mg, MAP__FUNCTION, (u64) sp);
	if (!map) {
		pr_debug("failed to get stack map\n");
		free(buf);
+1 −1
Original line number Diff line number Diff line
@@ -495,7 +495,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
			break;

		if (h->ms.map == NULL && verbose > 1) {
			__map_groups__fprintf_maps(&h->thread->mg,
			__map_groups__fprintf_maps(h->thread->mg,
						   MAP__FUNCTION, verbose, fp);
			fprintf(fp, "%.10s end\n", graph_dotted_line);
		}
+1 −1
Original line number Diff line number Diff line
@@ -699,7 +699,7 @@ void thread__find_addr_map(struct thread *thread,
			   enum map_type type, u64 addr,
			   struct addr_location *al)
{
	struct map_groups *mg = &thread->mg;
	struct map_groups *mg = thread->mg;
	bool load_map = false;

	al->machine = machine;
+16 −0
Original line number Diff line number Diff line
@@ -358,6 +358,22 @@ void map_groups__exit(struct map_groups *mg)
	}
}

struct map_groups *map_groups__new(void)
{
	struct map_groups *mg = malloc(sizeof(*mg));

	if (mg != NULL)
		map_groups__init(mg);

	return mg;
}

void map_groups__delete(struct map_groups *mg)
{
	map_groups__exit(mg);
	free(mg);
}

void map_groups__flush(struct map_groups *mg)
{
	int type;
+3 −0
Original line number Diff line number Diff line
@@ -61,6 +61,9 @@ struct map_groups {
	struct machine	 *machine;
};

struct map_groups *map_groups__new(void);
void map_groups__delete(struct map_groups *mg);

static inline struct kmap *map__kmap(struct map *map)
{
	return (struct kmap *)(map + 1);
Loading