Skip to content

Commit 212146f

Browse files
committed
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
2 parents d2a6aae + 3bb2600 commit 212146f

File tree

14 files changed

+105
-36
lines changed

14 files changed

+105
-36
lines changed

arch/x86/events/intel/core.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3558,6 +3558,14 @@ static void free_excl_cntrs(int cpu)
35583558
}
35593559

35603560
static void intel_pmu_cpu_dying(int cpu)
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)
35613569
{
35623570
struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
35633571
struct intel_shared_regs *pc;
@@ -3570,11 +3578,6 @@ static void intel_pmu_cpu_dying(int cpu)
35703578
}
35713579

35723580
free_excl_cntrs(cpu);
3573-
3574-
fini_debug_store_on_cpu(cpu);
3575-
3576-
if (x86_pmu.counter_freezing)
3577-
disable_counter_freeze();
35783581
}
35793582

35803583
static void intel_pmu_sched_task(struct perf_event_context *ctx,
@@ -3663,6 +3666,7 @@ static __initconst const struct x86_pmu core_pmu = {
36633666
.cpu_prepare = intel_pmu_cpu_prepare,
36643667
.cpu_starting = intel_pmu_cpu_starting,
36653668
.cpu_dying = intel_pmu_cpu_dying,
3669+
.cpu_dead = intel_pmu_cpu_dead,
36663670
};
36673671

36683672
static struct attribute *intel_pmu_attrs[];
@@ -3703,6 +3707,8 @@ static __initconst const struct x86_pmu intel_pmu = {
37033707
.cpu_prepare = intel_pmu_cpu_prepare,
37043708
.cpu_starting = intel_pmu_cpu_starting,
37053709
.cpu_dying = intel_pmu_cpu_dying,
3710+
.cpu_dead = intel_pmu_cpu_dead,
3711+
37063712
.guest_get_msrs = intel_guest_get_msrs,
37073713
.sched_task = intel_pmu_sched_task,
37083714
};

arch/x86/events/intel/uncore_snbep.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,8 @@ static struct pci_driver snbep_uncore_pci_driver = {
12221222
.id_table = snbep_uncore_pci_ids,
12231223
};
12241224

1225+
#define NODE_ID_MASK 0x7
1226+
12251227
/*
12261228
* build pci bus to socket mapping
12271229
*/
@@ -1243,7 +1245,7 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
12431245
err = pci_read_config_dword(ubox_dev, nodeid_loc, &config);
12441246
if (err)
12451247
break;
1246-
nodeid = config;
1248+
nodeid = config & NODE_ID_MASK;
12471249
/* get the Node ID mapping */
12481250
err = pci_read_config_dword(ubox_dev, idmap_loc, &config);
12491251
if (err)

kernel/events/ring_buffer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,9 @@ struct ring_buffer *rb_alloc(int nr_pages, long watermark, int cpu, int flags)
734734
size = sizeof(struct ring_buffer);
735735
size += nr_pages * sizeof(void *);
736736

737+
if (order_base_2(size) >= MAX_ORDER)
738+
goto fail;
739+
737740
rb = kzalloc(size, GFP_KERNEL);
738741
if (!rb)
739742
goto fail;

tools/include/uapi/linux/in.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ struct sockaddr_in {
268268
#define IN_MULTICAST(a) IN_CLASSD(a)
269269
#define IN_MULTICAST_NET 0xe0000000
270270

271-
#define IN_BADCLASS(a) ((((long int) (a) ) == 0xffffffff)
271+
#define IN_BADCLASS(a) (((long int) (a) ) == (long int)0xffffffff)
272272
#define IN_EXPERIMENTAL(a) IN_BADCLASS((a))
273273

274274
#define IN_CLASSE(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000)

tools/perf/Documentation/perf-c2c.txt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ C2C stands for Cache To Cache.
1919
The perf c2c tool provides means for Shared Data C2C/HITM analysis. It allows
2020
you to track down the cacheline contentions.
2121

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:
2427
- memory address of the access
2528
- type of the access (load and store details)
2629
- latency (in cycles) of the load access
@@ -46,7 +49,7 @@ RECORD OPTIONS
4649

4750
-l::
4851
--ldlat::
49-
Configure mem-loads latency.
52+
Configure mem-loads latency. (x86 only)
5053

5154
-k::
5255
--all-kernel::
@@ -119,11 +122,16 @@ Following perf record options are configured by default:
119122
-W,-d,--phys-data,--sample-cpu
120123

121124
Unless specified otherwise with '-e' option, following events are monitored by
122-
default:
125+
default on x86:
123126

124127
cpu/mem-loads,ldlat=30/P
125128
cpu/mem-stores/P
126129

130+
and following on PowerPC:
131+
132+
cpu/mem-loads/
133+
cpu/mem-stores/
134+
127135
User can pass any 'perf record' option behind '--' mark, like (to enable
128136
callchains and system wide monitoring):
129137

tools/perf/Documentation/perf-mem.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ RECORD OPTIONS
8282
Be more verbose (show counter open errors, etc)
8383

8484
--ldlat <n>::
85-
Specify desired latency for loads event.
85+
Specify desired latency for loads event. (x86 only)
8686

8787
In addition, for report all perf report options are valid, and for record
8888
all perf record options.

tools/perf/arch/powerpc/util/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ libperf-y += header.o
22
libperf-y += sym-handling.o
33
libperf-y += kvm-stat.o
44
libperf-y += perf_regs.o
5+
libperf-y += mem-events.o
56

67
libperf-$(CONFIG_DWARF) += dwarf-regs.o
78
libperf-$(CONFIG_DWARF) += skip-callchain-idx.o
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
}

tools/perf/builtin-trace.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2514,19 +2514,30 @@ static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp);
25142514

