Skip to content

Commit 41f3091

Browse files
committed
perf map: Move structs and prototypes for map groups to a separate header
And since machine.h only needs what is in there, make it stop including map.h and instead include this newly introduced map_groups.h instead. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lkml.kernel.org/n/tip-dbob25fv5rp2rjpwlnterf38@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 1101f69 commit 41f3091

11 files changed

Lines changed: 106 additions & 87 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "perf_regs.h"
44
#include "thread.h"
55
#include "map.h"
6+
#include "map_groups.h"
67
#include "event.h"
78
#include "debug.h"
89
#include "tests/tests.h"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "perf_regs.h"
44
#include "thread.h"
55
#include "map.h"
6+
#include "map_groups.h"
67
#include "event.h"
78
#include "debug.h"
89
#include "tests/tests.h"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "perf_regs.h"
44
#include "thread.h"
55
#include "map.h"
6+
#include "map_groups.h"
67
#include "event.h"
78
#include "debug.h"
89
#include "tests/tests.h"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "perf_regs.h"
44
#include "thread.h"
55
#include "map.h"
6+
#include "map_groups.h"
67
#include "event.h"
78
#include "debug.h"
89
#include "tests/tests.h"

‎tools/perf/ui/stdio/hist.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "../../util/util.h"
66
#include "../../util/hist.h"
77
#include "../../util/map.h"
8+
#include "../../util/map_groups.h"
89
#include "../../util/sort.h"
910
#include "../../util/evsel.h"
1011
#include "../../util/srcline.h"

‎tools/perf/util/machine.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <sys/types.h>
66
#include <linux/rbtree.h>
7-
#include "map.h"
7+
#include "map_groups.h"
88
#include "dso.h"
99
#include "event.h"
1010
#include "rwsem.h"

‎tools/perf/util/map.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,12 @@ void map_groups__init(struct map_groups *mg, struct machine *machine)
557557
refcount_set(&mg->refcnt, 1);
558558
}
559559

560+
void map_groups__insert(struct map_groups *mg, struct map *map)
561+
{
562+
maps__insert(&mg->maps, map);
563+
map->groups = mg;
564+
}
565+
560566
static void __maps__purge(struct maps *maps)
561567
{
562568
struct rb_root *root = &maps->entries;

‎tools/perf/util/map.h‎

Lines changed: 1 addition & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
#include <linux/compiler.h>
77
#include <linux/list.h>
88
#include <linux/rbtree.h>
9-
#include <pthread.h>
109
#include <stdio.h>
1110
#include <string.h>
1211
#include <stdbool.h>
1312
#include <linux/types.h>
14-
#include "rwsem.h"
1513

1614
struct dso;
1715
struct ip_callchain;
@@ -48,38 +46,7 @@ struct map {
4846
refcount_t refcnt;
4947
};
5048

51-
#define KMAP_NAME_LEN 256
52-
53-
struct kmap {
54-
struct ref_reloc_sym *ref_reloc_sym;
55-
struct map_groups *kmaps;
56-
char name[KMAP_NAME_LEN];
57-
};
58-
59-
struct maps {
60-
struct rb_root entries;
61-
struct rb_root names;
62-
struct rw_semaphore lock;
63-
};
64-
65-
struct map_groups {
66-
struct maps maps;
67-
struct machine *machine;
68-
refcount_t refcnt;
69-
};
70-
71-
struct map_groups *map_groups__new(struct machine *machine);
72-
void map_groups__delete(struct map_groups *mg);
73-
bool map_groups__empty(struct map_groups *mg);
74-
75-
static inline struct map_groups *map_groups__get(struct map_groups *mg)
76-
{
77-
if (mg)
78-
refcount_inc(&mg->refcnt);
79-
return mg;
80-
}
81-
82-
void map_groups__put(struct map_groups *mg);
49+
struct kmap;
8350

8451
struct kmap *__map__kmap(struct map *map);
8552
struct kmap *map__kmap(struct map *map);
@@ -187,61 +154,9 @@ void map__fixup_end(struct map *map);
187154

188155
void map__reloc_vmlinux(struct map *map);
189156

190-
void maps__insert(struct maps *maps, struct map *map);
191-
void maps__remove(struct maps *maps, struct map *map);
192-
struct map *maps__find(struct maps *maps, u64 addr);
193-
struct map *maps__first(struct maps *maps);
194-
struct map *map__next(struct map *map);
195-
struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name,
196-
struct map **mapp);
197-
void map_groups__init(struct map_groups *mg, struct machine *machine);
198-
void map_groups__exit(struct map_groups *mg);
199-
int map_groups__clone(struct thread *thread,
200-
struct map_groups *parent);
201-
size_t map_groups__fprintf(struct map_groups *mg, FILE *fp);
202-
203157
int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name,
204158
u64 addr);
205159

