Skip to content

Commit 79b6bb7

Browse files
committed
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>
1 parent 9adab03 commit 79b6bb7

33 files changed

Lines changed: 209 additions & 275 deletions

‎tools/perf/arch/arm/tests/dwarf-unwind.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static int sample_ustack(struct perf_sample *sample,
2626

2727
sp = (unsigned long) regs[PERF_REG_ARM_SP];
2828

29-
map = map_groups__find(thread->mg, (u64)sp);
29+
map = maps__find(thread->mg, (u64)sp);
3030
if (!map) {
3131
pr_debug("failed to get stack map\n");
3232
free(buf);

‎tools/perf/arch/arm64/tests/dwarf-unwind.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static int sample_ustack(struct perf_sample *sample,
2626

2727
sp = (unsigned long) regs[PERF_REG_ARM64_SP];
2828

29-
map = map_groups__find(thread->mg, (u64)sp);
29+
map = maps__find(thread->mg, (u64)sp);
3030
if (!map) {
3131
pr_debug("failed to get stack map\n");
3232
free(buf);

‎tools/perf/arch/powerpc/tests/dwarf-unwind.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static int sample_ustack(struct perf_sample *sample,
2727

2828
sp = (unsigned long) regs[PERF_REG_POWERPC_R1];
2929

30-
map = map_groups__find(thread->mg, (u64)sp);
30+
map = maps__find(thread->mg, (u64)sp);
3131
if (!map) {
3232
pr_debug("failed to get stack map\n");
3333
free(buf);

‎tools/perf/arch/s390/annotate/instructions.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static int s390_call__parse(struct arch *arch, struct ins_operands *ops,
3838
return -1;
3939
target.addr = map__objdump_2mem(map, ops->target.addr);
4040

41-
if (map_groups__find_ams(ms->mg, &target) == 0 &&
41+
if (maps__find_ams(ms->mg, &target) == 0 &&
4242
map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr)
4343
ops->target.sym = target.ms.sym;
4444

‎tools/perf/arch/x86/tests/dwarf-unwind.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static int sample_ustack(struct perf_sample *sample,
2727

2828
sp = (unsigned long) regs[PERF_REG_X86_SP];
2929

30-
map = map_groups__find(thread->mg, (u64)sp);
30+
map = maps__find(thread->mg, (u64)sp);
3131
if (!map) {
3232
pr_debug("failed to get stack map\n");
3333
free(buf);

‎tools/perf/arch/x86/util/event.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ int perf_event__synthesize_extra_kmaps(struct perf_tool *tool,
1818
{
1919
int rc = 0;
2020
struct map *pos;
21-
struct map_groups *kmaps = &machine->kmaps;
22-
struct maps *maps = &kmaps->maps;
21+
struct maps *kmaps = &machine->kmaps;
2322
union perf_event *event = zalloc(sizeof(event->mmap) +
2423
machine->id_hdr_size);
2524

@@ -29,7 +28,7 @@ int perf_event__synthesize_extra_kmaps(struct perf_tool *tool,
2928
return -1;
3029
}
3130

32-
maps__for_each_entry(maps, pos) {
31+
maps__for_each_entry(kmaps, pos) {
3332
struct kmap *kmap;
3433
size_t size;
3534

‎tools/perf/builtin-report.c‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -780,11 +780,6 @@ static size_t maps__fprintf_task(struct maps *maps, int indent, FILE *fp)
780780
return printed;
781781
}
782782

783-
static int map_groups__fprintf_task(struct map_groups *mg, int indent, FILE *fp)
784-
{
785-
return maps__fprintf_task(&mg->maps, indent, fp);
786-
}
787-
788783
static void task__print_level(struct task *task, FILE *fp, int level)
789784
{
790785
struct thread *thread = task->thread;
@@ -795,7 +790,7 @@ static void task__print_level(struct task *task, FILE *fp, int level)
795790

796791
fprintf(fp, "%s\n", thread__comm_str(thread));
797792

798-
map_groups__fprintf_task(thread->mg, comm_indent, fp);
793+
maps__fprintf_task(thread->mg, comm_indent, fp);
799794

800795
if (!list_empty(&task->children)) {
801796
list_for_each_entry(child, &task->children, list)

‎tools/perf/tests/map_groups.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ struct map_def {
1313
u64 end;
1414
};
1515

16-
static int check_maps(struct map_def *merged, unsigned int size, struct map_groups *mg)
16+
static int check_maps(struct map_def *merged, unsigned int size, struct maps *maps)
1717
{
1818
struct map *map;
1919
unsigned int i = 0;
2020

21-
map_groups__for_each_entry(mg, map) {
21+
maps__for_each_entry(maps, map) {
2222
if (i > 0)
2323
TEST_ASSERT_VAL("less maps expected", (map && i < size) || (!map && i == size));
2424

@@ -35,7 +35,7 @@ static int check_maps(struct map_def *merged, unsigned int size, struct map_grou
3535

3636
int test__map_groups__merge_in(struct test *t __maybe_unused, int subtest __maybe_unused)
3737
{
38-
struct map_groups mg;
38+
struct maps mg;
3939
unsigned int i;
4040
struct map_def bpf_progs[] = {
4141
{ "bpf_prog_1", 200, 300 },
@@ -64,7 +64,7 @@ int test__map_groups__merge_in(struct test *t __maybe_unused, int subtest __mayb
6464
struct map *map_kcore1, *map_kcore2, *map_kcore3;
6565
int ret;
6666

67-
map_groups__init(&mg, NULL);
67+
maps__init(&mg, NULL);
6868

6969
for (i = 0; i < ARRAY_SIZE(bpf_progs); i++) {
7070
struct map *map;
@@ -74,7 +74,7 @@ int test__map_groups__merge_in(struct test *t __maybe_unused, int subtest __mayb
7474

7575
map->start = bpf_progs[i].start;
7676
map->end = bpf_progs[i].end;
77-
map_groups__insert(&mg, map);
77+
maps__insert(&mg, map);
7878
map__put(map);
7979
}
8080

@@ -99,19 +99,19 @@ int test__map_groups__merge_in(struct test *t __maybe_unused, int subtest __mayb
9999
map_kcore3->start = 880;
100100
map_kcore3->end = 1100;
101101

102-
ret = map_groups__merge_in(&mg, map_kcore1);
102+
ret = maps__merge_in(&mg, map_kcore1);
103103
TEST_ASSERT_VAL("failed to merge map", !ret);
104104

105105
ret = check_maps(merged12, ARRAY_SIZE(merged12), &mg);
106106
TEST_ASSERT_VAL("merge check failed", !ret);
107107

108-
ret = map_groups__merge_in(&mg, map_kcore2);
108+
ret = maps__merge_in(&mg, map_kcore2);
109109
TEST_ASSERT_VAL("failed to merge map", !ret);
110110

111111
ret = check_maps(merged12, ARRAY_SIZE(merged12), &mg);
112112
TEST_ASSERT_VAL("merge check failed", !ret);
113113

114-
ret = map_groups__merge_in(&mg, map_kcore3);
114+
ret = maps__merge_in(&mg, map_kcore3);
115115
TEST_ASSERT_VAL("failed to merge map", !ret);
116116

117117
ret = check_maps(merged3, ARRAY_SIZE(merged3), &mg);

‎tools/perf/tests/thread-mg-share.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ int test__thread_mg_share(struct test *test __maybe_unused, int subtest __maybe_
1212
/* thread group */
1313
struct thread *leader;
1414
struct thread *t1, *t2, *t3;
15-
struct map_groups *mg;
15+
struct maps *mg;
1616

1717
/* other process */
1818
struct thread *other, *other_leader;
19-
struct map_groups *other_mg;
19+
struct maps *other_mg;
2020

2121
/*
2222
* This test create 2 processes abstractions (struct thread)
2323
* with several threads and checks they properly share and
24-
* maintain map groups info (struct map_groups).
24+
* maintain maps info (struct maps).
2525
*
2626
* thread group (pid: 0, tids: 0, 1, 2, 3)
2727
* other group (pid: 4, tids: 4, 5)

‎tools/perf/tests/vmlinux-kallsyms.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,9 @@ int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest
190190
* so use the short name, less descriptive but the same ("[kernel]" in
191191
* both cases.
192192
*/
193-
pair = map_groups__find_by_name(&kallsyms.kmaps,
194-
(map->dso->kernel ?
195-
map->dso->short_name :
196-
map->dso->name));
193+
pair = maps__find_by_name(&kallsyms.kmaps, (map->dso->kernel ?
194+
map->dso->short_name :
195+
map->dso->name));
197196
if (pair) {
198197
pair->priv = 1;
199198
} else {
@@ -213,7 +212,7 @@ int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest
213212
mem_start = vmlinux_map->unmap_ip(vmlinux_map, map->start);
214213
mem_end = vmlinux_map->unmap_ip(vmlinux_map, map->end);
215214

216-
pair = map_groups__find(&kallsyms.kmaps, mem_start);
215+
pair = maps__find(&kallsyms.kmaps, mem_start);
217216
if (pair == NULL || pair->priv)
218217
continue;
219218

0 commit comments

Comments
 (0)