Skip to content

Commit 3f59dbc

Browse files
committed
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf updates from Ingo Molnar: "The main kernel side changes in this cycle were: - Various Intel-PT updates and optimizations (Alexander Shishkin) - Prohibit kprobes on Xen/KVM emulate prefixes (Masami Hiramatsu) - Add support for LSM and SELinux checks to control access to the perf syscall (Joel Fernandes) - Misc other changes, optimizations, fixes and cleanups - see the shortlog for details. There were numerous tooling changes as well - 254 non-merge commits. Here are the main changes - too many to list in detail: - Enhancements to core tooling infrastructure, perf.data, libperf, libtraceevent, event parsing, vendor events, Intel PT, callchains, BPF support and instruction decoding. - There were updates to the following tools: perf annotate perf diff perf inject perf kvm perf list perf maps perf parse perf probe perf record perf report perf script perf stat perf test perf trace - And a lot of other changes: please see the shortlog and Git log for more details" * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (279 commits) perf parse: Fix potential memory leak when handling tracepoint errors perf probe: Fix spelling mistake "addrees" -> "address" libtraceevent: Fix memory leakage in copy_filter_type libtraceevent: Fix header installation perf intel-bts: Does not support AUX area sampling perf intel-pt: Add support for decoding AUX area samples perf intel-pt: Add support for recording AUX area samples perf pmu: When using default config, record which bits of config were changed by the user perf auxtrace: Add support for queuing AUX area samples perf session: Add facility to peek at all events perf auxtrace: Add support for dumping AUX area samples perf inject: Cut AUX area samples perf record: Add aux-sample-size config term perf record: Add support for AUX area sampling perf auxtrace: Add support for AUX area sample recording perf auxtrace: Move perf_evsel__find_pmu() perf record: Add a function to test for kernel support for AUX area sampling perf tools: Add kernel AUX area sampling definitions perf/core: Make the mlock accounting simple again perf report: Jump to symbol source view from total cycles view ...
2 parents df28204 + ceb9e77 commit 3f59dbc

File tree

297 files changed

+32874
-23281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

297 files changed

+32874
-23281
lines changed

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12846,6 +12846,13 @@ F: arch/*/events/*
1284612846
F: arch/*/events/*/*
1284712847
F: tools/perf/
1284812848

12849+
PERFORMANCE EVENTS SUBSYSTEM ARM64 PMU EVENTS
12850+
R: John Garry <[email protected]>
12851+
R: Will Deacon <[email protected]>
12852+
L: [email protected] (moderated for non-subscribers)
12853+
S: Supported
12854+
F: tools/perf/pmu-events/arch/arm64/
12855+
1284912856
PERSONALITY HANDLING
1285012857
M: Christoph Hellwig <[email protected]>
1285112858

arch/powerpc/perf/core-book3s.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static inline unsigned long perf_ip_adjust(struct pt_regs *regs)
9696
{
9797
return 0;
9898
}
99-
static inline void perf_get_data_addr(struct pt_regs *regs, u64 *addrp) { }
99+
static inline void perf_get_data_addr(struct perf_event *event, struct pt_regs *regs, u64 *addrp) { }
100100
static inline u32 perf_get_misc_flags(struct pt_regs *regs)
101101
{
102102
return 0;
@@ -127,7 +127,7 @@ static unsigned long ebb_switch_in(bool ebb, struct cpu_hw_events *cpuhw)
127127
static inline void power_pmu_bhrb_enable(struct perf_event *event) {}
128128
static inline void power_pmu_bhrb_disable(struct perf_event *event) {}
129129
static void power_pmu_sched_task(struct perf_event_context *ctx, bool sched_in) {}
130-
static inline void power_pmu_bhrb_read(struct cpu_hw_events *cpuhw) {}
130+
static inline void power_pmu_bhrb_read(struct perf_event *event, struct cpu_hw_events *cpuhw) {}
131131
static void pmao_restore_workaround(bool ebb) { }
132132
#endif /* CONFIG_PPC32 */
133133

