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 14/52] perf thread: Introduce thread__find_symbol()
Date: Wed,  2 May 2018 12:19:04 -0300	[thread overview]
Message-ID: <20180502151942.20542-15-acme@kernel.org> (raw)
In-Reply-To: <20180502151942.20542-1-acme@kernel.org>

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

Out of thread__find_addr_location(..., MAP__FUNCTION, ...), idea here is to
continue removing references to MAP__{FUNCTION,VARIABLE} ahead of
getting both types of symbols in the same rbtree, as various places do
two lookups, looking first at MAP__FUNCTION, then at MAP__VARIABLE.

So thread__find_symbol() will eventually do just that, and 'struct
symbol' will have the symbol type, for code that cares about that.

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-n7528en9e08yd3flzmb26tth@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/arch/powerpc/util/skip-callchain-idx.c |  3 +--
 tools/perf/builtin-timechart.c                    |  3 +--
 tools/perf/builtin-trace.c                        |  9 +++------
 tools/perf/util/event.c                           |  6 +++---
 tools/perf/util/machine.c                         |  7 +++----
 tools/perf/util/thread.c                          |  2 +-
 tools/perf/util/thread.h                          | 11 ++++++++---
 tools/perf/util/unwind-libdw.c                    |  9 +++++----
 tools/perf/util/unwind-libunwind-local.c          |  3 +--
 9 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/tools/perf/arch/powerpc/util/skip-callchain-idx.c b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
index 0c370f81e002..3598b8b75d27 100644
--- a/tools/perf/arch/powerpc/util/skip-callchain-idx.c
+++ b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
@@ -248,8 +248,7 @@ int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain)
 
 	ip = chain->ips[2];
 
-	thread__find_addr_location(thread, PERF_RECORD_MISC_USER,
-			MAP__FUNCTION, ip, &al);
+	thread__find_symbol(thread, PERF_RECORD_MISC_USER, ip, &al);
 
 	if (al.map)
 		dso = al.map->dso;
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 813698a9b8c7..38fcbb5ddce8 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -533,8 +533,7 @@ static const char *cat_backtrace(union perf_event *event,
 		}
 
 		tal.filtered = 0;
