mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 21:21:09 -04:00
perf unwind: Use function to add missing maps lock
Switch read_unwind_spec_eh_frame() from loop macro
maps__for_each_entry() to maps__for_each_map() function that takes a
callback. The function holds the maps lock, which should be held during
iteration.
Committer notes:
Fixed up conflict with:
4fb54994b2 ("perf unwind-libunwind: Fix base address for .eh_frame")
Signed-off-by: Ian Rogers <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Athira Rajeev <[email protected]>
Cc: German Gomez <[email protected]>
Cc: James Clark <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Kajol Jain <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Leo Yan <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Nick Terrell <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Ravi Bangoria <[email protected]>
Cc: Sandipan Das <[email protected]>
Cc: Steinar H. Gunderson <[email protected]>
Cc: Wenyu Liu <[email protected]>
Cc: Yang Jihong <[email protected]>
Cc: changbin du <[email protected]>
Cc: colin ian king <[email protected]>
Cc: dmitrii dolgov <[email protected]>
Cc: guilherme amadio <[email protected]>
Cc: huacai chen <[email protected]>
Cc: k prateek nayak <[email protected]>
Cc: li dong <[email protected]>
Cc: liam howlett <[email protected]>
Cc: miguel ojeda <[email protected]>
Cc: ming wang <[email protected]>
Cc: sean christopherson <[email protected]>
Cc: vincent whitchurch <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
2d98dbb4c9
commit
16f533ade7
@@ -302,12 +302,31 @@ static int unwind_spec_ehframe(struct dso *dso, struct machine *machine,
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct read_unwind_spec_eh_frame_maps_cb_args {
|
||||
struct dso *dso;
|
||||
u64 base_addr;
|
||||
};
|
||||
|
||||
static int read_unwind_spec_eh_frame_maps_cb(struct map *map, void *data)
|
||||
{
|
||||
|
||||
struct read_unwind_spec_eh_frame_maps_cb_args *args = data;
|
||||
|
||||
if (map__dso(map) == args->dso && map__start(map) - map__pgoff(map) < args->base_addr)
|
||||
args->base_addr = map__start(map) - map__pgoff(map);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int read_unwind_spec_eh_frame(struct dso *dso, struct unwind_info *ui,
|
||||
u64 *table_data, u64 *segbase,
|
||||
u64 *fde_count)
|
||||
{
|
||||
struct map_rb_node *map_node;
|
||||
u64 base_addr = UINT64_MAX;
|
||||
struct read_unwind_spec_eh_frame_maps_cb_args args = {
|
||||
.dso = dso,
|
||||
.base_addr = UINT64_MAX,
|
||||
};
|
||||
int ret, fd;
|
||||
|
||||
if (dso->data.eh_frame_hdr_offset == 0) {
|
||||
@@ -325,16 +344,11 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct unwind_info *ui,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
maps__for_each_entry(thread__maps(ui->thread), map_node) {
|
||||
struct map *map = map_node->map;
|
||||
u64 start = map__start(map) - map__pgoff(map);
|
||||
maps__for_each_map(thread__maps(ui->thread), read_unwind_spec_eh_frame_maps_cb, &args);
|
||||
|
||||
if (map__dso(map) == dso && start < base_addr)
|
||||
base_addr = start;
|
||||
}
|
||||
base_addr -= dso->data.elf_base_addr;
|
||||
args.base_addr -= dso->data.elf_base_addr;
|
||||
/* Address of .eh_frame_hdr */
|
||||
*segbase = base_addr + dso->data.eh_frame_hdr_addr;
|
||||
*segbase = args.base_addr + dso->data.eh_frame_hdr_addr;
|
||||
ret = unwind_spec_ehframe(dso, ui->machine, dso->data.eh_frame_hdr_offset,
|
||||
table_data, fde_count);
|
||||
if (ret)
|
||||
|
||||
Reference in New Issue
Block a user