Skip to content

Commit e99bc91

Browse files
committed
Merge tag 'perf-urgent-2020-03-15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Thomas Gleixner: "A pile of perf fixes: Kernel side: - AMD uncore driver: Replace the open coded sanity check with the core variant, which provides the correct error code and also leaves a hint in dmesg Tooling: - Fix the stdio input handling with glibc versions >= 2.28 - Unbreak the futex-wake benchmark which was reduced to 0 test threads due to the conversion to cpumaps - Initialize sigaction structs before invoking sys_sigactio() - Plug the mapfile memory leak in perf jevents - Fix off by one relative directory includes - Fix an undefined string comparison in perf diff" * tag 'perf-urgent-2020-03-15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/amd/uncore: Replace manual sampling check with CAP_NO_INTERRUPT flag tools: Fix off-by 1 relative directory includes perf jevents: Fix leak of mapfile memory perf bench: Clear struct sigaction before sigaction() syscall perf bench futex-wake: Restore thread count default to online CPU count perf top: Fix stdio interface input handling with glibc 2.28+ perf diff: Fix undefined string comparision spotted by clang's -Wstring-compare perf symbols: Don't try to find a vmlinux file when looking for kernel modules perf bench: Share some global variables to fix build with gcc 10 perf parse-events: Use asprintf() instead of strncpy() to read tracepoint files perf env: Do not return pointers to local variables perf tests bp_account: Make global variable static
2 parents ffe6da9 + f967140 commit e99bc91

30 files changed

+139
-134
lines changed

arch/x86/events/amd/uncore.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,12 @@ static int amd_uncore_event_init(struct perf_event *event)
190190

191191
/*
192192
* NB and Last level cache counters (MSRs) are shared across all cores
193-
* that share the same NB / Last level cache. Interrupts can be directed
194-
* to a single target core, however, event counts generated by processes
195-
* running on other cores cannot be masked out. So we do not support
196-
* sampling and per-thread events.
193+
* that share the same NB / Last level cache. On family 16h and below,
194+
* Interrupts can be directed to a single target core, however, event
195+
* counts generated by processes running on other cores cannot be masked
196+
* out. So we do not support sampling and per-thread events via
197+
* CAP_NO_INTERRUPT, and we do not enable counter overflow interrupts:
197198
*/
198-
if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK)
199-
return -EINVAL;
200-
201-
/* and we do not enable counter overflow interrupts */
202199
hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB;
203200
hwc->idx = -1;
204201

@@ -306,7 +303,7 @@ static struct pmu amd_nb_pmu = {
306303
.start = amd_uncore_start,
307304
.stop = amd_uncore_stop,
308305
.read = amd_uncore_read,
309-
.capabilities = PERF_PMU_CAP_NO_EXCLUDE,
306+
.capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_INTERRUPT,
310307
};
311308