25152515
static bool perf_evlist__add_vfs_getname(struct perf_evlist *evlist)
25162516
{
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);
25182521

2519-
if (IS_ERR(evsel))
2522+
if (ret)
25202523
return false;
25212524

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;
25232537
perf_evsel__delete(evsel);
2524-
return false;
25252538
}
25262539

2527-
evsel->handler = trace__vfs_getname;
2528-
perf_evlist__add(evlist, evsel);
2529-
return true;
2540+
return found;
25302541
}
25312542

25322543
static struct perf_evsel *perf_evsel__new_pgfault(u64 config)

tools/perf/tests/attr.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
#! /usr/bin/python
22
# SPDX-License-Identifier: GPL-2.0
33

4+
from __future__ import print_function
5+
46
import os
57
import sys
68
import glob
79
import optparse
810
import tempfile
911
import logging
1012
import shutil
11-
import ConfigParser
13+
14+
try:
15+
import configparser
16+
except ImportError:
17+
import ConfigParser as configparser
1218

1319
def data_equal(a, b):
1420
# Allow multiple values in assignment separated by '|'
@@ -100,20 +106,20 @@ def __init__(self, name, data, base):
100106
def equal(self, other):
101107
for t in Event.terms:
102108
log.debug(" [%s] %s %s" % (t, self[t], other[t]));
103-
if not self.has_key(t) or not other.has_key(t):
109+
if t not in self or t not in other:
104110
return False
105111
if not data_equal(self[t], other[t]):
106112
return False
107113
return True
108114

109115
def optional(self):
110-
if self.has_key('optional') and self['optional'] == '1':
116+
if 'optional' in self and self['optional'] == '1':
111117
return True
112118
return False
113119

114120
def diff(self, other):
115121
for t in Event.terms:
116-
if not self.has_key(t) or not other.has_key(t):
122+
if t not in self or t not in other:
117123
continue
118124
if not data_equal(self[t], other[t]):
119125
log.warning("expected %s=%s, got %s" % (t, self[t], other[t]))
@@ -134,7 +140,7 @@ def diff(self, other):
134140
# - expected values assignments
135141
class Test(object):
136142
def __init__(self, path, options):
137-
parser = ConfigParser.SafeConfigParser()
143+
parser = configparser.SafeConfigParser()
138144
parser.read(path)
139145

140146
log.warning("running '%s'" % path)
@@ -193,7 +199,7 @@ def skip_test(self, myarch):
193199
return True
194200

195201
def load_events(self, path, events):
196-
parser_event = ConfigParser.SafeConfigParser()
202+
parser_event = configparser.SafeConfigParser()
197203
parser_event.read(path)
198204

