Skip to contentSkip to conversation

perf maps: Rename 'mg' variables to 'maps'

tip: perf/urgent tip-bot2 for Arnaldo Carvalho de Melo 1 participant 1 message Nov 29, 2019 1 message not in the archive perf events

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

tip-bot2 for Arnaldo Carvalho de Melo

author merge bot Applied
#1 lore raw

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     9a29ceee6bb14aeb58ab2222c8e792576fe90fb8
Gitweb:        https://git.kernel.org/tip/9a29ceee6bb14aeb58ab2222c8e792576fe90fb8
Author:        Arnaldo Carvalho de Melo <[email protected]>
AuthorDate:    Mon, 25 Nov 2019 22:21:28 -03:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Tue, 26 Nov 2019 11:07:46 -03:00

perf maps: Rename 'mg' variables to 'maps'

Continuing the merge of 'struct maps' with 'struct map_groups'.

---
 tools/perf/tests/map_groups.c            | 18 ++---
 tools/perf/tests/thread-mg-share.c       | 18 ++---
 tools/perf/util/event.c                  | 12 +--
 tools/perf/util/machine.c                | 10 +--
 tools/perf/util/map.c                    | 89 +++++++++++------------
 tools/perf/util/map_groups.h             | 36 ++++-----
 tools/perf/util/symbol.c                 | 44 +++++------
 tools/perf/util/symbol.h                 |  2 +-
 tools/perf/util/unwind-libunwind-local.c | 16 ++--
 tools/perf/util/unwind-libunwind.c       | 30 ++++----
 10 files changed, 135 insertions(+), 140 deletions(-)
