Skip to contentSkip to conversation

perf: Fallback to MAP__FUNCTION if daddr maps are NULL

PATCH Applied Don Zickus 4 participants 4 messages Aug 21, 2014 – Aug 24, 2014 perf events

lore
Share & tools
lore

Don Zickus

author
#0 lore raw

PATCH 1/1 perf: Fallback to MAP__FUNCTION if daddr maps are NULL

As we run "perf c2c" on more applications, we noticed we're missing significant samples from a common customer's application. Looking at the /proc/<pid>/maps file for the app, we see "rwxs" and "rwxp" permissions on many of the shared memory & heap regions, and on all the thread stacks.

Because those regions have the "x" bit set, perf marks them with a MAP_FUNCTION type. Hence ip_resolve_data() never finds load or store events coming from them.

We fixed this by re-calling thread__find_addr_location with MAP__FUNCTION in the case where map is NULL as a last ditch effort to map the sample before giving up and dropping it.

---
 tools/perf/util/machine.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
tools/perf/util/machine.c +10 -0
index 0e5fea9..e62bd87 100644
@@ -1241,6 +1241,16 @@ static void ip__resolve_data(struct machine *machine, struct thread *thread,
 
 	thread__find_addr_location(thread, machine, 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, machine, m, MAP__FUNCTION, addr,
+					   &al);
+	}
+
 	ams->addr = addr;
 	ams->al_addr = al.addr;
 	ams->sym = al.sym;
Signature · 1 line
1.7.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Don Zickus

As we run "perf c2c" on more applications, we noticed we're missing significant samples from a common customer's application. Looking at the /proc/<pid>/maps file for the app, we see "rwxs" and "rwxp" permissions on many of the shared memory & heap regions, and on all the thread stacks.

Because those regions have the "x" bit set, perf marks them with a MAP_FUNCTION type. Hence ip_resolve_data() never finds load or store events coming from them.

Quoted 7 lines

We fixed this by re-calling thread__find_addr_location with MAP__FUNCTION in the case where map is NULL as a last ditch effort to map the sample before giving up and dropping it.

thanks,
jirka

maintainer Applied
#2 lore raw

Em Thu, Aug 21, 2014 at 09:04:51AM +0200, Jiri Olsa escreveu:

Quoted 14 lines · Don Zickus
Quoted 13 lines

As we run "perf c2c" on more applications, we noticed we're missing significant samples from a common customer's application. Looking at the /proc/<pid>/maps file for the app, we see "rwxs" and "rwxp" permissions on many of the shared memory & heap regions, and on all the thread stacks.

Because those regions have the "x" bit set, perf marks them with a MAP_FUNCTION type. Hence ip_resolve_data() never finds load or store events coming from them.

We fixed this by re-calling thread__find_addr_location with MAP__FUNCTION in the case where map is NULL as a last ditch effort to map the sample before giving up and dropping it.

Quoted 5 lines
Quoted 3 lines

Thanks, applied.

- Arnaldo

#3 lore raw

[tip:perf/core] perf machine: Fallback to MAP__FUNCTION if daddr maps are NULL

In reply to Don Zickus
perf machine: Fallback to MAP__FUNCTION if daddr maps are NULL
Commit-ID:  06b2afc0b9a26e7673856a24ab57bfb307dad394
Gitweb:     http://git.kernel.org/tip/06b2afc0b9a26e7673856a24ab57bfb307dad394
Author:     Don Zickus <[email protected]>
AuthorDate: Wed, 20 Aug 2014 23:25:11 -0400
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 22 Aug 2014 13:12:13 -0300

perf machine: Fallback to MAP__FUNCTION if daddr maps are NULL

As we run "perf c2c" on more applications, we noticed we're missing significant samples from a common customer's application. Looking at the /proc/<pid>/maps file for the app, we see "rwxs" and "rwxp" permissions on many of the shared memory & heap regions, and on all the thread stacks.

Because those regions have the "x" bit set, perf marks them with a MAP_FUNCTION type. Hence ip_resolve_data() never finds load or store events coming from them.

We fixed this by re-calling thread__find_addr_location with MAP__FUNCTION in the case where map is NULL as a last ditch effort to map the sample before giving up and dropping it.

---
 tools/perf/util/machine.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
tools/perf/util/machine.c +10 -0
index e00daf0..b2ec38b 100644
@@ -1314,6 +1314,16 @@ static void ip__resolve_data(struct machine *machine, struct thread *thread,
 
 	thread__find_addr_location(thread, machine, 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, machine, m, MAP__FUNCTION, addr,
+					   &al);
+	}
+
 	ams->addr = addr;
 	ams->al_addr = al.addr;
 	ams->sym = al.sym;