206-
static inline void map_groups__insert(struct map_groups *mg, struct map *map)
207-
{
208-
maps__insert(&mg->maps, map);
209-
map->groups = mg;
210-
}
211-
212-
static inline void map_groups__remove(struct map_groups *mg, struct map *map)
213-
{
214-
maps__remove(&mg->maps, map);
215-
}
216-
217-
static inline struct map *map_groups__find(struct map_groups *mg, u64 addr)
218-
{
219-
return maps__find(&mg->maps, addr);
220-
}
221-
222-
struct map *map_groups__first(struct map_groups *mg);
223-
224-
static inline struct map *map_groups__next(struct map *map)
225-
{
226-
return map__next(map);
227-
}
228-
229-
struct symbol *map_groups__find_symbol(struct map_groups *mg,
230-
u64 addr, struct map **mapp);
231-
232-
struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg,
233-
const char *name,
234-
struct map **mapp);
235-
236-
struct addr_map_symbol;
237-
238-
int map_groups__find_ams(struct addr_map_symbol *ams);
239-
240-
int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map,
241-
FILE *fp);
242-
243-
struct map *map_groups__find_by_name(struct map_groups *mg, const char *name);
244-
245160
bool __map__is_kernel(const struct map *map);
246161
bool __map__is_extra_kernel_map(const struct map *map);
247162

‎tools/perf/util/map_groups.h‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef __PERF_MAP_GROUPS_H
3+
#define __PERF_MAP_GROUPS_H
4+
5+
#include <linux/refcount.h>
6+
#include <linux/rbtree.h>
7+
#include <stdio.h>
8+
#include <stdbool.h>
9+
#include <linux/types.h>
10+
#include "rwsem.h"
11+
12+
struct ref_reloc_sym;
13+
struct machine;
14+
struct map;
15+
struct thread;
16+
17+
struct maps {
18+
struct rb_root entries;
19+
struct rb_root names;
20+
struct rw_semaphore lock;
21+
};
22+
23+
void maps__insert(struct maps *maps, struct map *map);
24+
void maps__remove(struct maps *maps, struct map *map);
25+
struct map *maps__find(struct maps *maps, u64 addr);
26+
struct map *maps__first(struct maps *maps);
27+
struct map *map__next(struct map *map);
28+
struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, struct map **mapp);
29+
30+
struct map_groups {
31+
struct maps maps;
32+
struct machine *machine;
33+
refcount_t refcnt;
34+
};
35+
36+
#define KMAP_NAME_LEN 256
37+
38+
struct kmap {
39+
struct ref_reloc_sym *ref_reloc_sym;
40+
struct map_groups *kmaps;
41+
char name[KMAP_NAME_LEN];
42+
};
43+
44+
struct map_groups *map_groups__new(struct machine *machine);
45+
void map_groups__delete(struct map_groups *mg);
46+
bool map_groups__empty(struct map_groups *mg);
47+
48+
static inline struct map_groups *map_groups__get(struct map_groups *mg)
49+
{
50+
if (mg)
51+
refcount_inc(&mg->refcnt);
52+
return mg;
53+
}
54+
55+
void map_groups__put(struct map_groups *mg);
56+
void map_groups__init(struct map_groups *mg, struct machine *machine);
57+
void map_groups__exit(struct map_groups *mg);
58+
int map_groups__clone(struct thread *thread, struct map_groups *parent);
59+
size_t map_groups__fprintf(struct map_groups *mg, FILE *fp);
60+
61+
void map_groups__insert(struct map_groups *mg, struct map *map);
62+
63+
static inline void map_groups__remove(struct map_groups *mg, struct map *map)
64+
{
65+
maps__remove(&mg->maps, map);
66+
}
67+
68+
static inline struct map *map_groups__find(struct map_groups *mg, u64 addr)
69+
{
70+
return maps__find(&mg->maps, addr);
71+
}
72+
73+
struct map *map_groups__first(struct map_groups *mg);
74+
75+
static inline struct map *map_groups__next(struct map *map)
76+
{
77+
return map__next(map);
78+
}
79+
80+
struct symbol *map_groups__find_symbol(struct map_groups *mg, u64 addr, struct map **mapp);
81+
struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg, const char *name, struct map **mapp);
82+
83+
struct addr_map_symbol;
84+
85+
int map_groups__find_ams(struct addr_map_symbol *ams);
86+
87+
int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, FILE *fp);
88+
89+
struct map *map_groups__find_by_name(struct map_groups *mg, const char *name);
90+
91+
#endif // __PERF_MAP_GROUPS_H

‎tools/perf/util/probe-event.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "cache.h"
4343
#include "color.h"
4444
#include "map.h"
45+
#include "map_groups.h"
4546
#include "symbol.h"
4647
#include "thread.h"
4748
#include <api/fs/fs.h>

0 commit comments

Comments
 (0)