LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 18/52] perf map: Shorten map_groups__find_by_name() signature
Date: Wed,  2 May 2018 12:19:08 -0300	[thread overview]
Message-ID: <20180502151942.20542-19-acme@kernel.org> (raw)
In-Reply-To: <20180502151942.20542-1-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Another step in the road to elliminate the MAP_{FUNCTION,VARIABLE}
separation, reducing the exposure to these details in the tools using
the symbol APIs.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-8a1hvrqe3r5i0kw865u3uxwt@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/vmlinux-kallsyms.c | 2 +-
 tools/perf/util/machine.c           | 6 ++----
 tools/perf/util/map.h               | 8 ++++++--
 tools/perf/util/probe-event.c       | 2 +-
 tools/perf/util/symbol-elf.c        | 2 +-
 tools/perf/util/symbol.c            | 6 ++----
 6 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
index 1e5adb65632a..d80416e07f4b 100644
--- a/tools/perf/tests/vmlinux-kallsyms.c
+++ b/tools/perf/tests/vmlinux-kallsyms.c
@@ -183,7 +183,7 @@ int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest
 		 * so use the short name, less descriptive but the same ("[kernel]" in
 		 * both cases.
 		 */
-		pair = map_groups__find_by_name(&kallsyms.kmaps, type,
+		pair = map_groups__find_by_name(&kallsyms.kmaps,
 						(map->dso->kernel ?
 							map->dso->short_name :
 							map->dso->name));
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index e354d94a68e8..fc71f2c69c8b 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -673,8 +673,7 @@ struct map *machine__findnew_module_map(struct machine *machine, u64 start,
 	if (kmod_path__parse_name(&m, filename))
 		return NULL;
 
-	map = map_groups__find_by_name(&machine->kmaps, MAP__FUNCTION,
-				       m.name);
+	map = map_groups__find_by_name(&machine->kmaps, m.name);
 	if (map) {
 		/*
 		 * If the map's dso is an offline module, give dso__load()
@@ -1055,10 +1054,9 @@ static bool is_kmod_dso(struct dso *dso)
 static int map_groups__set_module_path(struct map_groups *mg, const char *path,
 				       struct kmod_path *m)
 {
-	struct map *map;
 	char *long_name;
+	struct map *map = map_groups__find_by_name(mg, m->name);
 
-	map = map_groups__find_by_name(mg, MAP__FUNCTION, m->name);
 	if (map == NULL)
 		return 0;
 
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index fc91bac8fed0..8ff75be0a965 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -254,8 +254,12 @@ struct symbol *map_groups__find_function_by_name(struct map_groups *mg,
 int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map,
 				   FILE *fp);
 
-struct map *map_groups__find_by_name(struct map_groups *mg,
-				     enum map_type type, const char *name);
+struct map *__map_groups__find_by_name(struct map_groups *mg, enum map_type type, const char *name);
+
+static inline struct map *map_groups__find_by_name(struct map_groups *mg, const char *name)
+{
+	return __map_groups__find_by_name(mg, MAP__FUNCTION, name);
+}
 
 bool __map__is_kernel(const struct map *map);
 
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index e1dbc9821617..d5e2516d5981 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -341,7 +341,7 @@ static int kernel_get_module_dso(const char *module, struct dso **pdso)
 		char module_name[128];
 
 		snprintf(module_name, sizeof(module_name), "[%s]", module);
-		map = map_groups__find_by_name(&host_machine->kmaps, MAP__FUNCTION, module_name);
+		map = map_groups__find_by_name(&host_machine->kmaps, module_name);
 		if (map) {
 			dso = map->dso;
 			goto found;
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 2de770511e70..75f578f3ed8e 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1042,7 +1042,7 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
 			snprintf(dso_name, sizeof(dso_name),
 				 "%s%s", dso->short_name, section_name);
 
-			curr_map = map_groups__find_by_name(kmaps, map->type, dso_name);
+			curr_map = __map_groups__find_by_name(kmaps, map->type, dso_name);
 			if (curr_map == NULL) {
 				u64 start = sym.st_value;
 
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 2b6292cff719..0bf4cf76f36a 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -792,8 +792,7 @@ static int dso__split_kallsyms(struct dso *dso, struct map *map, u64 delta)
 							curr_map->type);
 				}
 
-				curr_map = map_groups__find_by_name(kmaps,
-							map->type, module);
+				curr_map = __map_groups__find_by_name(kmaps, map->type, module);
 				if (curr_map == NULL) {
 					pr_debug("%s/proc/{kallsyms,modules} "
 					         "inconsistency while looking "
@@ -1667,8 +1666,7 @@ int dso__load(struct dso *dso, struct map *map)
 	return ret;
 }
 
-struct map *map_groups__find_by_name(struct map_groups *mg,
-				     enum map_type type, const char *name)
+struct map *__map_groups__find_by_name(struct map_groups *mg, enum map_type type, const char *name)
 {
 	struct maps *maps = &mg->maps[type];
 	struct map *map;
-- 
2.14.3

  parent reply	other threads:[~2018-05-02 15:30 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-02 15:18 [GIT PULL 00/52] perf/core improvements and fixes Arnaldo Carvalho de Melo
2018-05-02 15:18 ` [PATCH 01/52] perf buildid-cache: Support --list option Arnaldo Carvalho de Melo
2018-05-02 15:18 ` [PATCH 02/52] perf buildid-cache: Support --purge-all option Arnaldo Carvalho de Melo
2018-05-02 15:18 ` [PATCH 03/52] perf check-headers.sh: Simplify arguments passing Arnaldo Carvalho de Melo
2018-05-02 15:18 ` [PATCH 04/52] perf check-headers.sh: Add support to check 2 independent files Arnaldo Carvalho de Melo
2018-05-02 15:18 ` [PATCH 05/52] perf stat: Display time in precision based on std deviation Arnaldo Carvalho de Melo
2018-05-02 15:18 ` [PATCH 06/52] perf stat: Add --table option to display time of each run Arnaldo Carvalho de Melo
2018-05-02 15:18 ` [PATCH 07/52] perf stat: Display length strings of each run for --table option Arnaldo Carvalho de Melo
2018-05-02 15:18 ` [PATCH 08/52] perf top: Use __map__is_kernel() Arnaldo Carvalho de Melo
2018-05-02 15:18 ` [PATCH 09/52] perf symbols: Use __map__is_kernel() instead of ad-hoc equivalent code Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 10/52] perf dso: Add dso__has_symbols() method Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 11/52] perf map: Introduce map__has_symbols() Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 12/52] perf thread: Introduce thread__find_map() Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 13/52] perf tests: Let 'perf test list' display subtests Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 14/52] perf thread: Introduce thread__find_symbol() Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 15/52] perf script: Use thread__find_symbol() instead of ad-hoc equivalent Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 16/52] perf thread: Make thread__find_map() return the map Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 17/52] perf thread: Make thread__find_symbol() return the symbol searched Arnaldo Carvalho de Melo
2018-05-02 15:19 ` Arnaldo Carvalho de Melo [this message]
2018-05-02 15:19 ` [PATCH 19/52] perf Documentation: Support for asciidoctor Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 20/52] perf machine: Introduce machine__kernel_maps() Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 21/52] perf machine: Shorten machine__load_kallsyms() signature Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 22/52] perf machine: Remove needless map_type from machine__load_vmlinux_path() Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 23/52] perf tests vmlinux-kallsyms: Use machine__find_kernel_function(_by_name) Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 24/52] perf tests vmlinux-kallsyms: Use map__for_each_symbol() instead of open coded equivalent Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 25/52] perf map: Shorten map_groups__find() signature Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 26/52] perf ui stdio: Use map_groups__fprintf() Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 27/52] perf symbols: Shorten dso__(first|last)_symbol() Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 28/52] tools lib symbols: Introduce kallsyms__is_function() Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 29/52] perf tools: Use kallsyms__is_function() Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 30/52] perf symbols: Unexport symbol_type__is_a() Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 31/52] perf map: Remove enum_type arg to map_groups__first() Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 32/52] perf symbols: Remove map_type arg from dso__find_symbol() Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 33/52] perf thread: Remove addr_type arg from thread__find_cpumode_addr_location() Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 34/52] perf machine: Use machine__find_kernel_function() instead of open coded version Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 35/52] perf thread: Ditch __thread__find_symbol() Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 36/52] perf thread: Make thread__find_map() search all maps Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 37/52] perf map: Remove map_type arg from map_groups__find() Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 38/52] perf symbols: Store the ELF symbol type in the symbol struct Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 39/52] perf machine: Set PROT_EXEC for executable PERF_RECORD_MMAP records Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 40/52] perf sort: Use mmap->prot on "dcacheline" formatting Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 41/52] perf symbols: No need to special case MAP__FUNCTION in fixup Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 42/52] perf symbols: Use symbol type instead of map->type Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 43/52] perf map: Use map->prot in place of type==MAP__FUNCTION Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 44/52] perf symbols: " Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 45/52] perf symbols: Unify symbol maps Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 46/52] perf symbols: Remove needless goto Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 47/52] perf symbols: Split kernel symbol processing from dso__load_sym() Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 48/52] perf symbols: Remove unused dso__load_all_kallsyms() 'map' parameter Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 49/52] perf symbols: kallsyms__delta() needs the kmap, not the map Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 50/52] perf symbols: Move split_kallsyms to struct map_groups Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 51/52] perf tools: Fix spelling mistake: "builid" -> "buildid" Arnaldo Carvalho de Melo
2018-05-02 15:19 ` [PATCH 52/52] perf machine: Ditch find_kernel_function variants Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180502151942.20542-19-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=wangnan0@huawei.com \
    --cc=williams@redhat.com \
    --subject='Re: [PATCH 18/52] perf map: Shorten map_groups__find_by_name() signature' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).