perf fixes
Subsystems (2)
Linus,
Please pull the latest perf-urgent-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf-urgent-for-linus
HEAD: 8a3da6c7d0031fcb6a0d17f9c7a68b0e01f52855 perf/x86: Fix PMU detection printout when no PMU is detected
A couple of tooling fixlets and a PMU detection printout fix.
Thanks,
Ingo
------------------>
Adrian Hunter (1):
perf machine: Fix path unpopulated in machine__create_modules()
Andi Kleen (1):
perf symbols: Demangle cloned functions
David Ahern (2):
perf trace: Add mmap2 handler
perf tools: Explicitly add libdl dependency
Ingo Molnar (1):
perf/x86: Fix PMU detection printout when no PMU is detected
Jiri Olsa (1):
perf kmem: Make it work again on non NUMA machines
Masami Hiramatsu (1):
perf probe: Fix probing symbols with optimization suffix
arch/x86/kernel/cpu/perf_event.c | 2 +- tools/perf/builtin-kmem.c | 2 +- tools/perf/builtin-trace.c | 1 + tools/perf/config/Makefile | 2 +- tools/perf/util/machine.c | 2 +- tools/perf/util/probe-finder.c | 77 +++++++++++++++++++++------------------- tools/perf/util/probe-finder.h | 3 ++ tools/perf/util/symbol-elf.c | 27 +++++++++++++- 8 files changed, 75 insertions(+), 41 deletions(-)
arch/x86/kernel/cpu/perf_event.c +1 -1
@@ -1506,7 +1506,7 @@ static int __init init_hw_perf_events(void) err =amd_pmu_init ();break ;default : -return 0 ; + err = -ENOTSUPP ; }if (err !=0 ) {pr_cont ("no PMU driver, software events only.\n" );
tools/perf/builtin-kmem.c +1 -1
@@ -101,7 +101,7 @@ static int setup_cpunode_map(void) dir1 =opendir (PATH_SYS_NODE );if (!dir1) -return -1 ; +return 0 ;while ((dent1 =readdir (dir1)) !=NULL ) { if (dent1->d_type != DT_DIR ||
tools/perf/builtin-trace.c +1 -0
@@ -1055,6 +1055,7 @@ static int trace__replay(struct trace *trace) trace->tool.sample = trace__process_sample; trace->tool.mmap = perf_event__process_mmap; + trace->tool.mmap2 = perf_event__process_mmap2; trace->tool.comm = perf_event__process_comm; trace->tool.exit = perf_event__process_exit; trace->tool.fork = perf_event__process_fork;
tools/perf/config/Makefile +1 -1
@@ -87,7 +87,7 @@ CFLAGS += -Wall CFLAGS += -Wextra CFLAGS += -std=gnu99 -EXTLIBS = -lelf -lpthread -lrt -lm +EXTLIBS = -lelf -lpthread -lrt -lm -ldl ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) CFLAGS += -fstack-protector-all
tools/perf/util/machine.c +1 -1
@@ -792,7 +792,7 @@ static int machine__create_modules(struct machine *machine) modules = path; } -if (symbol__restricted_filename (path,"/proc/modules" )) +if (symbol__restricted_filename (modules,"/proc/modules" ))return -1 ; file =fopen (modules,"r" );
tools/perf/util/probe-finder.c +41 -36
123 lines not on this page · raw message
tools/perf/util/probe-finder.h +3 -0
@@ -23,6 +23,7 @@ static inline int is_c_varname(const char *name)/* debug information structure */ struct debuginfo {Dwarf *dbg; +Dwfl_Module *mod;Dwfl *dwfl;Dwarf_Addr bias; };
@@ -77,6 +78,7 @@ struct probe_finder {struct trace_event_finder {struct probe_finder pf; +Dwfl_Module *mod;/* For solving symbols */ struct probe_trace_event *tevs;/* Found trace events */ int ntevs;/* Number of trace events */ int max_tevs;/* Max number of trace events */
@@ -84,6 +86,7 @@ struct trace_event_finder {struct available_var_finder {struct probe_finder pf; +Dwfl_Module *mod;/* For solving symbols */ struct variable_list *vls;/* Found variable lists */ int nvls;/* Number of variable lists */ int max_vls;/* Max no. of variable lists */
tools/perf/util/symbol-elf.c +26 -1
@@ -928,8 +928,33 @@ int dso__load_sym(struct dso *dso, struct map *map,* to it... */ if (symbol_conf.demangle) { - demangled =bfd_demangle (NULL , elf_name, +/* +* The demangler doesn't deal with cloned functions. +* XXXX.clone.NUM or similar +* Strip the dot part and readd it later. +*/ +char *p = (char *)elf_name, *dot; + dot =strchr (elf_name,'.' ); +if (dot) { + p =strdup (elf_name); +if (!p) + goto new_symbol; + dot =strchr (p,'.' ); + *dot =0 ; + } + + demangled =bfd_demangle (NULL , p,DMGL_PARAMS |DMGL_ANSI ); +if (dot) + *dot ='.' ; +if (demangled && dot) { + demangled =realloc (demangled,strlen (demangled) +strlen (dot) +1 ); +if (!demangled) + goto new_symbol; +strcpy (demangled + (dot - p), dot); + } +if (p != elf_name) +free (p);if (demangled !=NULL ) elf_name = demangled; }
Quoted 2 lines · Ingo Molnar
Andi Kleen (1):
perf symbols: Demangle cloned functions
The commit above e95ab53645:
commit de95ab53645a2f0015e0f68ee723f18dce2b8b51
Author: Andi Kleen <[email protected]>
Date: Thu Sep 12 08:16:38 2013 -0700
perf symbols: Demangle cloned functions
breaks "perf top" on my machine. I just see a gray screen with no text at all. Sometimes the following error messages are printed:
*** Error in perf': invalid fastbin entry (free): 0x00000000029b18c0 *** *** Error in perf': malloc(): memory corruption (fast): 0x0000000000ee0b10 ***
Reverting the commit "fixes" the issue.
Signature · 1 line
Markus
[GIT PULL] perf fix
Quoted 10 lines · Markus Trippelsdorf
Quoted 2 lines · Ingo Molnar
Andi Kleen (1):
perf symbols: Demangle cloned functionsThe commit above
e95ab53645:commit
de95ab53645a2f0015e0f68ee723f18dce2b8b51
Author: Andi Kleen <[email protected]>
Date: Thu Sep 12 08:16:38 2013 -0700
Quoted 8 lines
perf symbols: Demangle cloned functions
breaks "perf top" on my machine. I just see a gray screen with no text at all. Sometimes the following error messages are printed:
*** Error inperf': invalid fastbin entry (free): 0x00000000029b18c0 *** *** Error inperf':malloc(): memory corruption (fast):0x0000000000ee0b10***Reverting the commit "fixes" the issue.
Sorry about that.
Looking at the commit it fails on several quality levels:
- sloppy structure: the code is unreadable, it should have been a separate helper function
- sloppy flow: why the heck does it do strchr() twice? Not to
mention the fragile way of how the new flow tries to merge with the old instead of cleanly separating.
- sloppy types: it casts a const char * over into char *
- sloppy style: variable block not separated from statements,
meaningless temporary variable names, etc. etc.
- and it's not even a regression fix to begin with!
So the right resolution is a revert. Andi, please send a fixed patch with all of these issues and the crash fixed.
Linus,
Please pull the latest perf-urgent-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf-urgent-for-linus
HEAD: 14951f22f1cc8375ead345d2ca08455e91f2152b Revert "perf symbols: Demangle cloned functions"
It fixes the 'perf top' regression Markus Trippelsdorf reported.
Thanks,
Ingo
------------------>
Ingo Molnar (1):
Revert "perf symbols: Demangle cloned functions"
tools/perf/util/symbol-elf.c | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-)
tools/perf/util/symbol-elf.c +1 -26
@@ -928,33 +928,8 @@ int dso__load_sym(struct dso *dso, struct map *map,* to it... */ if (symbol_conf.demangle) { -/* -* The demangler doesn't deal with cloned functions. -* XXXX.clone.NUM or similar -* Strip the dot part and readd it later. -*/ -char *p = (char *)elf_name, *dot; - dot =strchr (elf_name,'.' ); -if (dot) { - p =strdup (elf_name); -if (!p) - goto new_symbol; - dot =strchr (p,'.' ); - *dot =0 ; - } - - demangled =bfd_demangle (NULL , p, + demangled =bfd_demangle (NULL , elf_name,DMGL_PARAMS |DMGL_ANSI ); -if (dot) - *dot ='.' ; -if (demangled && dot) { - demangled =realloc (demangled,strlen (demangled) +strlen (dot) +1 ); -if (!demangled) - goto new_symbol; -strcpy (demangled + (dot - p), dot); - } -if (p != elf_name) -free (p);if (demangled !=NULL ) elf_name = demangled; }
Quoted 4 lines
breaks "perf top" on my machine. I just see a gray screen with no text at all. Sometimes the following error messages are printed:
*** Error inperf': invalid fastbin entry (free): 0x00000000029b18c0 *** *** Error inperf':malloc(): memory corruption (fast):0x0000000000ee0b10***
Hmm, works for me. In fact I wrote it to fix a perf top issue.
What does valgrind say?
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only
Quoted 8 lines · Andi Kleen
Quoted 4 lines
breaks "perf top" on my machine. I just see a gray screen with no text at all. Sometimes the following error messages are printed:
*** Error inperf': invalid fastbin entry (free): 0x00000000029b18c0 *** *** Error inperf':malloc(): memory corruption (fast):0x0000000000ee0b10***Hmm, works for me. In fact I wrote it to fix a perf top issue.
What does valgrind say?
Here's the -fsanitize=address output instead:
markus@x4 perf % perf top --stdio 2>&1 | asan_symbolize.py
=================================================================
==24617== ERROR: AddressSanitizer: heap-buffer-overflow on address 0x600c0000b638 at pc 0x7f2683fad79d bp 0x7fffbb8ec3b0 sp 0x7fffbb8ebb70 WRITE of size 9 at 0x600c0000b638 thread T0
#0 0x7f2683fad79c in __interceptor_strcpy ??:?
#1 0x4e422c in strcpy /usr/include/bits/string3.h:104
#2 0x4ddeff in dso__load /usr/src/linux/tools/perf/util/symbol.c:1085
#3 0x509058 in map__load /usr/src/linux/tools/perf/util/map.c:159
#4 0x49fa6b in perf_event__preprocess_sample /usr/src/linux/tools/perf/util/event.c:762
#5 0x455fa0 in perf_event__process_sample /usr/src/linux/tools/perf/builtin-top.c:719
#6 0x45be8e in perf_top__mmap_read /usr/src/linux/tools/perf/builtin-top.c:870
#7 0x41f88d in run_builtin /usr/src/linux/tools/perf/perf.c:319
#8 0x41bc05 in run_argv /usr/src/linux/tools/perf/perf.c:376
#9 0x7f2682d41a74 in __libc_start_main /home/markus/glibc/csu/libc-start.c:269
#10 0x41e948 in _start /home/markus/glibc/csu/../sysdeps/x86_64/start.S:122
0x600c0000b63d is located 0 bytes to the right of 61-byte region [0x600c0000b600,0x600c0000b63d)
allocated by thread T0 here:
#0 0x7f2683fb6d6f in __interceptor_realloc ??:?
#1 0x4e420f in dso__load_sym /usr/src/linux/tools/perf/util/symbol-elf.c:951
#2 0x4ddeff in dso__load /usr/src/linux/tools/perf/util/symbol.c:1085
#3 0x509058 in map__load /usr/src/linux/tools/perf/util/map.c:159
#4 0x49fa6b in perf_event__preprocess_sample /usr/src/linux/tools/perf/util/event.c:762
#5 0x455fa0 in perf_event__process_sample /usr/src/linux/tools/perf/builtin-top.c:719
#6 0x45be8e in perf_top__mmap_read /usr/src/linux/tools/perf/builtin-top.c:870
#7 0x41f88d in run_builtin /usr/src/linux/tools/perf/perf.c:319
#8 0x41bc05 in run_argv /usr/src/linux/tools/perf/perf.c:376
#9 0x7f2682d41a74 in __libc_start_main /home/markus/glibc/csu/libc-start.c:269Shadow bytes around the buggy address:
0x0c01ffff9670: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c01ffff9680: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c01ffff9690: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c01ffff96a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c01ffff96b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c01ffff96c0: 00 00 00 00 00 00 00[05]fa fa fa fa fd fd fd fd
0x0c01ffff96d0: fd fd fd fd fa fa fa fa fd fd fd fd fd fd fd fd 0x0c01ffff96e0: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa 0x0c01ffff96f0: fd fd fd fd fd fd fd fd fa fa fa fa fd fd fd fd 0x0c01ffff9700: fd fd fd fd fa fa fa fa fd fd fd fd fd fd fd fd 0x0c01ffff9710: fa fa fa fa fd fd fd fd fd fd fd fd fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa Heap righ redzone: fb Freed Heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack partial redzone: f4 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 ASan internal: fe
==24617== ABORTING
And please note that cloned functions are demangled just fine on my machine even without your patch, e.g.:
10.61% libQtGui.so.4.8.5 [.] QFontEngineFT::stringToCMap(QChar const*, int, QGlyphLayout*, int*, QFlags<QTextEngine::ShaperFlag>) const [clone .part.20]
Signature · 1 line
Markus
Quoted 6 lines · Andi Kleen
Quoted 4 lines
breaks "perf top" on my machine. I just see a gray screen with no text at all. Sometimes the following error messages are printed:
*** Error inperf': invalid fastbin entry (free): 0x00000000029b18c0 *** *** Error inperf':malloc(): memory corruption (fast):0x0000000000ee0b10***Hmm, works for me. In fact I wrote it to fix a perf top issue.
What 'issue' and why wasn't it described in the changelog more accurately?
The blurb you wrote in the changelog:
| The libbfd C++ demangler doesn't seem to deal with cloned functions, | like symbol.clone.NUM. | | Just strip the dot part before demangling and add it back later.
Only alludes to a C++ symbol resolution annoyance and thus isn't very informative.
Ingo
Quoted 9 lines
The blurb you wrote in the changelog:
| The libbfd C++ demangler doesn't seem to deal with cloned functions, | like symbol.clone.NUM. | | Just strip the dot part before demangling and add it back later.Only alludes to a C++ symbol resolution annoyance and thus isn't very informative.
The issue was that I saw a long unreadable line noise string in report/top, instead of a demangled function. After I stripped the postfix I got the demangled symbol as expected.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only
Quoted 12 lines · Andi Kleen
Quoted 12 lines
Quoted 1 line
Hmm, works for me. In fact I wrote it to fix a perf top issue.
What 'issue' and why wasn't it described in the changelog more accurately?
The blurb you wrote in the changelog:
| The libbfd C++ demangler doesn't seem to deal with cloned functions, | like symbol.clone.NUM. | | Just strip the dot part before demangling and add it back later.
Quoted 6 lines
Quoted 2 lines
Only alludes to a C++ symbol resolution annoyance and thus isn't very informative.
The issue was that I saw a long unreadable line noise string in report/top, instead of a demangled function. After I stripped the postfix I got the demangled symbol as expected.
We obviously don't want to trade output annoyances for crashes, nor does it justify the code uglies you introduced with the patch - which made the code obviously unrobust.
My guess would be that maybe it's the cast of a const pointer that possibly broke GCC's aliasing detection on Markus's system or so. But maybe there's a more direct bug in the code as well, the code you added is too ugly to be reviewed efficiently, please send a cleaned up version.
Thanks,
Ingo