@@ -179,7 +179,7 @@ static inline unsigned long perf_ip_adjust(struct pt_regs *regs)
179179
* pointed to by SIAR; this is indicated by the [POWER6_]MMCRA_SDSYNC, the
180180
* [POWER7P_]MMCRA_SDAR_VALID bit in MMCRA, or the SDAR_VALID bit in SIER.
181181
*/
182-
static inline void perf_get_data_addr(struct pt_regs *regs, u64 *addrp)
182+
static inline void perf_get_data_addr(struct perf_event *event, struct pt_regs *regs, u64 *addrp)
183183
{
184184
unsigned long mmcra = regs->dsisr;
185185
bool sdar_valid;
@@ -204,8 +204,7 @@ static inline void perf_get_data_addr(struct pt_regs *regs, u64 *addrp)
204204
if (!(mmcra & MMCRA_SAMPLE_ENABLE) || sdar_valid)
205205
*addrp = mfspr(SPRN_SDAR);
206206

207-
if (perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN) &&
208-
is_kernel_addr(mfspr(SPRN_SDAR)))
207+
if (is_kernel_addr(mfspr(SPRN_SDAR)) && perf_allow_kernel(&event->attr) != 0)
209208
*addrp = 0;
210209
}
211210

@@ -444,7 +443,7 @@ static __u64 power_pmu_bhrb_to(u64 addr)
444443
}
445444

446445
/* Processing BHRB entries */
447-
static void power_pmu_bhrb_read(struct cpu_hw_events *cpuhw)
446+
static void power_pmu_bhrb_read(struct perf_event *event, struct cpu_hw_events *cpuhw)
448447
{
449448
u64 val;
450449
u64 addr;
@@ -472,8 +471,7 @@ static void power_pmu_bhrb_read(struct cpu_hw_events *cpuhw)
472471
* exporting it to userspace (avoid exposure of regions
473472
* where we could have speculative execution)
474473
*/
475-
if (perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN) &&
476-
is_kernel_addr(addr))
474+
if (is_kernel_addr(addr) && perf_allow_kernel(&event->attr) != 0)
477475
continue;
478476

479477
/* Branches are read most recent first (ie. mfbhrb 0 is
@@ -2087,12 +2085,12 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
20872085

20882086
if (event->attr.sample_type &
20892087
(PERF_SAMPLE_ADDR | PERF_SAMPLE_PHYS_ADDR))
2090-
perf_get_data_addr(regs, &data.addr);
2088+
perf_get_data_addr(event, regs, &data.addr);
20912089

20922090
if (event->attr.sample_type & PERF_SAMPLE_BRANCH_STACK) {
20932091
struct cpu_hw_events *cpuhw;
20942092
cpuhw = this_cpu_ptr(&cpu_hw_events);
2095-
power_pmu_bhrb_read(cpuhw);
2093+
power_pmu_bhrb_read(event, cpuhw);
20962094
data.br_stack = &cpuhw->bhrb_stack;
20972095
}
20982096

arch/x86/events/amd/core.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -652,15 +652,7 @@ static void amd_pmu_disable_event(struct perf_event *event)
652652
*/
653653
static int amd_pmu_handle_irq(struct pt_regs *regs)
654654
{
655-
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
656-
int active, handled;
657-
658-
/*
659-
* Obtain the active count before calling x86_pmu_handle_irq() since
660-
* it is possible that x86_pmu_handle_irq() may make a counter
661-
* inactive (through x86_pmu_stop).
662-
*/
663-
active = __bitmap_weight(cpuc->active_mask, X86_PMC_IDX_MAX);
655+
int handled;
664656

665657
/* Process any counter overflows */
666658
handled = x86_pmu_handle_irq(regs);
@@ -670,8 +662,7 @@ static int amd_pmu_handle_irq(struct pt_regs *regs)
670662
* NMIs will be claimed if arriving within that window.
671663
*/
672664
if (handled) {
673-
this_cpu_write(perf_nmi_tstamp,
674-
jiffies + perf_nmi_window);
665+
this_cpu_write(perf_nmi_tstamp, jiffies + perf_nmi_window);
675666

676667
return handled;
677668
}

arch/x86/events/core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,6 +2243,13 @@ static void x86_pmu_sched_task(struct perf_event_context *ctx, bool sched_in)
22432243
x86_pmu.sched_task(ctx, sched_in);
22442244
}
22452245

