Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Do not remove addr_location.thread in thread__find_map()

The thread__find_map() is to find a map for a given address in the
given thread's address space. It searches maps based on the cpu mode
and fills various information in the addr_location data structure.

It might change al->maps and al->map, but not al->thread. Then I
think no reason to not set the al->thread at the beginning.

Also get rid of the duplicate 'al->map = NULL' part.

Fixes: 0dd5041c9a0ea ("perf addr_location: Add init/exit/copy functions")
Acked-by: Ian Rogers <irogers@google.com>
Acked-by: James Clark <james.clark@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

+2 -5
+2 -5
tools/perf/util/event.c
··· 581 581 maps__zput(al->maps); 582 582 map__zput(al->map); 583 583 thread__zput(al->thread); 584 + al->thread = thread__get(thread); 584 585 585 586 al->addr = addr; 586 587 al->cpumode = cpumode; 587 588 al->filtered = 0; 588 589 589 - if (machine == NULL) { 590 - al->map = NULL; 590 + if (machine == NULL) 591 591 return NULL; 592 - } 593 592 594 593 if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) { 595 594 al->level = 'k'; ··· 604 605 al->level = 'u'; 605 606 } else { 606 607 al->level = 'H'; 607 - al->map = NULL; 608 608 609 609 if ((cpumode == PERF_RECORD_MISC_GUEST_USER || 610 610 cpumode == PERF_RECORD_MISC_GUEST_KERNEL) && ··· 617 619 return NULL; 618 620 } 619 621 al->maps = maps__get(maps); 620 - al->thread = thread__get(thread); 621 622 al->map = map__get(maps__find(maps, al->addr)); 622 623 if (al->map != NULL) { 623 624 /*