You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
perf maps: Merge 'struct maps' with 'struct map_groups'
And pick the shortest name: 'struct maps'. The split existed because we used to have two groups of maps, one for functions and one for variables, but that only complicated things, sometimes we needed to figure out what was at some address and then had to first try it on the functions group and if that failed, fall back to the variables one. That split is long gone, so for quite a while we had only one struct maps per struct map_groups, simplify things by combining those structs. First patch is the minimum needed to merge both, follow up patches will rename 'thread->mg' to 'thread->maps', etc. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lkml.kernel.org/n/tip-hom6639ro7020o708trhxh59@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
@@ -26,7 +26,7 @@ static int sample_ustack(struct perf_sample *sample,
|
||||
|
||||
sp = (unsigned long) regs[PERF_REG_ARM_SP];
|
||||
|
||||
map = map_groups__find(thread->mg, (u64)sp);
|
||||
map = maps__find(thread->mg, (u64)sp);
|
||||
if (!map) {
|
||||
pr_debug("failed to get stack map\n");
|
||||
free(buf);
|
||||
|
||||
@@ -26,7 +26,7 @@ static int sample_ustack(struct perf_sample *sample,
|
||||
|
||||
sp = (unsigned long) regs[PERF_REG_ARM64_SP];
|
||||
|
||||
map = map_groups__find(thread->mg, (u64)sp);
|
||||
map = maps__find(thread->mg, (u64)sp);
|
||||
if (!map) {
|
||||
pr_debug("failed to get stack map\n");
|
||||
free(buf);
|
||||
|
||||
@@ -27,7 +27,7 @@ static int sample_ustack(struct perf_sample *sample,
|
||||
|
||||
sp = (unsigned long) regs[PERF_REG_POWERPC_R1];
|
||||
|
||||
map = map_groups__find(thread->mg, (u64)sp);
|
||||
map = maps__find(thread->mg, (u64)sp);
|
||||
if (!map) {
|
||||
pr_debug("failed to get stack map\n");
|
||||
free(buf);
|
||||
|
||||
@@ -38,7 +38,7 @@ static int s390_call__parse(struct arch *arch, struct ins_operands *ops,
|
||||
return -1;
|
||||
target.addr = map__objdump_2mem(map, ops->target.addr);
|
||||
|
||||
if (map_groups__find_ams(ms->mg, &target) == 0 &&
|
||||
if (maps__find_ams(ms->mg, &target) == 0 &&
|
||||
map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr)
|
||||
ops->target.sym = target.ms.sym;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ static int sample_ustack(struct perf_sample *sample,
|
||||
|
||||
sp = (unsigned long) regs[PERF_REG_X86_SP];
|
||||
|
||||
map = map_groups__find(thread->mg, (u64)sp);
|
||||
map = maps__find(thread->mg, (u64)sp);
|
||||
if (!map) {
|
||||
pr_debug("failed to get stack map\n");
|
||||
free(buf);
|
||||
|
||||
@@ -18,8 +18,7 @@ int perf_event__synthesize_extra_kmaps(struct perf_tool *tool,
|
||||
{
|
||||
int rc = 0;
|
||||
struct map *pos;
|
||||
struct map_groups *kmaps = &machine->kmaps;
|
||||
struct maps *maps = &kmaps->maps;
|
||||
struct maps *kmaps = &machine->kmaps;
|
||||
union perf_event *event = zalloc(sizeof(event->mmap) +
|
||||
machine->id_hdr_size);
|
||||
|
||||
@@ -29,7 +28,7 @@ int perf_event__synthesize_extra_kmaps(struct perf_tool *tool,
|
||||
return -1;
|
||||
}
|
||||
|
||||
maps__for_each_entry(maps, pos) {
|
||||
maps__for_each_entry(kmaps, pos) {
|
||||
struct kmap *kmap;
|
||||
size_t size;
|
||||
|
||||
|
||||
@@ -780,11 +780,6 @@ static size_t maps__fprintf_task(struct maps *maps, int indent, FILE *fp)
|
||||
return printed;
|
||||
}
|
||||
|
||||
static int map_groups__fprintf_task(struct map_groups *mg, int indent, FILE *fp)
|
||||
{
|
||||
return maps__fprintf_task(&mg->maps, indent, fp);
|
||||
}
|
||||
|
||||
static void task__print_level(struct task *task, FILE *fp, int level)
|
||||
{
|
||||
struct thread *thread = task->thread;
|
||||
@@ -795,7 +790,7 @@ static void task__print_level(struct task *task, FILE *fp, int level)
|
||||
|
||||
fprintf(fp, "%s\n", thread__comm_str(thread));
|
||||
|
||||
map_groups__fprintf_task(thread->mg, comm_indent, fp);
|
||||
maps__fprintf_task(thread->mg, comm_indent, fp);
|
||||
|
||||
if (!list_empty(&task->children)) {
|
||||
list_for_each_entry(child, &task->children, list)
|
||||
|
||||
@@ -13,12 +13,12 @@ struct map_def {
|
||||
u64 end;
|
||||
};
|
||||
|
||||
static int check_maps(struct map_def *merged, unsigned int size, struct map_groups *mg)
|
||||
static int check_maps(struct map_def *merged, unsigned int size, struct maps *maps)
|
||||
{
|
||||
struct map *map;
|
||||
unsigned int i = 0;
|
||||
|
||||
map_groups__for_each_entry(mg, map) {
|
||||
maps__for_each_entry(maps, map) {
|
||||
if (i > 0)
|
||||
TEST_ASSERT_VAL("less maps expected", (map && i < size) || (!map && i == size));
|
||||
|
||||
@@ -35,7 +35,7 @@ static int check_maps(struct map_def *merged, unsigned int size, struct map_grou
|
||||
|
||||
int test__map_groups__merge_in(struct test *t __maybe_unused, int subtest __maybe_unused)
|
||||
{
|
||||
struct map_groups mg;
|
||||
struct maps mg;
|
||||
unsigned int i;
|
||||
struct map_def bpf_progs[] = {
|
||||
{ "bpf_prog_1", 200, 300 },
|
||||
@@ -64,7 +64,7 @@ int test__map_groups__merge_in(struct test *t __maybe_unused, int subtest __mayb
|
||||
struct map *map_kcore1, *map_kcore2, *map_kcore3;
|
||||
int ret;
|
||||
|
||||
map_groups__init(&mg, NULL);
|
||||
maps__init(&mg, NULL);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(bpf_progs); i++) {
|
||||
struct map *map;
|
||||
@@ -74,7 +74,7 @@ int test__map_groups__merge_in(struct test *t __maybe_unused, int subtest __mayb
|
||||
|
||||
map->start = bpf_progs[i].start;
|
||||
map->end = bpf_progs[i].end;
|
||||
map_groups__insert(&mg, map);
|
||||
maps__insert(&mg, map);
|
||||
map__put(map);
|
||||
}
|
||||
|
||||
@@ -99,19 +99,19 @@ int test__map_groups__merge_in(struct test *t __maybe_unused, int subtest __mayb
|
||||
map_kcore3->start = 880;
|
||||
map_kcore3->end = 1100;
|
||||
|
||||
ret = map_groups__merge_in(&mg, map_kcore1);
|
||||
ret = maps__merge_in(&mg, map_kcore1);
|
||||
TEST_ASSERT_VAL("failed to merge map", !ret);
|
||||
|
||||
ret = check_maps(merged12, ARRAY_SIZE(merged12), &mg);
|
||||
TEST_ASSERT_VAL("merge check failed", !ret);
|
||||
|
||||
ret = map_groups__merge_in(&mg, map_kcore2);
|
||||
ret = maps__merge_in(&mg, map_kcore2);
|
||||
TEST_ASSERT_VAL("failed to merge map", !ret);
|
||||
|
||||
ret = check_maps(merged12, ARRAY_SIZE(merged12), &mg);
|
||||
TEST_ASSERT_VAL("merge check failed", !ret);
|
||||
|
||||
ret = map_groups__merge_in(&mg, map_kcore3);
|
||||
ret = maps__merge_in(&mg, map_kcore3);
|
||||
TEST_ASSERT_VAL("failed to merge map", !ret);
|
||||
|
||||
ret = check_maps(merged3, ARRAY_SIZE(merged3), &mg);
|
||||
|
||||
@@ -12,16 +12,16 @@ int test__thread_mg_share(struct test *test __maybe_unused, int subtest __maybe_
|
||||
/* thread group */
|
||||
struct thread *leader;
|
||||
struct thread *t1, *t2, *t3;
|
||||
struct map_groups *mg;
|
||||
struct maps *mg;
|
||||
|
||||
/* other process */
|
||||
struct thread *other, *other_leader;
|
||||
struct map_groups *other_mg;
|
||||
struct maps *other_mg;
|
||||
|
||||
/*
|
||||
* This test create 2 processes abstractions (struct thread)
|
||||
* with several threads and checks they properly share and
|
||||
* maintain map groups info (struct map_groups).
|
||||
* maintain maps info (struct maps).
|
||||
*
|
||||
* thread group (pid: 0, tids: 0, 1, 2, 3)
|
||||
* other group (pid: 4, tids: 4, 5)
|
||||
|
||||
@@ -190,10 +190,9 @@ next_pair:
|
||||
* so use the short name, less descriptive but the same ("[kernel]" in
|
||||
* both cases.
|
||||
*/
|
||||
pair = map_groups__find_by_name(&kallsyms.kmaps,
|
||||
(map->dso->kernel ?
|
||||
map->dso->short_name :
|
||||
map->dso->name));
|
||||
pair = maps__find_by_name(&kallsyms.kmaps, (map->dso->kernel ?
|
||||
map->dso->short_name :
|
||||
map->dso->name));
|
||||
if (pair) {
|
||||
pair->priv = 1;
|
||||
} else {
|
||||
@@ -213,7 +212,7 @@ next_pair:
|
||||
mem_start = vmlinux_map->unmap_ip(vmlinux_map, map->start);
|
||||
mem_end = vmlinux_map->unmap_ip(vmlinux_map, map->end);
|
||||
|
||||
pair = map_groups__find(&kallsyms.kmaps, mem_start);
|
||||
pair = maps__find(&kallsyms.kmaps, mem_start);
|
||||
if (pair == NULL || pair->priv)
|
||||
continue;
|
||||
|
||||
|
||||
@@ -885,7 +885,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
|
||||
}
|
||||
|
||||
if (h->ms.map == NULL && verbose > 1) {
|
||||
map_groups__fprintf(h->thread->mg, fp);
|
||||
maps__fprintf(h->thread->mg, fp);
|
||||
fprintf(fp, "%.10s end\n", graph_dotted_line);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ static int call__parse(struct arch *arch, struct ins_operands *ops, struct map_s
|
||||
find_target:
|
||||
target.addr = map__objdump_2mem(map, ops->target.addr);
|
||||
|
||||
if (map_groups__find_ams(ms->mg, &target) == 0 &&
|
||||
if (maps__find_ams(ms->mg, &target) == 0 &&
|
||||
map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr)
|
||||
ops->target.sym = target.ms.sym;
|
||||
|
||||
@@ -391,7 +391,7 @@ static int jump__parse(struct arch *arch, struct ins_operands *ops, struct map_s
|
||||
* Actual navigation will come next, with further understanding of how
|
||||
* the symbol searching and disassembly should be done.
|
||||
*/
|
||||
if (map_groups__find_ams(ms->mg, &target) == 0 &&
|
||||
if (maps__find_ams(ms->mg, &target) == 0 &&
|
||||
map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr)
|
||||
ops->target.sym = target.ms.sym;
|
||||
|
||||
@@ -1545,7 +1545,7 @@ static int symbol__parse_objdump_line(struct symbol *sym,
|
||||
.ms = { .map = map, },
|
||||
};
|
||||
|
||||
if (!map_groups__find_ams(args->ms.mg, &target) &&
|
||||
if (!maps__find_ams(args->ms.mg, &target) &&
|
||||
target.ms.sym->start == target.al_addr)
|
||||
dl->ops.target.sym = target.ms.sym;
|
||||
}
|
||||
|
||||
@@ -52,9 +52,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;
|
||||
|
||||
map = map_groups__find(&machine->kmaps, addr);
|
||||
struct map *map = maps__find(&machine->kmaps, addr);
|
||||
|
||||
if (map) {
|
||||
map->dso->binary_type = DSO_BINARY_TYPE__BPF_PROG_INFO;
|
||||
|
||||
@@ -2569,7 +2569,7 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
|
||||
if (err)
|
||||
goto err_delete_thread;
|
||||
|
||||
if (thread__init_map_groups(etm->unknown_thread, etm->machine)) {
|
||||
if (thread__init_maps(etm->unknown_thread, etm->machine)) {
|
||||
err = -ENOMEM;
|
||||
goto err_delete_thread;
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ int perf_event__process(struct perf_tool *tool __maybe_unused,
|
||||
struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr,
|
||||
struct addr_location *al)
|
||||
{
|
||||
struct map_groups *mg = thread->mg;
|
||||
struct maps *mg = thread->mg;
|
||||
struct machine *machine = mg->machine;
|
||||
bool load_map = false;
|
||||
|
||||
@@ -500,7 +500,7 @@ struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
al->map = map_groups__find(mg, al->addr);
|
||||
al->map = maps__find(mg, al->addr);
|
||||
if (al->map != NULL) {
|
||||
/*
|
||||
* Kernel maps might be changed when loading symbols so loading
|
||||
|
||||
@@ -3296,7 +3296,7 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
|
||||
err = thread__set_comm(pt->unknown_thread, "unknown", 0);
|
||||
if (err)
|
||||
goto err_delete_thread;
|
||||
if (thread__init_map_groups(pt->unknown_thread, pt->machine)) {
|
||||
if (thread__init_maps(pt->unknown_thread, pt->machine)) {
|
||||
err = -ENOMEM;
|
||||
goto err_delete_thread;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
|
||||
int err = -ENOMEM;
|
||||
|
||||
memset(machine, 0, sizeof(*machine));
|
||||
map_groups__init(&machine->kmaps, machine);
|
||||
maps__init(&machine->kmaps, machine);
|
||||
RB_CLEAR_NODE(&machine->rb_node);
|
||||
dsos__init(&machine->dsos);
|
||||
|
||||
@@ -217,7 +217,7 @@ void machine__exit(struct machine *machine)
|
||||
return;
|
||||
|
||||
machine__destroy_kernel_maps(machine);
|
||||
map_groups__exit(&machine->kmaps);
|
||||
maps__exit(&machine->kmaps);
|
||||
dsos__exit(&machine->dsos);
|
||||
machine__exit_vdso(machine);
|
||||
zfree(&machine->root_dir);
|
||||
@@ -413,7 +413,7 @@ static void machine__update_thread_pid(struct machine *machine,
|
||||
goto out_err;
|
||||
|
||||
if (!leader->mg)
|
||||
leader->mg = map_groups__new(machine);
|
||||
leader->mg = maps__new(machine);
|
||||
|
||||
if (!leader->mg)
|
||||
goto out_err;
|
||||
@@ -427,13 +427,13 @@ static void machine__update_thread_pid(struct machine *machine,
|
||||
* tid. Consequently there never should be any maps on a thread
|
||||
* with an unknown pid. Just print an error if there are.
|
||||
*/
|
||||
if (!map_groups__empty(th->mg))
|
||||
if (!maps__empty(th->mg))
|
||||
pr_err("Discarding thread maps for %d:%d\n",
|
||||
th->pid_, th->tid);
|
||||
map_groups__put(th->mg);
|
||||
maps__put(th->mg);
|
||||
}
|
||||
|
||||
th->mg = map_groups__get(leader->mg);
|
||||
th->mg = maps__get(leader->mg);
|
||||
out_put:
|
||||
thread__put(leader);
|
||||
return;
|
||||
@@ -536,14 +536,13 @@ static struct thread *____machine__findnew_thread(struct machine *machine,
|
||||
rb_insert_color_cached(&th->rb_node, &threads->entries, leftmost);
|
||||
|
||||
/*
|
||||
* We have to initialize map_groups separately
|
||||
* after rb tree is updated.
|
||||
* We have to initialize maps separately after rb tree is updated.
|
||||
*
|
||||
* The reason is that we call machine__findnew_thread
|
||||
* within thread__init_map_groups to find the thread
|
||||
* within thread__init_maps to find the thread
|
||||
* leader and that would screwed the rb tree.
|
||||
*/
|
||||
if (thread__init_map_groups(th, machine)) {
|
||||
if (thread__init_maps(th, machine)) {
|
||||
rb_erase_cached(&th->rb_node, &threads->entries);
|
||||
RB_CLEAR_NODE(&th->rb_node);
|
||||
thread__put(th);
|
||||
@@ -724,9 +723,8 @@ static int machine__process_ksymbol_register(struct machine *machine,
|
||||
struct perf_sample *sample __maybe_unused)
|
||||
{
|
||||
struct symbol *sym;
|
||||
struct map *map;
|
||||
struct map *map = maps__find(&machine->kmaps, event->ksymbol.addr);
|
||||
|
||||
map = map_groups__find(&machine->kmaps, event->ksymbol.addr);
|
||||
if (!map) {
|
||||
map = dso__new_map(event->ksymbol.name);
|
||||
if (!map)
|
||||
@@ -734,7 +732,7 @@ static int machine__process_ksymbol_register(struct machine *machine,
|
||||
|
||||
map->start = event->ksymbol.addr;
|
||||
map->end = map->start + event->ksymbol.len;
|
||||
map_groups__insert(&machine->kmaps, map);
|
||||
maps__insert(&machine->kmaps, map);
|
||||
}
|
||||
|
||||
sym = symbol__new(map->map_ip(map, map->start),
|
||||
@@ -752,9 +750,9 @@ static int machine__process_ksymbol_unregister(struct machine *machine,
|
||||
{
|
||||
struct map *map;
|
||||
|
||||
map = map_groups__find(&machine->kmaps, event->ksymbol.addr);
|
||||
map = maps__find(&machine->kmaps, event->ksymbol.addr);
|
||||
if (map)
|
||||
map_groups__remove(&machine->kmaps, map);
|
||||
maps__remove(&machine->kmaps, map);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -790,9 +788,9 @@ static struct map *machine__addnew_module_map(struct machine *machine, u64 start
|
||||
if (map == NULL)
|
||||
goto out;
|
||||
|
||||
map_groups__insert(&machine->kmaps, map);
|
||||
maps__insert(&machine->kmaps, map);
|
||||
|
||||
/* Put the map here because map_groups__insert alread got it */
|
||||
/* Put the map here because maps__insert alread got it */
|
||||
map__put(map);
|
||||
out:
|
||||
/* put the dso here, corresponding to machine__findnew_module_dso */
|
||||
@@ -977,7 +975,7 @@ int machine__create_extra_kernel_map(struct machine *machine,
|
||||
kmap->kmaps = &machine->kmaps;
|
||||
strlcpy(kmap->name, xm->name, KMAP_NAME_LEN);
|
||||
|
||||
map_groups__insert(&machine->kmaps, map);
|
||||
maps__insert(&machine->kmaps, map);
|
||||
|
||||
pr_debug2("Added extra kernel map %s %" PRIx64 "-%" PRIx64 "\n",
|
||||
kmap->name, map->start, map->end);
|
||||
@@ -1022,8 +1020,7 @@ static u64 find_entry_trampoline(struct dso *dso)
|
||||
int machine__map_x86_64_entry_trampolines(struct machine *machine,
|
||||
struct dso *kernel)
|
||||
{
|
||||
struct map_groups *kmaps = &machine->kmaps;
|
||||
struct maps *maps = &kmaps->maps;
|
||||
struct maps *kmaps = &machine->kmaps;
|
||||
int nr_cpus_avail, cpu;
|
||||
bool found = false;
|
||||
struct map *map;
|
||||
@@ -1033,14 +1030,14 @@ int machine__map_x86_64_entry_trampolines(struct machine *machine,
|
||||
* In the vmlinux case, pgoff is a virtual address which must now be
|
||||
* mapped to a vmlinux offset.
|
||||
*/
|
||||
maps__for_each_entry(maps, map) {
|
||||
maps__for_each_entry(kmaps, map) {
|
||||
struct kmap *kmap = __map__kmap(map);
|
||||
struct map *dest_map;
|
||||
|
||||
if (!kmap || !is_entry_trampoline(kmap->name))
|
||||
continue;
|
||||
|
||||
dest_map = map_groups__find(kmaps, map->pgoff);
|
||||
dest_map = maps__find(kmaps, map->pgoff);
|
||||
if (dest_map != map)
|
||||
map->pgoff = dest_map->map_ip(dest_map, map->pgoff);
|
||||
found = true;
|
||||
@@ -1102,7 +1099,7 @@ __machine__create_kernel_maps(struct machine *machine, struct dso *kernel)
|
||||
return -1;
|
||||
|
||||
kmap->kmaps = &machine->kmaps;
|
||||
map_groups__insert(&machine->kmaps, map);
|
||||
maps__insert(&machine->kmaps, map);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1116,7 +1113,7 @@ void machine__destroy_kernel_maps(struct machine *machine)
|
||||
return;
|
||||
|
||||
kmap = map__kmap(map);
|
||||
map_groups__remove(&machine->kmaps, map);
|
||||
maps__remove(&machine->kmaps, map);
|
||||
if (kmap && kmap->ref_reloc_sym) {
|
||||
zfree((char **)&kmap->ref_reloc_sym->name);
|
||||
zfree(&kmap->ref_reloc_sym);
|
||||
@@ -1211,7 +1208,7 @@ int machine__load_kallsyms(struct machine *machine, const char *filename)
|
||||
* kernel, with modules between them, fixup the end of all
|
||||
* sections.
|
||||
*/
|
||||
map_groups__fixup_end(&machine->kmaps);
|
||||
maps__fixup_end(&machine->kmaps);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -1262,11 +1259,10 @@ static bool is_kmod_dso(struct dso *dso)
|
||||
dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE;
|
||||
}
|
||||
|
||||
static int map_groups__set_module_path(struct map_groups *mg, const char *path,
|
||||
struct kmod_path *m)
|
||||
static int maps__set_module_path(struct maps *mg, const char *path, struct kmod_path *m)
|
||||
{
|
||||
char *long_name;
|
||||
struct map *map = map_groups__find_by_name(mg, m->name);
|
||||
struct map *map = maps__find_by_name(mg, m->name);
|
||||
|
||||
if (map == NULL)
|
||||
return 0;
|
||||
@@ -1290,8 +1286,7 @@ static int map_groups__set_module_path(struct map_groups *mg, const char *path,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int map_groups__set_modules_path_dir(struct map_groups *mg,
|
||||
const char *dir_name, int depth)
|
||||
static int maps__set_modules_path_dir(struct maps *mg, const char *dir_name, int depth)
|
||||
{
|
||||
struct dirent *dent;
|
||||
DIR *dir = opendir(dir_name);
|
||||
@@ -1323,8 +1318,7 @@ static int map_groups__set_modules_path_dir(struct map_groups *mg,
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = map_groups__set_modules_path_dir(mg, path,
|
||||
depth + 1);
|
||||
ret = maps__set_modules_path_dir(mg, path, depth + 1);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
} else {
|
||||
@@ -1335,7 +1329,7 @@ static int map_groups__set_modules_path_dir(struct map_groups *mg,
|
||||
goto out;
|
||||
|
||||
if (m.kmod)
|
||||
ret = map_groups__set_module_path(mg, path, &m);
|
||||
ret = maps__set_module_path(mg, path, &m);
|
||||
|
||||
zfree(&m.name);
|
||||
|
||||
@@ -1362,7 +1356,7 @@ static int machine__set_modules_path(struct machine *machine)
|
||||
machine->root_dir, version);
|
||||
free(version);
|
||||
|
||||
return map_groups__set_modules_path_dir(&machine->kmaps, modules_path, 0);
|
||||
return maps__set_modules_path_dir(&machine->kmaps, modules_path, 0);
|
||||
}
|
||||
int __weak arch__fix_module_text_start(u64 *start __maybe_unused,
|
||||
u64 *size __maybe_unused,
|
||||
@@ -1435,11 +1429,11 @@ static void machine__update_kernel_mmap(struct machine *machine,
|
||||
struct map *map = machine__kernel_map(machine);
|
||||
|
||||
map__get(map);
|
||||
map_groups__remove(&machine->kmaps, map);
|
||||
maps__remove(&machine->kmaps, map);
|
||||
|
||||
machine__set_kernel_mmap(machine, start, end);
|
||||
|
||||
map_groups__insert(&machine->kmaps, map);
|
||||
maps__insert(&machine->kmaps, map);
|
||||
map__put(map);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ struct machine {
|
||||
struct vdso_info *vdso_info;
|
||||
struct perf_env *env;
|
||||
struct dsos dsos;
|
||||
struct map_groups kmaps;
|
||||
struct maps kmaps;
|
||||
struct map *vmlinux_map;
|
||||
u64 kernel_start;
|
||||
pid_t *current_tid;
|
||||
@@ -83,7 +83,7 @@ struct map *machine__kernel_map(struct machine *machine)
|
||||
static inline
|
||||
struct maps *machine__kernel_maps(struct machine *machine)
|
||||
{
|
||||
return &machine->kmaps.maps;
|
||||
return &machine->kmaps;
|
||||
}
|
||||
|
||||
int machine__get_kernel_start(struct machine *machine);
|
||||
@@ -212,7 +212,7 @@ static inline
|
||||
struct symbol *machine__find_kernel_symbol(struct machine *machine, u64 addr,
|
||||
struct map **mapp)
|
||||
{
|
||||
return map_groups__find_symbol(&machine->kmaps, addr, mapp);
|
||||
return maps__find_symbol(&machine->kmaps, addr, mapp);
|
||||
}
|
||||
|
||||
static inline
|
||||
@@ -220,7 +220,7 @@ struct symbol *machine__find_kernel_symbol_by_name(struct machine *machine,
|
||||
const char *name,
|
||||
struct map **mapp)
|
||||
{
|
||||
return map_groups__find_symbol_by_name(&machine->kmaps, name, mapp);
|
||||
return maps__find_symbol_by_name(&machine->kmaps, name, mapp);
|
||||
}
|
||||
|
||||
int arch__fix_module_text_start(u64 *start, u64 *size, const char *name);
|
||||
|
||||
@@ -512,15 +512,10 @@ u64 map__objdump_2mem(struct map *map, u64 ip)
|
||||
return ip + map->reloc;
|
||||
}
|
||||
|
||||
static void maps__init(struct maps *maps)
|
||||
void maps__init(struct maps *mg, struct machine *machine)
|
||||
{
|
||||
maps->entries = RB_ROOT;
|
||||
init_rwsem(&maps->lock);
|
||||
}
|
||||
|
||||
void map_groups__init(struct map_groups *mg, struct machine *machine)
|
||||
{
|
||||
maps__init(&mg->maps);
|
||||
mg->entries = RB_ROOT;
|
||||
init_rwsem(&mg->lock);
|
||||
mg->machine = machine;
|
||||
mg->last_search_by_name = NULL;
|
||||
mg->nr_maps = 0;
|
||||
@@ -528,7 +523,7 @@ void map_groups__init(struct map_groups *mg, struct machine *machine)
|
||||
refcount_set(&mg->refcnt, 1);
|
||||
}
|
||||
|
||||
static void __map_groups__free_maps_by_name(struct map_groups *mg)
|
||||
static void __maps__free_maps_by_name(struct maps *mg)
|
||||
{
|
||||
/*
|
||||
* Free everything to try to do it from the rbtree in the next search
|
||||
@@ -537,9 +532,9 @@ static void __map_groups__free_maps_by_name(struct map_groups *mg)
|
||||
mg->nr_maps_allocated = 0;
|
||||
}
|
||||
|
||||
void map_groups__insert(struct map_groups *mg, struct map *map)
|
||||
void maps__insert(struct maps *mg, struct map *map)
|
||||
{
|
||||
struct maps *maps = &mg->maps;
|
||||
struct maps *maps = mg;
|
||||
|
||||
down_write(&maps->lock);
|
||||
__maps__insert(maps, map);
|
||||
@@ -555,7 +550,7 @@ void map_groups__insert(struct map_groups *mg, struct map *map)
|
||||
struct map **maps_by_name = realloc(mg->maps_by_name, nr_allocate * sizeof(map));
|
||||
|
||||
if (maps_by_name == NULL) {
|
||||
__map_groups__free_maps_by_name(mg);
|
||||
__maps__free_maps_by_name(maps);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -563,7 +558,7 @@ void map_groups__insert(struct map_groups *mg, struct map *map)
|
||||
mg->nr_maps_allocated = nr_allocate;
|
||||
}
|
||||
mg->maps_by_name[mg->nr_maps - 1] = map;
|
||||
__map_groups__sort_by_name(mg);
|
||||
__maps__sort_by_name(maps);
|
||||
}
|
||||
up_write(&maps->lock);
|
||||
}
|
||||
@@ -574,9 +569,9 @@ static void __maps__remove(struct maps *maps, struct map *map)
|
||||
map__put(map);
|
||||
}
|
||||
|
||||
void map_groups__remove(struct map_groups *mg, struct map *map)
|
||||
void maps__remove(struct maps *mg, struct map *map)
|
||||
{
|
||||
struct maps *maps = &mg->maps;
|
||||
struct maps *maps = mg;
|
||||
down_write(&maps->lock);
|
||||
if (mg->last_search_by_name == map)
|
||||
mg->last_search_by_name = NULL;
|
||||
@@ -584,7 +579,7 @@ void map_groups__remove(struct map_groups *mg, struct map *map)
|
||||
__maps__remove(maps, map);
|
||||
--mg->nr_maps;
|
||||
if (mg->maps_by_name)
|
||||
__map_groups__free_maps_by_name(mg);
|
||||
__maps__free_maps_by_name(maps);
|
||||
up_write(&maps->lock);
|
||||
}
|
||||
|
||||
@@ -598,50 +593,44 @@ static void __maps__purge(struct maps *maps)
|
||||
}
|
||||
}
|
||||
|
||||
static void maps__exit(struct maps *maps)
|
||||
void maps__exit(struct maps *maps)
|
||||
{
|
||||
down_write(&maps->lock);
|
||||
__maps__purge(maps);
|
||||
up_write(&maps->lock);
|
||||
}
|
||||
|
||||
void map_groups__exit(struct map_groups *mg)
|
||||
bool maps__empty(struct maps *maps)
|
||||
{
|
||||
maps__exit(&mg->maps);
|
||||
return !maps__first(maps);
|
||||
}
|
||||
|
||||
bool map_groups__empty(struct map_groups *mg)
|
||||
struct maps *maps__new(struct machine *machine)
|
||||
{
|
||||
return !maps__first(&mg->maps);
|
||||
}
|
||||
|
||||
struct map_groups *map_groups__new(struct machine *machine)
|
||||
{
|
||||
struct map_groups *mg = zalloc(sizeof(*mg));
|
||||
struct maps *mg = zalloc(sizeof(*mg)), *maps = mg;
|
||||
|
||||
if (mg != NULL)
|
||||
map_groups__init(mg, machine);
|
||||
maps__init(maps, machine);
|
||||
|
||||
return mg;
|
||||
}
|
||||
|
||||
void map_groups__delete(struct map_groups *mg)
|
||||
void maps__delete(struct maps *mg)
|
||||
{
|
||||
map_groups__exit(mg);
|
||||
maps__exit(mg);
|
||||
unwind__finish_access(mg);
|
||||
free(mg);
|
||||
}
|
||||
|
||||
void map_groups__put(struct map_groups *mg)
|
||||
void maps__put(struct maps *mg)
|
||||
{
|
||||
if (mg && refcount_dec_and_test(&mg->refcnt))
|
||||
map_groups__delete(mg);
|
||||
maps__delete(mg);
|
||||
}
|
||||
|
||||
struct symbol *map_groups__find_symbol(struct map_groups *mg,
|
||||
u64 addr, struct map **mapp)
|
||||
struct symbol *maps__find_symbol(struct maps *mg, u64 addr, struct map **mapp)
|
||||
{
|
||||
struct map *map = map_groups__find(mg, addr);
|
||||
struct map *map = maps__find(mg, addr);
|
||||
|
||||
/* Ensure map is loaded before using map->map_ip */
|
||||
if (map != NULL && map__load(map) >= 0) {
|
||||
@@ -660,8 +649,7 @@ static bool map__contains_symbol(struct map *map, struct symbol *sym)
|
||||
return ip >= map->start && ip < map->end;
|
||||
}
|
||||
|
||||
static struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name,
|
||||
struct map **mapp)
|
||||
struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, struct map **mapp)
|
||||
{
|
||||
struct symbol *sym;
|
||||
struct map *pos;
|
||||
@@ -688,19 +676,12 @@ out:
|
||||
return sym;
|
||||
}
|
||||
|
||||
struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg,
|
||||
const char *name,
|
||||
struct map **mapp)
|
||||
{
|
||||
return maps__find_symbol_by_name(&mg->maps, name, mapp);
|
||||
}
|
||||
|
||||
int map_groups__find_ams(struct map_groups *mg, struct addr_map_symbol *ams)
|
||||
int maps__find_ams(struct maps *mg, struct addr_map_symbol *ams)
|
||||
{
|
||||
if (ams->addr < ams->ms.map->start || ams->addr >= ams->ms.map->end) {
|
||||
if (mg == NULL)
|
||||
return -1;
|
||||
ams->ms.map = map_groups__find(mg, ams->addr);
|
||||
ams->ms.map = maps__find(mg, ams->addr);
|
||||
if (ams->ms.map == NULL)
|
||||
return -1;
|
||||
}
|
||||
@@ -711,7 +692,7 @@ int map_groups__find_ams(struct map_groups *mg, struct addr_map_symbol *ams)
|
||||
return ams->ms.sym ? 0 : -1;
|
||||
}
|
||||
|
||||
static size_t maps__fprintf(struct maps *maps, FILE *fp)
|
||||
size_t maps__fprintf(struct maps *maps, FILE *fp)
|
||||
{
|
||||
size_t printed = 0;
|
||||
struct map *pos;
|
||||
@@ -732,19 +713,8 @@ static size_t maps__fprintf(struct maps *maps, FILE *fp)
|
||||
return printed;
|
||||
}
|
||||
|
||||
size_t map_groups__fprintf(struct map_groups *mg, FILE *fp)
|
||||
int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
|
||||
{
|
||||
return maps__fprintf(&mg->maps, fp);
|
||||
}
|
||||
|
||||
static void __map_groups__insert(struct map_groups *mg, struct map *map)
|
||||
{
|
||||
__maps__insert(&mg->maps, map);
|
||||
}
|
||||
|
||||
int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, FILE *fp)
|
||||
{
|
||||
struct maps *maps = &mg->maps;
|
||||
struct rb_root *root;
|
||||
struct rb_node *next, *first;
|
||||
int err = 0;
|
||||
@@ -809,7 +779,7 @@ int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, FILE
|
||||
}
|
||||
|
||||
before->end = map->start;
|
||||
__map_groups__insert(mg, before);
|
||||
__maps__insert(maps, before);
|
||||
if (verbose >= 2 && !use_browser)
|
||||
map__fprintf(before, fp);
|
||||
map__put(before);
|
||||
@@ -826,7 +796,7 @@ int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, FILE
|
||||
after->start = map->end;
|
||||
after->pgoff += map->end - pos->start;
|
||||
assert(pos->map_ip(pos, map->end) == after->map_ip(after, map->end));
|
||||
__map_groups__insert(mg, after);
|
||||
__maps__insert(maps, after);
|
||||
if (verbose >= 2 && !use_browser)
|
||||
map__fprintf(after, fp);
|
||||
map__put(after);
|
||||
@@ -847,16 +817,15 @@ out:
|
||||
/*
|
||||
* XXX This should not really _copy_ te maps, but refcount them.
|
||||
*/
|
||||
int map_groups__clone(struct thread *thread, struct map_groups *parent)
|
||||
int maps__clone(struct thread *thread, struct maps *parent)
|
||||
{
|
||||
struct map_groups *mg = thread->mg;
|
||||
struct maps *mg = thread->mg;
|
||||
int err = -ENOMEM;
|
||||
struct map *map;
|
||||
struct maps *maps = &parent->maps;
|
||||
|
||||
down_read(&maps->lock);
|
||||
down_read(&parent->lock);
|
||||
|
||||
maps__for_each_entry(maps, map) {
|
||||
maps__for_each_entry(parent, map) {
|
||||
struct map *new = map__clone(map);
|
||||
if (new == NULL)
|
||||
goto out_unlock;
|
||||
@@ -865,13 +834,13 @@ int map_groups__clone(struct thread *thread, struct map_groups *parent)
|
||||
if (err)
|
||||
goto out_unlock;
|
||||
|
||||
map_groups__insert(mg, new);
|
||||
maps__insert(mg, new);
|
||||
map__put(new);
|
||||
}
|
||||
|
||||
err = 0;
|
||||
out_unlock:
|
||||
up_read(&maps->lock);
|
||||
up_read(&parent->lock);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -959,7 +928,7 @@ struct kmap *map__kmap(struct map *map)
|
||||
return kmap;
|
||||
}
|
||||
|
||||
struct map_groups *map__kmaps(struct map *map)
|
||||
struct maps *map__kmaps(struct map *map)
|
||||
{
|
||||
struct kmap *kmap = map__kmap(map);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <linux/types.h>
|
||||
|
||||
struct dso;
|
||||
struct map_groups;
|
||||
struct maps;
|
||||
struct machine;
|
||||
|
||||
struct map {
|
||||
@@ -42,7 +42,7 @@ struct kmap;
|
||||
|
||||
struct kmap *__map__kmap(struct map *map);
|
||||
struct kmap *map__kmap(struct map *map);
|
||||
struct map_groups *map__kmaps(struct map *map);
|
||||
struct maps *map__kmaps(struct map *map);
|
||||
|
||||
static inline u64 map__map_ip(struct map *map, u64 ip)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user