Unverified Commit f5a62ec8 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!14208 Fix perf coredump and refcnt inccoret

Merge Pull Request from: @langfei295455 
 
1.perf maps: Use a pointer for kmaps
Fix:https://gitee.com/openeuler/kernel/commit/c6d91c40316e249c5b1e42a44082cf52c4e2b6b2

2.perf addr_location: Add init/exit/copy functions

issue:https://gitee.com/openeuler/kernel/issues/IBBJ27 
 
Link:https://gitee.com/openeuler/kernel/pulls/14208

 

Reviewed-by: default avatarLiu Chao <liuchao173@huawei.com>
Reviewed-by: default avatarLi Nan <linan122@huawei.com>
Signed-off-by: default avatarLi Nan <linan122@huawei.com>
parents 3ad50d6b 13f820db
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ int perf_event__synthesize_extra_kmaps(struct perf_tool *tool,
{
	int rc = 0;
	struct map *pos;
	struct maps *kmaps = &machine->kmaps;
	struct maps *kmaps = machine__kernel_maps(machine);
	union perf_event *event = zalloc(sizeof(event->mmap) +
					 machine->id_hdr_size);

+5 −3
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest
	struct symbol *sym;
	struct map *kallsyms_map, *vmlinux_map, *map;
	struct machine kallsyms, vmlinux;
	struct maps *maps = machine__kernel_maps(&vmlinux);
	struct maps *maps;
	u64 mem_start, mem_end;
	bool header_printed;

@@ -34,6 +34,8 @@ int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest
	machine__init(&kallsyms, "", HOST_KERNEL_ID);
	machine__init(&vmlinux, "", HOST_KERNEL_ID);

	maps = machine__kernel_maps(&vmlinux);

	/*
	 * Step 2:
	 *
@@ -190,7 +192,7 @@ int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest
		 * so use the short name, less descriptive but the same ("[kernel]" in
		 * both cases.
		 */
		pair = maps__find_by_name(&kallsyms.kmaps, (map->dso->kernel ?
		pair = maps__find_by_name(kallsyms.kmaps, (map->dso->kernel ?
								map->dso->short_name :
								map->dso->name));
		if (pair) {
@@ -212,7 +214,7 @@ int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest
		mem_start = vmlinux_map->unmap_ip(vmlinux_map, map->start);
		mem_end = vmlinux_map->unmap_ip(vmlinux_map, map->end);

		pair = maps__find(&kallsyms.kmaps, mem_start);
		pair = maps__find(kallsyms.kmaps, mem_start);
		if (pair == NULL || pair->priv)
			continue;

+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ static int machine__process_bpf_event_load(struct machine *machine,
	for (i = 0; i < info_linear->info.nr_jited_ksyms; i++) {
		u64 *addrs = (u64 *)(uintptr_t)(info_linear->info.jited_ksyms);
		u64 addr = addrs[i];
		struct map *map = maps__find(&machine->kmaps, addr);
		struct map *map = maps__find(machine__kernel_maps(machine), addr);

		if (map) {
			map->dso->binary_type = DSO_BINARY_TYPE__BPF_PROG_INFO;
+1 −1
Original line number Diff line number Diff line
@@ -1119,7 +1119,7 @@ int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node *
			goto out;
	}

	if (al->maps == &al->maps->machine->kmaps) {
	if (al->maps == machine__kernel_maps(al->maps->machine)) {
		if (machine__is_host(al->maps->machine)) {
			al->cpumode = PERF_RECORD_MISC_KERNEL;
			al->level = 'k';
+3 −3
Original line number Diff line number Diff line
@@ -450,7 +450,7 @@ size_t perf_event__fprintf_text_poke(union perf_event *event, struct machine *ma
	if (machine) {
		struct addr_location al;

		al.map = maps__find(&machine->kmaps, tp->addr);
		al.map = maps__find(machine__kernel_maps(machine), tp->addr);
		if (al.map && map__load(al.map) >= 0) {
			al.addr = al.map->map_ip(al.map, tp->addr);
			al.sym = map__find_symbol(al.map, al.addr);
@@ -550,13 +550,13 @@ struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr,

	if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) {
		al->level = 'k';
		al->maps = maps = &machine->kmaps;
		al->maps = maps = machine__kernel_maps(machine);
		load_map = true;
	} else if (cpumode == PERF_RECORD_MISC_USER && perf_host) {
		al->level = '.';
	} else if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest) {
		al->level = 'g';
		al->maps = maps = &machine->kmaps;
		al->maps = maps = machine__kernel_maps(machine);
		load_map = true;
	} else if (cpumode == PERF_RECORD_MISC_GUEST_USER && perf_guest) {
		al->level = 'u';
Loading