Merge tag 'perf-urgent-for-mingo-5.0-20190205' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent

Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

perf trace:

Arnaldo Carvalho de Melo:

Fix handling of probe:vfs_getname when the probed routine is
inlined in multiple places, fixing the collection of the 'filename'
parameter in open syscalls.

perf test:

Gustavo A. R. Silva:

Fix bitwise operator usage in evsel-tp-sched test, which made tat
test always detect fields as signed.

Jiri Olsa:

Filter out hidden symbols from labels, added in systems where the
annobin plugin is used, such as RHEL8, which, if left in place make
the DWARF unwind 'perf test' to fail on PPC.

Tony Jones:

Fix 'perf_event_attr' tests when building with python3.

perf mem/c2c:

Ravi Bangoria:

Fix perf_mem_events on PowerPC.

tools headers UAPI:

Arnaldo Carvalho de Melo:

Sync linux/in.h copy from the kernel sources, silencing a perf build warning.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>

+88 -30
+1 -1
tools/include/uapi/linux/in.h
··· 268 #define IN_MULTICAST(a) IN_CLASSD(a) 269 #define IN_MULTICAST_NET 0xe0000000 270 271 - #define IN_BADCLASS(a) ((((long int) (a) ) == 0xffffffff) 272 #define IN_EXPERIMENTAL(a) IN_BADCLASS((a)) 273 274 #define IN_CLASSE(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000)
··· 268 #define IN_MULTICAST(a) IN_CLASSD(a) 269 #define IN_MULTICAST_NET 0xe0000000 270 271 + #define IN_BADCLASS(a) (((long int) (a) ) == (long int)0xffffffff) 272 #define IN_EXPERIMENTAL(a) IN_BADCLASS((a)) 273 274 #define IN_CLASSE(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000)
+12 -4
tools/perf/Documentation/perf-c2c.txt
··· 19 The perf c2c tool provides means for Shared Data C2C/HITM analysis. It allows 20 you to track down the cacheline contentions. 21 22 - The tool is based on x86's load latency and precise store facility events 23 - provided by Intel CPUs. These events provide: 24 - memory address of the access 25 - type of the access (load and store details) 26 - latency (in cycles) of the load access ··· 49 50 -l:: 51 --ldlat:: 52 - Configure mem-loads latency. 53 54 -k:: 55 --all-kernel:: ··· 122 -W,-d,--phys-data,--sample-cpu 123 124 Unless specified otherwise with '-e' option, following events are monitored by 125 - default: 126 127 cpu/mem-loads,ldlat=30/P 128 cpu/mem-stores/P 129 130 User can pass any 'perf record' option behind '--' mark, like (to enable 131 callchains and system wide monitoring):
··· 19 The perf c2c tool provides means for Shared Data C2C/HITM analysis. It allows 20 you to track down the cacheline contentions. 21 22 + On x86, the tool is based on load latency and precise store facility events 23 + provided by Intel CPUs. On PowerPC, the tool uses random instruction sampling 24 + with thresholding feature. 25 + 26 + These events provide: 27 - memory address of the access 28 - type of the access (load and store details) 29 - latency (in cycles) of the load access ··· 46 47 -l:: 48 --ldlat:: 49 + Configure mem-loads latency. (x86 only) 50 51 -k:: 52 --all-kernel:: ··· 119 -W,-d,--phys-data,--sample-cpu 120 121 Unless specified otherwise with '-e' option, following events are monitored by 122 + default on x86: 123 124 cpu/mem-loads,ldlat=30/P 125 cpu/mem-stores/P 126 + 127 + and following on PowerPC: 128 + 129 + cpu/mem-loads/ 130 + cpu/mem-stores/ 131 132 User can pass any 'perf record' option behind '--' mark, like (to enable 133 callchains and system wide monitoring):
+1 -1
tools/perf/Documentation/perf-mem.txt
··· 82 Be more verbose (show counter open errors, etc) 83 84 --ldlat <n>:: 85 - Specify desired latency for loads event. 86 87 In addition, for report all perf report options are valid, and for record 88 all perf record options.
··· 82 Be more verbose (show counter open errors, etc) 83 84 --ldlat <n>:: 85 + Specify desired latency for loads event. (x86 only) 86 87 In addition, for report all perf report options are valid, and for record 88 all perf record options.
+1
tools/perf/arch/powerpc/util/Build
··· 2 libperf-y += sym-handling.o 3 libperf-y += kvm-stat.o 4 libperf-y += perf_regs.o 5 6 libperf-$(CONFIG_DWARF) += dwarf-regs.o 7 libperf-$(CONFIG_DWARF) += skip-callchain-idx.o
··· 2 libperf-y += sym-handling.o 3 libperf-y += kvm-stat.o 4 libperf-y += perf_regs.o 5 + libperf-y += mem-events.o 6 7 libperf-$(CONFIG_DWARF) += dwarf-regs.o 8 libperf-$(CONFIG_DWARF) += skip-callchain-idx.o
+11
tools/perf/arch/powerpc/util/mem-events.c
···
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include "mem-events.h" 3 + 4 + /* PowerPC does not support 'ldlat' parameter. */ 5 + char *perf_mem_events__name(int i) 6 + { 7 + if (i == PERF_MEM_EVENTS__LOAD) 8 + return (char *) "cpu/mem-loads/"; 9 + 10 + return (char *) "cpu/mem-stores/"; 11 + }
+18 -7
tools/perf/builtin-trace.c
··· 2514 2515 static bool perf_evlist__add_vfs_getname(struct perf_evlist *evlist) 2516 { 2517 - struct perf_evsel *evsel = perf_evsel__newtp("probe", "vfs_getname"); 2518 2519 - if (IS_ERR(evsel)) 2520 return false; 2521 2522 - if (perf_evsel__field(evsel, "pathname") == NULL) { 2523 perf_evsel__delete(evsel); 2524 - return false; 2525 } 2526 2527 - evsel->handler = trace__vfs_getname; 2528 - perf_evlist__add(evlist, evsel); 2529 - return true; 2530 } 2531 2532 static struct perf_evsel *perf_evsel__new_pgfault(u64 config)
··· 2514 2515 static bool perf_evlist__add_vfs_getname(struct perf_evlist *evlist) 2516 { 2517 + bool found = false; 2518 + struct perf_evsel *evsel, *tmp; 2519 + struct parse_events_error err = { .idx = 0, }; 2520 + int ret = parse_events(evlist, "probe:vfs_getname*", &err); 2521 2522 + if (ret) 2523 return false; 2524 2525 + evlist__for_each_entry_safe(evlist, evsel, tmp) { 2526 + if (!strstarts(perf_evsel__name(evsel), "probe:vfs_getname")) 2527 + continue; 2528 + 2529 + if (perf_evsel__field(evsel, "pathname")) { 2530 + evsel->handler = trace__vfs_getname; 2531 + found = true; 2532 + continue; 2533 + } 2534 + 2535 + list_del_init(&evsel->node); 2536 + evsel->evlist = NULL; 2537 perf_evsel__delete(evsel); 2538 } 2539 2540 + return found; 2541 } 2542 2543 static struct perf_evsel *perf_evsel__new_pgfault(u64 config)
+19 -13
tools/perf/tests/attr.py
··· 1 #! /usr/bin/python 2 # SPDX-License-Identifier: GPL-2.0 3 4 import os 5 import sys 6 import glob ··· 10 import tempfile 11 import logging 12 import shutil 13 - import ConfigParser 14 15 def data_equal(a, b): 16 # Allow multiple values in assignment separated by '|' ··· 106 def equal(self, other): 107 for t in Event.terms: 108 log.debug(" [%s] %s %s" % (t, self[t], other[t])); 109 - if not self.has_key(t) or not other.has_key(t): 110 return False 111 if not data_equal(self[t], other[t]): 112 return False 113 return True 114 115 def optional(self): 116 - if self.has_key('optional') and self['optional'] == '1': 117 return True 118 return False 119 120 def diff(self, other): 121 for t in Event.terms: 122 - if not self.has_key(t) or not other.has_key(t): 123 continue 124 if not data_equal(self[t], other[t]): 125 log.warning("expected %s=%s, got %s" % (t, self[t], other[t])) ··· 140 # - expected values assignments 141 class Test(object): 142 def __init__(self, path, options): 143 - parser = ConfigParser.SafeConfigParser() 144 parser.read(path) 145 146 log.warning("running '%s'" % path) ··· 199 return True 200 201 def load_events(self, path, events): 202 - parser_event = ConfigParser.SafeConfigParser() 203 parser_event.read(path) 204 205 # The event record section header contains 'event' word, ··· 213 # Read parent event if there's any 214 if (':' in section): 215 base = section[section.index(':') + 1:] 216 - parser_base = ConfigParser.SafeConfigParser() 217 parser_base.read(self.test_dir + '/' + base) 218 base_items = parser_base.items('event') 219 ··· 328 for f in glob.glob(options.test_dir + '/' + options.test): 329 try: 330 Test(f, options).run() 331 - except Unsup, obj: 332 log.warning("unsupp %s" % obj.getMsg()) 333 - except Notest, obj: 334 log.warning("skipped %s" % obj.getMsg()) 335 336 def setup_log(verbose): ··· 369 parser.add_option("-p", "--perf", 370 action="store", type="string", dest="perf") 371 parser.add_option("-v", "--verbose", 372 - action="count", dest="verbose") 373 374 options, args = parser.parse_args() 375 if args: ··· 379 setup_log(options.verbose) 380 381 if not options.test_dir: 382 - print 'FAILED no -d option specified' 383 sys.exit(-1) 384 385 if not options.test: ··· 388 try: 389 run_tests(options) 390 391 - except Fail, obj: 392 - print "FAILED %s" % obj.getMsg(); 393 sys.exit(-1) 394 395 sys.exit(0)
··· 1 #! /usr/bin/python 2 # SPDX-License-Identifier: GPL-2.0 3 4 + from __future__ import print_function 5 + 6 import os 7 import sys 8 import glob ··· 8 import tempfile 9 import logging 10 import shutil 11 + 12 + try: 13 + import configparser 14 + except ImportError: 15 + import ConfigParser as configparser 16 17 def data_equal(a, b): 18 # Allow multiple values in assignment separated by '|' ··· 100 def equal(self, other): 101 for t in Event.terms: 102 log.debug(" [%s] %s %s" % (t, self[t], other[t])); 103 + if t not in self or t not in other: 104 return False 105 if not data_equal(self[t], other[t]): 106 return False 107 return True 108 109 def optional(self): 110 + if 'optional' in self and self['optional'] == '1': 111 return True 112 return False 113 114 def diff(self, other): 115 for t in Event.terms: 116 + if t not in self or t not in other: 117 continue 118 if not data_equal(self[t], other[t]): 119 log.warning("expected %s=%s, got %s" % (t, self[t], other[t])) ··· 134 # - expected values assignments 135 class Test(object): 136 def __init__(self, path, options): 137 + parser = configparser.SafeConfigParser() 138 parser.read(path) 139 140 log.warning("running '%s'" % path) ··· 193 return True 194 195 def load_events(self, path, events): 196 + parser_event = configparser.SafeConfigParser() 197 parser_event.read(path) 198 199 # The event record section header contains 'event' word, ··· 207 # Read parent event if there's any 208 if (':' in section): 209 base = section[section.index(':') + 1:] 210 + parser_base = configparser.SafeConfigParser() 211 parser_base.read(self.test_dir + '/' + base) 212 base_items = parser_base.items('event') 213 ··· 322 for f in glob.glob(options.test_dir + '/' + options.test): 323 try: 324 Test(f, options).run() 325 + except Unsup as obj: 326 log.warning("unsupp %s" % obj.getMsg()) 327 + except Notest as obj: 328 log.warning("skipped %s" % obj.getMsg()) 329 330 def setup_log(verbose): ··· 363 parser.add_option("-p", "--perf", 364 action="store", type="string", dest="perf") 365 parser.add_option("-v", "--verbose", 366 + default=0, action="count", dest="verbose") 367 368 options, args = parser.parse_args() 369 if args: ··· 373 setup_log(options.verbose) 374 375 if not options.test_dir: 376 + print('FAILED no -d option specified') 377 sys.exit(-1) 378 379 if not options.test: ··· 382 try: 383 run_tests(options) 384 385 + except Fail as obj: 386 + print("FAILED %s" % obj.getMsg()) 387 sys.exit(-1) 388 389 sys.exit(0)
+1 -1
tools/perf/tests/evsel-tp-sched.c
··· 17 return -1; 18 } 19 20 - is_signed = !!(field->flags | TEP_FIELD_IS_SIGNED); 21 if (should_be_signed && !is_signed) { 22 pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n", 23 evsel->name, name, is_signed, should_be_signed);
··· 17 return -1; 18 } 19 20 + is_signed = !!(field->flags & TEP_FIELD_IS_SIGNED); 21 if (should_be_signed && !is_signed) { 22 pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n", 23 evsel->name, name, is_signed, should_be_signed);
+1 -1
tools/perf/util/c++/clang.cpp
··· 160 } 161 PM.run(*Module); 162 163 - return std::move(Buffer); 164 } 165 166 }
··· 160 } 161 PM.run(*Module); 162 163 + return Buffer; 164 } 165 166 }
+1 -1
tools/perf/util/mem-events.c
··· 28 static char mem_loads_name[100]; 29 static bool mem_loads_name__init; 30 31 - char *perf_mem_events__name(int i) 32 { 33 if (i == PERF_MEM_EVENTS__LOAD) { 34 if (!mem_loads_name__init) {
··· 28 static char mem_loads_name[100]; 29 static bool mem_loads_name__init; 30 31 + char * __weak perf_mem_events__name(int i) 32 { 33 if (i == PERF_MEM_EVENTS__LOAD) { 34 if (!mem_loads_name__init) {
+22 -1
tools/perf/util/symbol-elf.c
··· 19 #define EM_AARCH64 183 /* ARM 64 bit */ 20 #endif 21 22 typedef Elf64_Nhdr GElf_Nhdr; 23 24 #ifdef HAVE_CPLUS_DEMANGLE_SUPPORT ··· 101 return GELF_ST_TYPE(sym->st_info); 102 } 103 104 #ifndef STT_GNU_IFUNC 105 #define STT_GNU_IFUNC 10 106 #endif ··· 130 return elf_sym__type(sym) == STT_NOTYPE && 131 sym->st_name != 0 && 132 sym->st_shndx != SHN_UNDEF && 133 - sym->st_shndx != SHN_ABS; 134 } 135 136 static bool elf_sym__filter(GElf_Sym *sym)
··· 19 #define EM_AARCH64 183 /* ARM 64 bit */ 20 #endif 21 22 + #ifndef ELF32_ST_VISIBILITY 23 + #define ELF32_ST_VISIBILITY(o) ((o) & 0x03) 24 + #endif 25 + 26 + /* For ELF64 the definitions are the same. */ 27 + #ifndef ELF64_ST_VISIBILITY 28 + #define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) 29 + #endif 30 + 31 + /* How to extract information held in the st_other field. */ 32 + #ifndef GELF_ST_VISIBILITY 33 + #define GELF_ST_VISIBILITY(val) ELF64_ST_VISIBILITY (val) 34 + #endif 35 + 36 typedef Elf64_Nhdr GElf_Nhdr; 37 38 #ifdef HAVE_CPLUS_DEMANGLE_SUPPORT ··· 87 return GELF_ST_TYPE(sym->st_info); 88 } 89 90 + static inline uint8_t elf_sym__visibility(const GElf_Sym *sym) 91 + { 92 + return GELF_ST_VISIBILITY(sym->st_other); 93 + } 94 + 95 #ifndef STT_GNU_IFUNC 96 #define STT_GNU_IFUNC 10 97 #endif ··· 111 return elf_sym__type(sym) == STT_NOTYPE && 112 sym->st_name != 0 && 113 sym->st_shndx != SHN_UNDEF && 114 + sym->st_shndx != SHN_ABS && 115 + elf_sym__visibility(sym) != STV_HIDDEN && 116 + elf_sym__visibility(sym) != STV_INTERNAL; 117 } 118 119 static bool elf_sym__filter(GElf_Sym *sym)