Applications can place JIT-compiled code in POSIX shared memory so that
multiple processes can execute the same code. On Linux, these shared
memory objects appear as file mappings under /dev/shm.
Perf uses /tmp/perf-$pid.map to resolve symbols for executable SysV
shared memory mappings, but it treats /dev/shm mappings as ordinary
DSOs. As a result, applications which provide perf-map symbols for JIT
code in POSIX shared memory don't get those symbols resolved, while they
do with SysV shared memory.
It would be incorrect to classify every /dev/shm mapping as no-DSO
memory though, because /dev/shm is just a tmpfs mount, and it can
contain ELF files.
Add a filename prefix "/dev/shm/no-dso." which is recognized by
is_no_dso_memory(). Applications can opt-in by naming their shared
memory objects "no-dso.<name>". Executable mappings with this prefix
will use the perf-map file, while other /dev/shm mappings will keep the
existing behavior. This allows applications that already emit perf maps
to use POSIX shared memory for JIT code, without needing to implement
jitdump support.
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
---
tools/perf/util/map.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index fb0279810ae99..c2e31be232c88 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -258,6 +258,8 @@ static inline int is_no_dso_memory(const char *filename)
{
return !strncmp(filename, "[stack", 6) ||
!strncmp(filename, "/SYSV", 5) ||
+ !strncmp(filename, "/dev/shm/no-dso.",
+ sizeof("/dev/shm/no-dso.") - 1) ||
!strcmp(filename, "[heap]");
}
--
2.52.0