2246+
static void x86_pmu_swap_task_ctx(struct perf_event_context *prev,
2247+
struct perf_event_context *next)
2248+
{
2249+
if (x86_pmu.swap_task_ctx)
2250+
x86_pmu.swap_task_ctx(prev, next);
2251+
}
2252+
22462253
void perf_check_microcode(void)
22472254
{
22482255
if (x86_pmu.check_microcode)
@@ -2297,6 +2304,7 @@ static struct pmu pmu = {
22972304
.event_idx = x86_pmu_event_idx,
22982305
.sched_task = x86_pmu_sched_task,
22992306
.task_ctx_size = sizeof(struct x86_perf_task_context),
2307+
.swap_task_ctx = x86_pmu_swap_task_ctx,
23002308
.check_period = x86_pmu_check_period,
23012309

23022310
.aux_output_match = x86_pmu_aux_output_match,

arch/x86/events/intel/bts.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,11 @@ static int bts_event_init(struct perf_event *event)
549549
* Note that the default paranoia setting permits unprivileged
550550
* users to profile the kernel.
551551
*/
552-
if (event->attr.exclude_kernel && perf_paranoid_kernel() &&
553-
!capable(CAP_SYS_ADMIN))
554-
return -EACCES;
552+
if (event->attr.exclude_kernel) {
553+
ret = perf_allow_kernel(&event->attr);
554+
if (ret)
555+
return ret;
556+
}
555557

556558
if (x86_add_exclusive(x86_lbr_exclusive_bts))
557559
return -EBUSY;

arch/x86/events/intel/core.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3315,8 +3315,9 @@ static int intel_pmu_hw_config(struct perf_event *event)
33153315
if (x86_pmu.version < 3)
33163316
return -EINVAL;
33173317

3318-
if (perf_paranoid_cpu() && !capable(CAP_SYS_ADMIN))
3319-
return -EACCES;
3318+
ret = perf_allow_cpu(&event->attr);
3319+
if (ret)
3320+
return ret;
33203321

33213322
event->hw.config |= ARCH_PERFMON_EVENTSEL_ANY;
33223323

@@ -3830,6 +3831,12 @@ static void intel_pmu_sched_task(struct perf_event_context *ctx,
38303831
intel_pmu_lbr_sched_task(ctx, sched_in);
38313832
}
38323833

3834+
static void intel_pmu_swap_task_ctx(struct perf_event_context *prev,
3835+
struct perf_event_context *next)
3836+
{
3837+
intel_pmu_lbr_swap_task_ctx(prev, next);
3838+
}
3839+
38333840
static int intel_pmu_check_period(struct perf_event *event, u64 value)
38343841
{
38353842
return intel_pmu_has_bts_period(event, value) ? -EINVAL : 0;
@@ -3965,6 +3972,7 @@ static __initconst const struct x86_pmu intel_pmu = {
39653972

39663973
.guest_get_msrs = intel_guest_get_msrs,
39673974
.sched_task = intel_pmu_sched_task,
3975+
.swap_task_ctx = intel_pmu_swap_task_ctx,
39683976

39693977
.check_period = intel_pmu_check_period,
39703978

arch/x86/events/intel/lbr.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,29 @@ static void __intel_pmu_lbr_save(struct x86_perf_task_context *task_ctx)
417417
cpuc->last_log_id = ++task_ctx->log_id;
418418
}
419419

420+
void intel_pmu_lbr_swap_task_ctx(struct perf_event_context *prev,
421+
struct perf_event_context *next)
422+
{
423+
struct x86_perf_task_context *prev_ctx_data, *next_ctx_data;
424+
425+
swap(prev->task_ctx_data, next->task_ctx_data);
426+
427+
/*
428+
* Architecture specific synchronization makes sense in
429+
* case both prev->task_ctx_data and next->task_ctx_data
430+
* pointers are allocated.
431+
*/
432+
433+
prev_ctx_data = next->task_ctx_data;
434+
next_ctx_data = prev->task_ctx_data;
435+
436+
if (!prev_ctx_data || !next_ctx_data)
437+
return;
438+
439+
swap(prev_ctx_data->lbr_callstack_users,
440+
next_ctx_data->lbr_callstack_users);
441+
}
442+
420443
void intel_pmu_lbr_sched_task(struct perf_event_context *ctx, bool sched_in)
421444
{
422445
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);

arch/x86/events/intel/p4.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,8 +776,9 @@ static int p4_validate_raw_event(struct perf_event *event)
776776
* the user needs special permissions to be able to use it
777777
*/
778778
if (p4_ht_active() && p4_event_bind_map[v].shared) {
779-
if (perf_paranoid_cpu() && !capable(CAP_SYS_ADMIN))
780-
return -EACCES;
779+
v = perf_allow_cpu(&event->attr);
780+
if (v)
781+
return v;
781782
}
782783

783784
/* ESCR EventMask bits may be invalid */

0 commit comments

Comments
 (0)