312309
static struct pmu amd_llc_pmu = {
@@ -317,7 +314,7 @@ static struct pmu amd_llc_pmu = {
317314
.start = amd_uncore_start,
318315
.stop = amd_uncore_stop,
319316
.read = amd_uncore_read,
320-
.capabilities = PERF_PMU_CAP_NO_EXCLUDE,
317+
.capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_INTERRUPT,
321318
};
322319

323320
static struct amd_uncore *amd_uncore_alloc(unsigned int cpu)

tools/include/uapi/asm/errno.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
#if defined(__i386__) || defined(__x86_64__)
3-
#include "../../arch/x86/include/uapi/asm/errno.h"
3+
#include "../../../arch/x86/include/uapi/asm/errno.h"
44
#elif defined(__powerpc__)
5-
#include "../../arch/powerpc/include/uapi/asm/errno.h"
5+
#include "../../../arch/powerpc/include/uapi/asm/errno.h"
66
#elif defined(__sparc__)
7-
#include "../../arch/sparc/include/uapi/asm/errno.h"
7+
#include "../../../arch/sparc/include/uapi/asm/errno.h"
88
#elif defined(__alpha__)
9-
#include "../../arch/alpha/include/uapi/asm/errno.h"
9+
#include "../../../arch/alpha/include/uapi/asm/errno.h"
1010
#elif defined(__mips__)
11-
#include "../../arch/mips/include/uapi/asm/errno.h"
11+
#include "../../../arch/mips/include/uapi/asm/errno.h"
1212
#elif defined(__ia64__)
13-
#include "../../arch/ia64/include/uapi/asm/errno.h"
13+
#include "../../../arch/ia64/include/uapi/asm/errno.h"
1414
#elif defined(__xtensa__)
15-
#include "../../arch/xtensa/include/uapi/asm/errno.h"
15+
#include "../../../arch/xtensa/include/uapi/asm/errno.h"
1616
#else
1717
#include <asm-generic/errno.h>
1818
#endif

tools/perf/arch/arm64/util/arm-spe.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
#include <linux/zalloc.h>
1212
#include <time.h>
1313

14-
#include "../../util/cpumap.h"
15-
#include "../../util/event.h"
16-
#include "../../util/evsel.h"
17-
#include "../../util/evlist.h"
18-
#include "../../util/session.h"
14+
#include "../../../util/cpumap.h"
15+
#include "../../../util/event.h"
16+
#include "../../../util/evsel.h"
17+
#include "../../../util/evlist.h"
18+
#include "../../../util/session.h"
1919
#include <internal/lib.h> // page_size
20-
#include "../../util/pmu.h"
21-
#include "../../util/debug.h"
22-
#include "../../util/auxtrace.h"
23-
#include "../../util/record.h"
24-
#include "../../util/arm-spe.h"
20+
#include "../../../util/pmu.h"
21+
#include "../../../util/debug.h"
22+
#include "../../../util/auxtrace.h"
23+
#include "../../../util/record.h"
24+
#include "../../../util/arm-spe.h"
2525

2626
#define KiB(x) ((x) * 1024)
2727
#define MiB(x) ((x) * 1024 * 1024)

tools/perf/arch/arm64/util/perf_regs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0
2-
#include "../../util/perf_regs.h"
2+
#include "../../../util/perf_regs.h"
33

44
const struct sample_reg sample_reg_masks[] = {
55
SMPL_REG_END

tools/perf/arch/powerpc/util/perf_regs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#include <regex.h>
55
#include <linux/zalloc.h>
66

7-
#include "../../util/perf_regs.h"
8-
#include "../../util/debug.h"
7+
#include "../../../util/perf_regs.h"
8+
#include "../../../util/debug.h"
99

1010
#include <linux/kernel.h>
1111

tools/perf/arch/x86/util/auxtrace.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
#include <errno.h>
88
#include <stdbool.h>
99

10-
#include "../../util/header.h"
11-
#include "../../util/debug.h"
12-
#include "../../util/pmu.h"
13-
#include "../../util/auxtrace.h"
14-
#include "../../util/intel-pt.h"
15-
#include "../../util/intel-bts.h"
16-
#include "../../util/evlist.h"
10+
#include "../../../util/header.h"
11+
#include "../../../util/debug.h"
12+
#include "../../../util/pmu.h"
13+
#include "../../../util/auxtrace.h"
14+
#include "../../../util/intel-pt.h"
15+
#include "../../../util/intel-bts.h"
16+
#include "../../../util/evlist.h"
1717

1818
static
1919
struct auxtrace_record *auxtrace_record__init_intel(struct evlist *evlist,

tools/perf/arch/x86/util/event.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
#include <linux/string.h>
44
#include <linux/zalloc.h>
55

6-
#include "../../util/event.h"
7-
#include "../../util/synthetic-events.h"
8-
#include "../../util/machine.h"
9-
#include "../../util/tool.h"
10-
#include "../../util/map.h"
11-
#include "../../util/debug.h"
6+
#include "../../../util/event.h"
7+
#include "../../../util/synthetic-events.h"
8+
#include "../../../util/machine.h"
9+
#include "../../../util/tool.h"
10+
#include "../../../util/map.h"
11+
#include "../../../util/debug.h"
1212

1313
#if defined(__x86_64__)
1414

tools/perf/arch/x86/util/header.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#include <string.h>
88
#include <regex.h>
99

10-
#include "../../util/debug.h"
11-
#include "../../util/header.h"
10+
#include "../../../util/debug.h"
11+
#include "../../../util/header.h"
1212

1313
static inline void
1414
cpuid(unsigned int op, unsigned int *a, unsigned int *b, unsigned int *c,

tools/perf/arch/x86/util/intel-bts.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111
#include <linux/log2.h>
1212
#include <linux/zalloc.h>
1313

14-
#include "../../util/cpumap.h"
15-
#include "../../util/event.h"
16-
#include "../../util/evsel.h"
17-
#include "../../util/evlist.h"
18-
#include "../../util/mmap.h"
19-
#include "../../util/session.h"
20-
#include "../../util/pmu.h"
21-
#include "../../util/debug.h"
22-
#include "../../util/record.h"
23-
#include "../../util/tsc.h"
24-
#include "../../util/auxtrace.h"
25-
#include "../../util/intel-bts.h"
14+
#include "../../../util/cpumap.h"
15+
#include "../../../util/event.h"
16+
#include "../../../util/evsel.h"
17+
#include "../../../util/evlist.h"
18+
#include "../../../util/mmap.h"
19+
#include "../../../util/session.h"
20+
#include "../../../util/pmu.h"
21+
#include "../../../util/debug.h"
22+
#include "../../../util/record.h"
23+
#include "../../../util/tsc.h"
24+
#include "../../../util/auxtrace.h"
25+
#include "../../../util/intel-bts.h"
2626
#include <internal/lib.h> // page_size
2727

2828
#define KiB(x) ((x) * 1024)

tools/perf/arch/x86/util/intel-pt.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@
1313
#include <linux/zalloc.h>
1414
#include <cpuid.h>
1515

16-
#include "../../util/session.h"
17-
#include "../../util/event.h"
18-
#include "../../util/evlist.h"
19-
#include "../../util/evsel.h"
20-
#include "../../util/evsel_config.h"
21-
#include "../../util/cpumap.h"
22-
#include "../../util/mmap.h"
16+
#include "../../../util/session.h"
17+
#include "../../../util/event.h"
18+
#include "../../../util/evlist.h"
19+
#include "../../../util/evsel.h"
20+
#include "../../../util/evsel_config.h"
21+
#include "../../../util/cpumap.h"
22+
#include "../../../util/mmap.h"
2323
#include <subcmd/parse-options.h>
24-
#include "../../util/parse-events.h"
25-
#include "../../util/pmu.h"
26-
#include "../../util/debug.h"
27-
#include "../../util/auxtrace.h"
28-
#include "../../util/record.h"
29-
#include "../../util/target.h"
30-
#include "../../util/tsc.h"
24+
#include "../../../util/parse-events.h"
25+
#include "../../../util/pmu.h"
26+
#include "../../../util/debug.h"
27+
#include "../../../util/auxtrace.h"
28+
#include "../../../util/record.h"
29+
#include "../../../util/target.h"
30+
#include "../../../util/tsc.h"
3131
#include <internal/lib.h> // page_size
32-
#include "../../util/intel-pt.h"
32+
#include "../../../util/intel-pt.h"
3333

3434
#define KiB(x) ((x) * 1024)
3535
#define MiB(x) ((x) * 1024 * 1024)

tools/perf/arch/x86/util/machine.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#include <stdlib.h>
66

77
#include <internal/lib.h> // page_size
8-
#include "../../util/machine.h"
9-
#include "../../util/map.h"
10-
#include "../../util/symbol.h"
8+
#include "../../../util/machine.h"
9+
#include "../../../util/map.h"
10+
#include "../../../util/symbol.h"
1111
#include <linux/ctype.h>
1212

1313
#include <symbol/kallsyms.h>

tools/perf/arch/x86/util/perf_regs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#include <linux/kernel.h>
66
#include <linux/zalloc.h>
77

8-
#include "../../perf-sys.h"
9-
#include "../../util/perf_regs.h"
10-
#include "../../util/debug.h"
11-
#include "../../util/event.h"
8+
#include "../../../perf-sys.h"
9+
#include "../../../util/perf_regs.h"
10+
#include "../../../util/debug.h"
11+
#include "../../../util/event.h"
1212

1313
const struct sample_reg sample_reg_masks[] = {
1414
SMPL_REG(AX, PERF_REG_X86_AX),

tools/perf/arch/x86/util/pmu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#include <linux/stddef.h>
55
#include <linux/perf_event.h>
66

7-
#include "../../util/intel-pt.h"
8-
#include "../../util/intel-bts.h"
9-
#include "../../util/pmu.h"
7+
#include "../../../util/intel-pt.h"
8+
#include "../../../util/intel-bts.h"
9+
#include "../../../util/pmu.h"
1010

1111
struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
1212
{

tools/perf/bench/bench.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#ifndef BENCH_H
33
#define BENCH_H
44

5+
#include <sys/time.h>
6+
7+
extern struct timeval bench__start, bench__end, bench__runtime;
8+
59
/*
610
* The madvise transparent hugepage constants were added in glibc
711
* 2.13. For compatibility with older versions of glibc, define these

tools/perf/bench/epoll-ctl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
static unsigned int nthreads = 0;
3737
static unsigned int nsecs = 8;
38-
struct timeval start, end, runtime;
3938
static bool done, __verbose, randomize;
4039

4140
/*
@@ -94,8 +93,8 @@ static void toggle_done(int sig __maybe_unused,
9493
{
9594
/* inform all threads that we're done for the day */
9695
done = true;
97-
gettimeofday(&end, NULL);
98-
timersub(&end, &start, &runtime);
96+
gettimeofday(&bench__end, NULL);
97+
timersub(&bench__end, &bench__start, &bench__runtime);
9998
}
10099

101100
static void nest_epollfd(void)
@@ -313,6 +312,7 @@ int bench_epoll_ctl(int argc, const char **argv)
313312
exit(EXIT_FAILURE);
314313
}
315314

315+
memset(&act, 0, sizeof(act));
316316
sigfillset(&act.sa_mask);
317317
act.sa_sigaction = toggle_done;
318318
sigaction(SIGINT, &act, NULL);
@@ -361,7 +361,7 @@ int bench_epoll_ctl(int argc, const char **argv)
361361

362362
threads_starting = nthreads;
363363

364-
gettimeofday(&start, NULL);
364+
gettimeofday(&bench__start, NULL);
365365

366366
do_threads(worker, cpu);
367367

tools/perf/bench/epoll-wait.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090

9191
static unsigned int nthreads = 0;
9292
static unsigned int nsecs = 8;
93-
struct timeval start, end, runtime;
9493
static bool wdone, done, __verbose, randomize, nonblocking;
9594

9695
/*
@@ -276,8 +275,8 @@ static void toggle_done(int sig __maybe_unused,
276275
{
277276
/* inform all threads that we're done for the day */
278277
done = true;
279-
gettimeofday(&end, NULL);
280-
timersub(&end, &start, &runtime);
278+
gettimeofday(&bench__end, NULL);
279+
timersub(&bench__end, &bench__start, &bench__runtime);
281280
}
282281

283282
static void print_summary(void)
@@ -287,7 +286,7 @@ static void print_summary(void)
287286

288287
printf("\nAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n",
289288
avg, rel_stddev_stats(stddev, avg),
290-
(int) runtime.tv_sec);
289+
(int)bench__runtime.tv_sec);
291290
}
292291

293292
static int do_threads(struct worker *worker, struct perf_cpu_map *cpu)
@@ -427,6 +426,7 @@ int bench_epoll_wait(int argc, const char **argv)
427426
exit(EXIT_FAILURE);
428427
}
429428

429+
memset(&act, 0, sizeof(act));
430430
sigfillset(&act.sa_mask);
431431
act.sa_sigaction = toggle_done;
432432
sigaction(SIGINT, &act, NULL);
@@ -479,7 +479,7 @@ int bench_epoll_wait(int argc, const char **argv)
479479

480480
threads_starting = nthreads;
481481

482-
gettimeofday(&start, NULL);
482+
gettimeofday(&bench__start, NULL);
483483

484484
do_threads(worker, cpu);
485485

@@ -519,7 +519,7 @@ int bench_epoll_wait(int argc, const char **argv)
519519
qsort(worker, nthreads, sizeof(struct worker), cmpworker);
520520

521521
for (i = 0; i < nthreads; i++) {
522-
unsigned long t = worker[i].ops/runtime.tv_sec;
522+
unsigned long t = worker[i].ops / bench__runtime.tv_sec;
523523

524524
update_stats(&throughput_stats, t);
525525

0 commit comments

Comments
 (0)