199205
# The event record section header contains 'event' word,
@@ -207,7 +213,7 @@ def load_events(self, path, events):
207213
# Read parent event if there's any
208214
if (':' in section):
209215
base = section[section.index(':') + 1:]
210-
parser_base = ConfigParser.SafeConfigParser()
216+
parser_base = configparser.SafeConfigParser()
211217
parser_base.read(self.test_dir + '/' + base)
212218
base_items = parser_base.items('event')
213219

@@ -322,9 +328,9 @@ def run_tests(options):
322328
for f in glob.glob(options.test_dir + '/' + options.test):
323329
try:
324330
Test(f, options).run()
325-
except Unsup, obj:
331+
except Unsup as obj:
326332
log.warning("unsupp %s" % obj.getMsg())
327-
except Notest, obj:
333+
except Notest as obj:
328334
log.warning("skipped %s" % obj.getMsg())
329335

330336
def setup_log(verbose):
@@ -363,7 +369,7 @@ def main():
363369
parser.add_option("-p", "--perf",
364370
action="store", type="string", dest="perf")
365371
parser.add_option("-v", "--verbose",
366-
action="count", dest="verbose")
372+
default=0, action="count", dest="verbose")
367373

368374
options, args = parser.parse_args()
369375
if args:
@@ -373,7 +379,7 @@ def main():
373379
setup_log(options.verbose)
374380

375381
if not options.test_dir:
376-
print 'FAILED no -d option specified'
382+
print('FAILED no -d option specified')
377383
sys.exit(-1)
378384

379385
if not options.test:
@@ -382,8 +388,8 @@ def main():
382388
try:
383389
run_tests(options)
384390

385-
except Fail, obj:
386-
print "FAILED %s" % obj.getMsg();
391+
except Fail as obj:
392+
print("FAILED %s" % obj.getMsg())
387393
sys.exit(-1)
388394

389395
sys.exit(0)

tools/perf/tests/evsel-tp-sched.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
1717
return -1;
1818
}
1919

20-
is_signed = !!(field->flags | TEP_FIELD_IS_SIGNED);
20+
is_signed = !!(field->flags & TEP_FIELD_IS_SIGNED);
2121
if (should_be_signed && !is_signed) {
2222
pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n",
2323
evsel->name, name, is_signed, should_be_signed);

tools/perf/util/c++/clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ getBPFObjectFromModule(llvm::Module *Module)
160160
}
161161
PM.run(*Module);
162162

163-
return std::move(Buffer);
163+
return Buffer;
164164
}
165165

166166
}

tools/perf/util/mem-events.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
2828
static char mem_loads_name[100];
2929
static bool mem_loads_name__init;
3030

31-
char *perf_mem_events__name(int i)
31+
char * __weak perf_mem_events__name(int i)
3232
{
3333
if (i == PERF_MEM_EVENTS__LOAD) {
3434
if (!mem_loads_name__init) {

tools/perf/util/symbol-elf.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@
1919
#define EM_AARCH64 183 /* ARM 64 bit */
2020
#endif
2121

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+
2236
typedef Elf64_Nhdr GElf_Nhdr;
2337

2438
#ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
@@ -87,6 +101,11 @@ static inline uint8_t elf_sym__type(const GElf_Sym *sym)
87101
return GELF_ST_TYPE(sym->st_info);
88102
}
89103

104+
static inline uint8_t elf_sym__visibility(const GElf_Sym *sym)
105+
{
106+
return GELF_ST_VISIBILITY(sym->st_other);
107+
}
108+
90109
#ifndef STT_GNU_IFUNC
91110
#define STT_GNU_IFUNC 10
92111
#endif
@@ -111,7 +130,9 @@ static inline int elf_sym__is_label(const GElf_Sym *sym)
111130
return elf_sym__type(sym) == STT_NOTYPE &&
112131
sym->st_name != 0 &&
113132
sym->st_shndx != SHN_UNDEF &&
114-
sym->st_shndx != SHN_ABS;
133+
sym->st_shndx != SHN_ABS &&
134+
elf_sym__visibility(sym) != STV_HIDDEN &&
135+
elf_sym__visibility(sym) != STV_INTERNAL;
115136
}
116137

117138
static bool elf_sym__filter(GElf_Sym *sym)

0 commit comments

Comments
 (0)