Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull perf fixes from Ingo Molnar:
"A couple of kernel side fixes:

- Fix the Intel uncore driver on certain hardware configurations

- Fix a CPU hotplug related memory allocation bug

- Remove a spurious WARN()

... plus also a handful of perf tooling fixes"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
perf script python: Add Python3 support to tests/attr.py
perf trace: Support multiple "vfs_getname" probes
perf symbols: Filter out hidden symbols from labels
perf symbols: Add fallback definitions for GELF_ST_VISIBILITY()
tools headers uapi: Sync linux/in.h copy from the kernel sources
perf clang: Do not use 'return std::move(something)'
perf mem/c2c: Fix perf_mem_events to support powerpc
perf tests evsel-tp-sched: Fix bitwise operator
perf/core: Don't WARN() for impossible ring-buffer sizes
perf/x86/intel: Delay memory deallocation until x86_pmu_dead_cpu()
perf/x86/intel/uncore: Add Node ID mask

Changed files
+105 -36
arch
x86
events
kernel
events
tools
include
uapi
linux
perf
+11 -5
arch/x86/events/intel/core.c
··· 3559 3559 3560 3560 static void intel_pmu_cpu_dying(int cpu) 3561 3561 { 3562 + fini_debug_store_on_cpu(cpu); 3563 + 3564 + if (x86_pmu.counter_freezing) 3565 + disable_counter_freeze(); 3566 + } 3567 + 3568 + static void intel_pmu_cpu_dead(int cpu) 3569 + { 3562 3570 struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu); 3563 3571 struct intel_shared_regs *pc; 3564 3572 ··· 3578 3570 } 3579 3571 3580 3572 free_excl_cntrs(cpu); 3581 - 3582 - fini_debug_store_on_cpu(cpu); 3583 - 3584 - if (x86_pmu.counter_freezing) 3585 - disable_counter_freeze(); 3586 3573 } 3587 3574 3588 3575 static void intel_pmu_sched_task(struct perf_event_context *ctx, ··· 3666 3663 .cpu_prepare = intel_pmu_cpu_prepare, 3667 3664 .cpu_starting = intel_pmu_cpu_starting, 3668 3665 .cpu_dying = intel_pmu_cpu_dying, 3666 + .cpu_dead = intel_pmu_cpu_dead, 3669 3667 }; 3670 3668 3671 3669 static struct attribute *intel_pmu_attrs[]; ··· 3707 3703 .cpu_prepare = intel_pmu_cpu_prepare, 3708 3704 .cpu_starting = intel_pmu_cpu_starting, 3709 3705 .cpu_dying = intel_pmu_cpu_dying, 3706 + .cpu_dead = intel_pmu_cpu_dead, 3707 + 3710 3708 .guest_get_msrs = intel_guest_get_msrs, 3711 3709 .sched_task = intel_pmu_sched_task, 3712 3710 };
+3 -1
arch/x86/events/intel/uncore_snbep.c
··· 1222 1222 .id_table = snbep_uncore_pci_ids, 1223 1223 }; 1224 1224 1225 + #define NODE_ID_MASK 0x7 1226 + 1225 1227 /* 1226 1228 * build pci bus to socket mapping 1227 1229 */ ··· 1245 1243 err = pci_read_config_dword(ubox_dev, nodeid_loc, &config); 1246 1244 if (err) 1247 1245 break; 1248 - nodeid = config; 1246 + nodeid = config & NODE_ID_MASK; 1249 1247 /* get the Node ID mapping */ 1250 1248 err = pci_read_config_dword(ubox_dev, idmap_loc, &config); 1251 1249 if (err)
+3
kernel/events/ring_buffer.c
··· 734 734 size = sizeof(struct ring_buffer); 735 735 size += nr_pages * sizeof(void *); 736 736 737 + if (order_base_2(size) >= MAX_ORDER) 738 + goto fail; 739 + 737 740 rb = kzalloc(size, GFP_KERNEL); 738 741 if (!rb) 739 742 goto fail;
+1 -1
tools/include/uapi/linux/in.h
··· 268 268 #define IN_MULTICAST(a) IN_CLASSD(a) 269 269 #define IN_MULTICAST_NET 0xe0000000 270 270 271 - #define IN_BADCLASS(a) ((((long int) (a) ) == 0xffffffff) 271 + #define IN_BADCLASS(a) (((long int) (a) ) == (long int)0xffffffff) 272 272 #define IN_EXPERIMENTAL(a) IN_BADCLASS((a)) 273 273 274 274 #define IN_CLASSE(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000)
+12 -4
tools/perf/Documentation/perf-c2c.txt
··· 19 19 The perf c2c tool provides means for Shared Data C2C/HITM analysis. It allows 20 20 you to track down the cacheline contentions. 21 21 22 - The tool is based on x86's load latency and precise store facility events 23 - provided by Intel CPUs. These events provide: 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: 24 27 - memory address of the access 25 28 - type of the access (load and store details) 26 29 - latency (in cycles) of the load access ··· 49 46 50 47 -l:: 51 48 --ldlat:: 52 - Configure mem-loads latency. 49 + Configure mem-loads latency. (x86 only) 53 50 54 51 -k:: 55 52 --all-kernel:: ··· 122 119 -W,-d,--phys-data,--sample-cpu 123 120 124 121 Unless specified otherwise with '-e' option, following events are monitored by 125 - default: 122 + default on x86: 126 123 127 124 cpu/mem-loads,ldlat=30/P 128 125 cpu/mem-stores/P 126 + 127 + and following on PowerPC: 128 + 129 + cpu/mem-loads/ 130 + cpu/mem-stores/ 129 131 130 132 User can pass any 'perf record' option behind '--' mark, like (to enable 131 133 callchains and system wide monitoring):
+1 -1
tools/perf/Documentation/perf-mem.txt
··· 82 82 Be more verbose (show counter open errors, etc) 83 83 84 84 --ldlat <n>:: 85 - Specify desired latency for loads event. 85 + Specify desired latency for loads event. (x86 only) 86 86 87 87 In addition, for report all perf report options are valid, and for record 88 88 all perf record options.
+1
tools/perf/arch/powerpc/util/Build
··· 2 2 libperf-y += sym-handling.o 3 3 libperf-y += kvm-stat.o 4 4 libperf-y += perf_regs.o 5 + libperf-y += mem-events.o 5 6 6 7 libperf-$(CONFIG_DWARF) += dwarf-regs.o 7 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 2514 2515 2515 static bool perf_evlist__add_vfs_getname(struct perf_evlist *evlist) 2516 2516 { 2517 - struct perf_evsel *evsel = perf_evsel__newtp("probe", "vfs_getname"); 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); 2518 2521 2519 - if (IS_ERR(evsel)) 2522 + if (ret) 2520 2523 return false; 2521 2524 2522 - if (perf_evsel__field(evsel, "pathname") == NULL) { 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; 2523 2537 perf_evsel__delete(evsel); 2524 - return false; 2525 2538 } 2526 2539 2527 - evsel->handler = trace__vfs_getname; 2528 - perf_evlist__add(evlist, evsel); 2529 - return true; 2540 + return found; 2530 2541 } 2531 2542 2532 2543 static struct perf_evsel *perf_evsel__new_pgfault(u64 config)
+19 -13
tools/perf/tests/attr.py
··· 1 1 #! /usr/bin/python 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 + from __future__ import print_function 5 + 4 6 import os 5 7 import sys 6 8 import glob ··· 10 8 import tempfile 11 9 import logging 12 10 import shutil 13 - import ConfigParser 11 + 12 + try: 13 + import configparser 14 + except ImportError: 15 + import ConfigParser as configparser 14 16 15 17 def data_equal(a, b): 16 18 # Allow multiple values in assignment separated by '|' ··· 106 100 def equal(self, other): 107 101 for t in Event.terms: 108 102 log.debug(" [%s] %s %s" % (t, self[t], other[t])); 109 - if not self.has_key(t) or not other.has_key(t): 103 + if t not in self or t not in other: 110 104 return False 111 105 if not data_equal(self[t], other[t]): 112 106 return False 113 107 return True 114 108 115 109 def optional(self): 116 - if self.has_key('optional') and self['optional'] == '1': 110 + if 'optional' in self and self['optional'] == '1': 117 111 return True 118 112 return False 119 113 120 114 def diff(self, other): 121 115 for t in Event.terms: 122 - if not self.has_key(t) or not other.has_key(t): 116 + if t not in self or t not in other: 123 117 continue 124 118 if not data_equal(self[t], other[t]): 125 119 log.warning("expected %s=%s, got %s" % (t, self[t], other[t])) ··· 140 134 # - expected values assignments 141 135 class Test(object): 142 136 def __init__(self, path, options): 143 - parser = ConfigParser.SafeConfigParser() 137 + parser = configparser.SafeConfigParser() 144 138 parser.read(path) 145 139 146 140 log.warning("running '%s'" % path) ··· 199 193 return True 200 194 201 195 def load_events(self, path, events): 202 - parser_event = ConfigParser.SafeConfigParser() 196 + parser_event = configparser.SafeConfigParser() 203 197 parser_event.read(path) 204 198 205 199 # The event record section header contains 'event' word, ··· 213 207 # Read parent event if there's any 214 208 if (':' in section): 215 209 base = section[section.index(':') + 1:] 216 - parser_base = ConfigParser.SafeConfigParser() 210 + parser_base = configparser.SafeConfigParser() 217 211 parser_base.read(self.test_dir + '/' + base) 218 212 base_items = parser_base.items('event') 219 213 ··· 328 322 for f in glob.glob(options.test_dir + '/' + options.test): 329 323 try: 330 324 Test(f, options).run() 331 - except Unsup, obj: 325 + except Unsup as obj: 332 326 log.warning("unsupp %s" % obj.getMsg()) 333 - except Notest, obj: 327 + except Notest as obj: 334 328 log.warning("skipped %s" % obj.getMsg()) 335 329 336 330 def setup_log(verbose): ··· 369 363 parser.add_option("-p", "--perf", 370 364 action="store", type="string", dest="perf") 371 365 parser.add_option("-v", "--verbose", 372 - action="count", dest="verbose") 366 + default=0, action="count", dest="verbose") 373 367 374 368 options, args = parser.parse_args() 375 369 if args: ··· 379 373 setup_log(options.verbose) 380 374 381 375 if not options.test_dir: 382 - print 'FAILED no -d option specified' 376 + print('FAILED no -d option specified') 383 377 sys.exit(-1) 384 378 385 379 if not options.test: ··· 388 382 try: 389 383 run_tests(options) 390 384 391 - except Fail, obj: 392 - print "FAILED %s" % obj.getMsg(); 385 + except Fail as obj: 386 + print("FAILED %s" % obj.getMsg()) 393 387 sys.exit(-1) 394 388 395 389 sys.exit(0)
+1 -1
tools/perf/tests/evsel-tp-sched.c
··· 17 17 return -1; 18 18 } 19 19 20 - is_signed = !!(field->flags | TEP_FIELD_IS_SIGNED); 20 + is_signed = !!(field->flags & TEP_FIELD_IS_SIGNED); 21 21 if (should_be_signed && !is_signed) { 22 22 pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n", 23 23 evsel->name, name, is_signed, should_be_signed);
+1 -1
tools/perf/util/c++/clang.cpp
··· 160 160 } 161 161 PM.run(*Module); 162 162 163 - return std::move(Buffer); 163 + return Buffer; 164 164 } 165 165 166 166 }
+1 -1
tools/perf/util/mem-events.c
··· 28 28 static char mem_loads_name[100]; 29 29 static bool mem_loads_name__init; 30 30 31 - char *perf_mem_events__name(int i) 31 + char * __weak perf_mem_events__name(int i) 32 32 { 33 33 if (i == PERF_MEM_EVENTS__LOAD) { 34 34 if (!mem_loads_name__init) {
+22 -1
tools/perf/util/symbol-elf.c
··· 19 19 #define EM_AARCH64 183 /* ARM 64 bit */ 20 20 #endif 21 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 + 22 36 typedef Elf64_Nhdr GElf_Nhdr; 23 37 24 38 #ifdef HAVE_CPLUS_DEMANGLE_SUPPORT ··· 101 87 return GELF_ST_TYPE(sym->st_info); 102 88 } 103 89 90 + static inline uint8_t elf_sym__visibility(const GElf_Sym *sym) 91 + { 92 + return GELF_ST_VISIBILITY(sym->st_other); 93 + } 94 + 104 95 #ifndef STT_GNU_IFUNC 105 96 #define STT_GNU_IFUNC 10 106 97 #endif ··· 130 111 return elf_sym__type(sym) == STT_NOTYPE && 131 112 sym->st_name != 0 && 132 113 sym->st_shndx != SHN_UNDEF && 133 - sym->st_shndx != SHN_ABS; 114 + sym->st_shndx != SHN_ABS && 115 + elf_sym__visibility(sym) != STV_HIDDEN && 116 + elf_sym__visibility(sym) != STV_INTERNAL; 134 117 } 135 118 136 119 static bool elf_sym__filter(GElf_Sym *sym)