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

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

perf thread: Introduce thread__find_map()

Out of thread__find_add_map(..., MAP__FUNCTION, ...), idea here is to
continue removing references to MAP__{FUNCTION,VARIABLE} ahead of
getting both types of symbols in the same rbtree, as various places do
two lookups, looking first at MAP__FUNCTION, then at MAP__VARIABLE.

So thread__find_map() will eventually do just that, and 'struct symbol'
will have the symbol type, for code that cares about that.

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: https://lkml.kernel.org/n/tip-q27xee34l4izpfau49w103s6@git.kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e94b861a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -440,7 +440,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool,
		goto repipe;
	}

	thread__find_addr_map(thread, sample->cpumode, MAP__FUNCTION, sample->ip, &al);
	thread__find_map(thread, sample->cpumode, sample->ip, &al);

	if (al.map != NULL) {
		if (!al.map->dso->hit) {
+9 −10
Original line number Diff line number Diff line
@@ -717,8 +717,8 @@ static int perf_sample__fprintf_brstack(struct perf_sample *sample,
		if (PRINT_FIELD(DSO)) {
			memset(&alf, 0, sizeof(alf));
			memset(&alt, 0, sizeof(alt));
			thread__find_addr_map(thread, sample->cpumode, MAP__FUNCTION, from, &alf);
			thread__find_addr_map(thread, sample->cpumode, MAP__FUNCTION, to, &alt);
			thread__find_map(thread, sample->cpumode, from, &alf);
			thread__find_map(thread, sample->cpumode, to, &alt);
		}

		printed += fprintf(fp, " 0x%"PRIx64, from);
@@ -764,11 +764,11 @@ static int perf_sample__fprintf_brstacksym(struct perf_sample *sample,
		from = br->entries[i].from;
		to   = br->entries[i].to;

		thread__find_addr_map(thread, sample->cpumode, MAP__FUNCTION, from, &alf);
		thread__find_map(thread, sample->cpumode, from, &alf);
		if (alf.map)
			alf.sym = map__find_symbol(alf.map, alf.addr);

		thread__find_addr_map(thread, sample->cpumode, MAP__FUNCTION, to, &alt);
		thread__find_map(thread, sample->cpumode, to, &alt);
		if (alt.map)
			alt.sym = map__find_symbol(alt.map, alt.addr);

@@ -814,11 +814,11 @@ static int perf_sample__fprintf_brstackoff(struct perf_sample *sample,
		from = br->entries[i].from;
		to   = br->entries[i].to;

		thread__find_addr_map(thread, sample->cpumode, MAP__FUNCTION, from, &alf);
		thread__find_map(thread, sample->cpumode, from, &alf);
		if (alf.map && !alf.map->dso->adjust_symbols)
			from = map__map_ip(alf.map, from);

		thread__find_addr_map(thread, sample->cpumode, MAP__FUNCTION, to, &alt);
		thread__find_map(thread, sample->cpumode, to, &alt);
		if (alt.map && !alt.map->dso->adjust_symbols)
			to = map__map_ip(alt.map, to);

@@ -882,7 +882,7 @@ static int grab_bb(u8 *buffer, u64 start, u64 end,
		return 0;
	}

	thread__find_addr_map(thread, *cpumode, MAP__FUNCTION, start, &al);
	thread__find_map(thread, *cpumode, start, &al);
	if (!al.map || !al.map->dso) {
		pr_debug("\tcannot resolve %" PRIx64 "-%" PRIx64 "\n", start, end);
		return 0;
@@ -933,10 +933,9 @@ static int ip__fprintf_sym(uint64_t addr, struct thread *thread,

	memset(&al, 0, sizeof(al));

	thread__find_addr_map(thread, cpumode, MAP__FUNCTION, addr, &al);
	thread__find_map(thread, cpumode, addr, &al);
	if (!al.map)
		thread__find_addr_map(thread, cpumode, MAP__VARIABLE,
				      addr, &al);
		__thread__find_map(thread, cpumode, MAP__VARIABLE, addr, &al);
	if ((*lastsym) && al.addr >= (*lastsym)->start && al.addr < (*lastsym)->end)
		return 0;

+2 −2
Original line number Diff line number Diff line
@@ -236,14 +236,14 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,

	pr_debug("Reading object code for memory address: %#"PRIx64"\n", addr);

	thread__find_addr_map(thread, cpumode, MAP__FUNCTION, addr, &al);
	thread__find_map(thread, cpumode, addr, &al);
	if (!al.map || !al.map->dso) {
		if (cpumode == PERF_RECORD_MISC_HYPERVISOR) {
			pr_debug("Hypervisor address can not be resolved - skipping\n");
			return 0;
		}

		pr_debug("thread__find_addr_map failed\n");
		pr_debug("thread__find_map failed\n");
		return -1;
	}

+3 −4
Original line number Diff line number Diff line
@@ -188,8 +188,7 @@ static int mmap_events(synth_cb synth)

		pr_debug("looking for map %p\n", td->map);

		thread__find_addr_map(thread,
				      PERF_RECORD_MISC_USER, MAP__FUNCTION,
		thread__find_map(thread, PERF_RECORD_MISC_USER,
				 (unsigned long) (td->map + 1), &al);

		thread__put(thread);
@@ -218,7 +217,7 @@ static int mmap_events(synth_cb synth)
 *   perf_event__synthesize_threads    (global)
 *
 * We test we can find all memory maps via:
 *   thread__find_addr_map
 *   thread__find_map
 *
 * by using all thread objects.
 */
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,
		return -1;
	}

	thread__find_addr_map(thread, sample->cpumode, MAP__FUNCTION, sample->ip, &al);
	thread__find_map(thread, sample->cpumode, sample->ip, &al);

	if (al.map != NULL)
		al.map->dso->hit = 1;
Loading