-		thread__find_addr_location(al.thread, cpumode,
-					   MAP__FUNCTION, ip, &tal);
+		thread__find_symbol(al.thread, cpumode, ip, &tal);
 
 		if (tal.sym)
 			fprintf(f, "..... %016" PRIx64 " %s\n", ip,
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 3ad17ee89403..afec6f9ffd89 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2024,8 +2024,7 @@ static int trace__pgfault(struct trace *trace,
 	if (trace->summary_only)
 		goto out;
 
-	thread__find_addr_location(thread, sample->cpumode, MAP__FUNCTION,
-			      sample->ip, &al);
+	thread__find_symbol(thread, sample->cpumode, sample->ip, &al);
 
 	trace__fprintf_entry_head(trace, thread, 0, true, sample->time, trace->output);
 
@@ -2037,12 +2036,10 @@ static int trace__pgfault(struct trace *trace,
 
 	fprintf(trace->output, "] => ");
 
-	thread__find_addr_location(thread, sample->cpumode, MAP__VARIABLE,
-				   sample->addr, &al);
+	__thread__find_symbol(thread, sample->cpumode, MAP__VARIABLE, sample->addr, &al);
 
 	if (!al.map) {
-		thread__find_addr_location(thread, sample->cpumode,
-					   MAP__FUNCTION, sample->addr, &al);
+		thread__find_symbol(thread, sample->cpumode, sample->addr, &al);
 
 		if (al.map)
 			map_type = 'x';
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index baa97d0b6114..2d860fbeb227 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1564,9 +1564,9 @@ void __thread__find_map(struct thread *thread, u8 cpumode, enum map_type type,
 	}
 }
 
-void thread__find_addr_location(struct thread *thread,
-				u8 cpumode, enum map_type type, u64 addr,
-				struct addr_location *al)
+void __thread__find_symbol(struct thread *thread, u8 cpumode,
+			   enum map_type type, u64 addr,
+			   struct addr_location *al)
 {
 	__thread__find_map(thread, cpumode, type, addr, al);
 	if (al->map != NULL)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 32d50492505d..e354d94a68e8 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1681,14 +1681,14 @@ static void ip__resolve_data(struct thread *thread,
 
 	memset(&al, 0, sizeof(al));
 
-	thread__find_addr_location(thread, m, MAP__VARIABLE, addr, &al);
+	__thread__find_symbol(thread, m, MAP__VARIABLE, addr, &al);
 	if (al.map == NULL) {
 		/*
 		 * some shared data regions have execute bit set which puts
 		 * their mapping in the MAP__FUNCTION type array.
 		 * Check there as a fallback option before dropping the sample.
 		 */
-		thread__find_addr_location(thread, m, MAP__FUNCTION, addr, &al);
+		thread__find_symbol(thread, m, addr, &al);
 	}
 
 	ams->addr = addr;
@@ -1784,8 +1784,7 @@ static int add_callchain_ip(struct thread *thread,
 			}
 			return 0;
 		}
-		thread__find_addr_location(thread, *cpumode, MAP__FUNCTION,
-					   ip, &al);
+		thread__find_symbol(thread, *cpumode, ip, &al);
 	}
 
 	if (al.sym != NULL) {
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 68b65b10579b..2a3fb7c6b39d 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -384,7 +384,7 @@ void thread__find_cpumode_addr_location(struct thread *thread,
 	};
 
 	for (i = 0; i < ARRAY_SIZE(cpumodes); i++) {
-		thread__find_addr_location(thread, cpumodes[i], type, addr, al);
+		__thread__find_symbol(thread, cpumodes[i], type, addr, al);
 		if (al->map)
 			break;
 	}
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index 52c788f955de..b69e65c821f9 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -101,9 +101,14 @@ static inline void thread__find_map(struct thread *thread, u8 cpumode,
 	__thread__find_map(thread, cpumode, MAP__FUNCTION, addr, al);
 }
 
-void thread__find_addr_location(struct thread *thread,
-				u8 cpumode, enum map_type type, u64 addr,
-				struct addr_location *al);
+void __thread__find_symbol(struct thread *thread, u8 cpumode, enum map_type type,
+			   u64 addr, struct addr_location *al);
+
+static inline void thread__find_symbol(struct thread *thread, u8 cpumode,
+				       u64 addr, struct addr_location *al)
+{
+	return __thread__find_symbol(thread, cpumode, MAP__FUNCTION, addr, al);
+}
 
 void thread__find_cpumode_addr_location(struct thread *thread,
 					enum map_type type, u64 addr,
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index 1ce8744649b5..bdc22f1864df 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -28,10 +28,11 @@ static int __report_module(struct addr_location *al, u64 ip,
 {
 	Dwfl_Module *mod;
 	struct dso *dso = NULL;
-
-	thread__find_addr_location(ui->thread,
-				   PERF_RECORD_MISC_USER,
-				   MAP__FUNCTION, ip, al);
+	/*
+	 * Some callers will use al->sym, so we can't just use the
+	 * cheaper thread__find_map() here.
+	 */
+	thread__find_symbol(ui->thread, PERF_RECORD_MISC_USER, ip, al);
 
 	if (al->map)
 		dso = al->map->dso;
diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
index 33afca5c04f6..0007c64f3220 100644
--- a/tools/perf/util/unwind-libunwind-local.c
+++ b/tools/perf/util/unwind-libunwind-local.c
@@ -585,8 +585,7 @@ static int entry(u64 ip, struct thread *thread,
 	struct unwind_entry e;
 	struct addr_location al;
 
-	thread__find_addr_location(thread, PERF_RECORD_MISC_USER,
-				   MAP__FUNCTION, ip, &al);
+	thread__find_symbol(thread, PERF_RECORD_MISC_USER, ip, &al);
 
 	e.ip = al.addr;
 	e.map = al.map;
-- 
2.14.3

  parent reply	other threads:[~2018-05-02 15:20 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 ` Arnaldo Carvalho de Melo [this message]
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 ` [PATCH 18/52] perf map: Shorten map_groups__find_by_name() signature Arnaldo Carvalho de Melo
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-15-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 14/52] perf thread: Introduce thread__find_symbol()' \
    /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).