tools/perf/tests/map_groups.c +9 -9
index db806e5..9df1d14 100644
@@ -35,7 +35,7 @@ static int check_maps(struct map_def *merged, unsigned int size, struct maps *ma
 
 int test__map_groups__merge_in(struct test *t __maybe_unused, int subtest __maybe_unused)
 {
-	struct maps mg;
+	struct maps maps;
 	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;
 
-	maps__init(&mg, NULL);
+	maps__init(&maps, 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;
-		maps__insert(&mg, map);
+		maps__insert(&maps, map);
 		map__put(map);
 	}
 
@@ -99,22 +99,22 @@ int test__map_groups__merge_in(struct test *t __maybe_unused, int subtest __mayb
 	map_kcore3->start = 880;
 	map_kcore3->end   = 1100;
 
-	ret = maps__merge_in(&mg, map_kcore1);
+	ret = maps__merge_in(&maps, map_kcore1);
 	TEST_ASSERT_VAL("failed to merge map", !ret);
 
-	ret = check_maps(merged12, ARRAY_SIZE(merged12), &mg);
+	ret = check_maps(merged12, ARRAY_SIZE(merged12), &maps);
 	TEST_ASSERT_VAL("merge check failed", !ret);
 
-	ret = maps__merge_in(&mg, map_kcore2);
+	ret = maps__merge_in(&maps, map_kcore2);
 	TEST_ASSERT_VAL("failed to merge map", !ret);
 
-	ret = check_maps(merged12, ARRAY_SIZE(merged12), &mg);
+	ret = check_maps(merged12, ARRAY_SIZE(merged12), &maps);
 	TEST_ASSERT_VAL("merge check failed", !ret);
 
-	ret = maps__merge_in(&mg, map_kcore3);
+	ret = maps__merge_in(&maps, map_kcore3);
 	TEST_ASSERT_VAL("failed to merge map", !ret);
 
-	ret = check_maps(merged3, ARRAY_SIZE(merged3), &mg);
+	ret = check_maps(merged3, ARRAY_SIZE(merged3), &maps);
 	TEST_ASSERT_VAL("merge check failed", !ret);
 	return TEST_OK;
 }
tools/perf/tests/thread-mg-share.c +9 -9
index 6032061..e3b0d69 100644
@@ -12,7 +12,7 @@ int test__thread_mg_share(struct test *test __maybe_unused, int subtest __maybe_
 	/* thread group */
 	struct thread *leader;
 	struct thread *t1, *t2, *t3;
-	struct maps *mg;
+	struct maps *maps;
 
 	/* other process */
 	struct thread *other, *other_leader;
@@ -42,13 +42,13 @@ int test__thread_mg_share(struct test *test __maybe_unused, int subtest __maybe_
 	TEST_ASSERT_VAL("failed to create threads",
 			leader && t1 && t2 && t3 && other);
 
-	mg = leader->maps;
-	TEST_ASSERT_EQUAL("wrong refcnt", refcount_read(&mg->refcnt), 4);
+	maps = leader->maps;
+	TEST_ASSERT_EQUAL("wrong refcnt", refcount_read(&maps->refcnt), 4);
 
 	/* test the map groups pointer is shared */
-	TEST_ASSERT_VAL("map groups don't match", mg == t1->maps);
-	TEST_ASSERT_VAL("map groups don't match", mg == t2->maps);
-	TEST_ASSERT_VAL("map groups don't match", mg == t3->maps);
+	TEST_ASSERT_VAL("map groups don't match", maps == t1->maps);
+	TEST_ASSERT_VAL("map groups don't match", maps == t2->maps);
+	TEST_ASSERT_VAL("map groups don't match", maps == t3->maps);
 
 	/*
 	 * Verify the other leader was created by previous call.
@@ -77,13 +77,13 @@ int test__thread_mg_share(struct test *test __maybe_unused, int subtest __maybe_
 
 	/* release thread group */
 	thread__put(leader);
-	TEST_ASSERT_EQUAL("wrong refcnt", refcount_read(&mg->refcnt), 3);
+	TEST_ASSERT_EQUAL("wrong refcnt", refcount_read(&maps->refcnt), 3);
 
 	thread__put(t1);
-	TEST_ASSERT_EQUAL("wrong refcnt", refcount_read(&mg->refcnt), 2);
+	TEST_ASSERT_EQUAL("wrong refcnt", refcount_read(&maps->refcnt), 2);
 
 	thread__put(t2);
-	TEST_ASSERT_EQUAL("wrong refcnt", refcount_read(&mg->refcnt), 1);
+	TEST_ASSERT_EQUAL("wrong refcnt", refcount_read(&maps->refcnt), 1);
 
 	thread__put(t3);
 
tools/perf/util/event.c +6 -6
index fc3da38..c5447ff 100644
@@ -457,11 +457,11 @@ 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 maps *mg = thread->maps;
-	struct machine *machine = mg->machine;
+	struct maps *maps = thread->maps;
+	struct machine *machine = maps->machine;
 	bool load_map = false;
 
-	al->maps = mg;
+	al->maps = maps;
 	al->thread = thread;
 	al->addr = addr;
 	al->cpumode = cpumode;
@@ -474,13 +474,13 @@ struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr,
 
 	if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) {
 		al->level = 'k';
-		al->maps = mg = &machine->kmaps;
+		al->maps = maps = &machine->kmaps;
 		load_map = true;
 	} else if (cpumode == PERF_RECORD_MISC_USER && perf_host) {
 		al->level = '.';
 	} else if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest) {
 		al->level = 'g';
-		al->maps = mg = &machine->kmaps;
+		al->maps = maps = &machine->kmaps;
 		load_map = true;
 	} else if (cpumode == PERF_RECORD_MISC_GUEST_USER && perf_guest) {
 		al->level = 'u';
@@ -500,7 +500,7 @@ struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr,
 		return NULL;
 	}
 
-	al->map = maps__find(mg, al->addr);
+	al->map = maps__find(maps, al->addr);
 	if (al->map != NULL) {
 		/*
 		 * Kernel maps might be changed when loading symbols so loading
tools/perf/util/machine.c +5 -5
index c1ae5e6..416d174 100644
@@ -1259,10 +1259,10 @@ static bool is_kmod_dso(struct dso *dso)
 	       dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE;
 }
 
-static int maps__set_module_path(struct maps *mg, const char *path, struct kmod_path *m)
+static int maps__set_module_path(struct maps *maps, const char *path, struct kmod_path *m)
 {
 	char *long_name;
-	struct map *map = maps__find_by_name(mg, m->name);
+	struct map *map = maps__find_by_name(maps, m->name);
 
 	if (map == NULL)
 		return 0;
@@ -1286,7 +1286,7 @@ static int maps__set_module_path(struct maps *mg, const char *path, struct kmod_
 	return 0;
 }
 
-static int maps__set_modules_path_dir(struct maps *mg, const char *dir_name, int depth)
+static int maps__set_modules_path_dir(struct maps *maps, const char *dir_name, int depth)
 {
 	struct dirent *dent;
 	DIR *dir = opendir(dir_name);
@@ -1318,7 +1318,7 @@ static int maps__set_modules_path_dir(struct maps *mg, const char *dir_name, int
 					continue;
 			}
 
-			ret = maps__set_modules_path_dir(mg, path, depth + 1);
+			ret = maps__set_modules_path_dir(maps, path, depth + 1);
 			if (ret < 0)
 				goto out;
 		} else {
@@ -1329,7 +1329,7 @@ static int maps__set_modules_path_dir(struct maps *mg, const char *dir_name, int
 				goto out;
 
 			if (m.kmod)
-				ret = maps__set_module_path(mg, path, &m);
+				ret = maps__set_module_path(maps, path, &m);
 
 			zfree(&m.name);
 
tools/perf/util/map.c +43 -46

171 lines not on this page · raw message

tools/perf/util/map_groups.h +18 -18
index 8a45994..ada2f40 100644
@@ -49,39 +49,39 @@ struct kmap {
 };
 
 struct maps *maps__new(struct machine *machine);
-void maps__delete(struct maps *mg);
-bool maps__empty(struct maps *mg);
+void maps__delete(struct maps *maps);
+bool maps__empty(struct maps *maps);
 
-static inline struct maps *maps__get(struct maps *mg)
+static inline struct maps *maps__get(struct maps *maps)
 {
-	if (mg)
-		refcount_inc(&mg->refcnt);
-	return mg;
+	if (maps)
+		refcount_inc(&maps->refcnt);
+	return maps;
 }
 
-void maps__put(struct maps *mg);
-void maps__init(struct maps *mg, struct machine *machine);
-void maps__exit(struct maps *mg);
+void maps__put(struct maps *maps);
+void maps__init(struct maps *maps, struct machine *machine);
+void maps__exit(struct maps *maps);
 int maps__clone(struct thread *thread, struct maps *parent);
-size_t maps__fprintf(struct maps *mg, FILE *fp);
+size_t maps__fprintf(struct maps *maps, FILE *fp);
 
-void maps__insert(struct maps *mg, struct map *map);
+void maps__insert(struct maps *maps, struct map *map);
 
-void maps__remove(struct maps *mg, struct map *map);
+void maps__remove(struct maps *maps, struct map *map);
 
-struct symbol *maps__find_symbol(struct maps *mg, u64 addr, struct map **mapp);
-struct symbol *maps__find_symbol_by_name(struct maps *mg, const char *name, struct map **mapp);
+struct symbol *maps__find_symbol(struct maps *maps, u64 addr, struct map **mapp);
+struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, struct map **mapp);
 
 struct addr_map_symbol;
 
-int maps__find_ams(struct maps *mg, struct addr_map_symbol *ams);
+int maps__find_ams(struct maps *maps, struct addr_map_symbol *ams);
 
-int maps__fixup_overlappings(struct maps *mg, struct map *map, FILE *fp);
+int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp);
 
-struct map *maps__find_by_name(struct maps *mg, const char *name);
+struct map *maps__find_by_name(struct maps *maps, const char *name);
 
 int maps__merge_in(struct maps *kmaps, struct map *new_map);
 
-void __maps__sort_by_name(struct maps *mg);
+void __maps__sort_by_name(struct maps *maps);
 
 #endif // __PERF_MAP_GROUPS_H
tools/perf/util/symbol.c +21 -23

98 lines not on this page · raw message

tools/perf/util/symbol.h +1 -1
index 29c4ea4..93fc43d 100644
@@ -186,7 +186,7 @@ void __symbols__insert(struct rb_root_cached *symbols, struct symbol *sym,
 void symbols__insert(struct rb_root_cached *symbols, struct symbol *sym);
 void symbols__fixup_duplicate(struct rb_root_cached *symbols);
 void symbols__fixup_end(struct rb_root_cached *symbols);
-void maps__fixup_end(struct maps *mg);
+void maps__fixup_end(struct maps *maps);
 
 typedef int (*mapfn_t)(u64 start, u64 len, u64 pgoff, void *data);
 int file__read_maps(int fd, bool exe, mapfn_t mapfn, void *data,
tools/perf/util/unwind-libunwind-local.c +8 -8
index 515131e..b4649f5 100644
@@ -616,26 +616,26 @@ static unw_accessors_t accessors = {
 	.get_proc_name		= get_proc_name,
 };
 
-static int _unwind__prepare_access(struct maps *mg)
+static int _unwind__prepare_access(struct maps *maps)
 {
-	mg->addr_space = unw_create_addr_space(&accessors, 0);
-	if (!mg->addr_space) {
+	maps->addr_space = unw_create_addr_space(&accessors, 0);
+	if (!maps->addr_space) {
 		pr_err("unwind: Can't create unwind address space.\n");
 		return -ENOMEM;
 	}
 
-	unw_set_caching_policy(mg->addr_space, UNW_CACHE_GLOBAL);
+	unw_set_caching_policy(maps->addr_space, UNW_CACHE_GLOBAL);
 	return 0;
 }
 
-static void _unwind__flush_access(struct maps *mg)
+static void _unwind__flush_access(struct maps *maps)
 {
-	unw_flush_cache(mg->addr_space, 0, 0);
+	unw_flush_cache(maps->addr_space, 0, 0);
 }
 
-static void _unwind__finish_access(struct maps *mg)
+static void _unwind__finish_access(struct maps *maps)
 {
-	unw_destroy_addr_space(mg->addr_space);
+	unw_destroy_addr_space(maps->addr_space);
 }
 
 static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
tools/perf/util/unwind-libunwind.c +15 -15
index 4003ae8..e89a547 100644
@@ -12,12 +12,12 @@ struct unwind_libunwind_ops __weak *local_unwind_libunwind_ops;
 struct unwind_libunwind_ops __weak *x86_32_unwind_libunwind_ops;
 struct unwind_libunwind_ops __weak *arm64_unwind_libunwind_ops;
 
-static void unwind__register_ops(struct maps *mg, struct unwind_libunwind_ops *ops)
+static void unwind__register_ops(struct maps *maps, struct unwind_libunwind_ops *ops)
 {
-	mg->unwind_libunwind_ops = ops;
+	maps->unwind_libunwind_ops = ops;
 }
 
-int unwind__prepare_access(struct maps *mg, struct map *map, bool *initialized)
+int unwind__prepare_access(struct maps *maps, struct map *map, bool *initialized)
 {
 	const char *arch;
 	enum dso_type dso_type;
@@ -27,7 +27,7 @@ int unwind__prepare_access(struct maps *mg, struct map *map, bool *initialized)
 	if (!dwarf_callchain_users)
 		return 0;
 
-	if (mg->addr_space) {
+	if (maps->addr_space) {
 		pr_debug("unwind: thread map already set, dso=%s\n",
 			 map->dso->name);
 		if (initialized)
@@ -36,14 +36,14 @@ int unwind__prepare_access(struct maps *mg, struct map *map, bool *initialized)
 	}
 
 	/* env->arch is NULL for live-mode (i.e. perf top) */
-	if (!mg->machine->env || !mg->machine->env->arch)
+	if (!maps->machine->env || !maps->machine->env->arch)
 		goto out_register;
 
-	dso_type = dso__type(map->dso, mg->machine);
+	dso_type = dso__type(map->dso, maps->machine);
 	if (dso_type == DSO__TYPE_UNKNOWN)
 		return 0;
 
-	arch = perf_env__arch(mg->machine->env);
+	arch = perf_env__arch(maps->machine->env);
 
 	if (!strcmp(arch, "x86")) {
 		if (dso_type != DSO__TYPE_64BIT)
@@ -58,24 +58,24 @@ int unwind__prepare_access(struct maps *mg, struct map *map, bool *initialized)
 		return 0;
 	}
 out_register:
-	unwind__register_ops(mg, ops);
+	unwind__register_ops(maps, ops);
 
-	err = mg->unwind_libunwind_ops->prepare_access(mg);
+	err = maps->unwind_libunwind_ops->prepare_access(maps);
 	if (initialized)
 		*initialized = err ? false : true;
 	return err;
 }
 
-void unwind__flush_access(struct maps *mg)
+void unwind__flush_access(struct maps *maps)
 {
-	if (mg->unwind_libunwind_ops)
-		mg->unwind_libunwind_ops->flush_access(mg);
+	if (maps->unwind_libunwind_ops)
+		maps->unwind_libunwind_ops->flush_access(maps);
 }
 
-void unwind__finish_access(struct maps *mg)
+void unwind__finish_access(struct maps *maps)
 {
-	if (mg->unwind_libunwind_ops)
-		mg->unwind_libunwind_ops->finish_access(mg);
+	if (maps->unwind_libunwind_ops)
+		maps->unwind_libunwind_ops->finish_access(maps);
 }
 
 int unwind__get_entries(unwind_entry_cb_t cb, void *arg,