mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00: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 <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: German Gomez <german.gomez@arm.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Terrell <terrelln@fb.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Steinar H. Gunderson <sesse@google.com>
Cc: Wenyu Liu <liuwenyu7@huawei.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: changbin du <changbin.du@huawei.com>
Cc: colin ian king <colin.i.king@gmail.com>
Cc: dmitrii dolgov <9erthalion6@gmail.com>
Cc: guilherme amadio <amadio@gentoo.org>
Cc: huacai chen <chenhuacai@kernel.org>
Cc: k prateek nayak <kprateek.nayak@amd.com>
Cc: li dong <lidong@vivo.com>
Cc: liam howlett <liam.howlett@oracle.com>
Cc: miguel ojeda <ojeda@kernel.org>
Cc: ming wang <wangming01@loongson.cn>
Cc: sean christopherson <seanjc@google.com>
Cc: vincent whitchurch <vincent.whitchurch@axis.com>
Link: http://lore.kernel.org/lkml/20231207011722.1220634-12-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
2d98dbb4c9
commit
16f533ade7
1 changed files with 24 additions and 10 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue