mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-17 05:45:20 +00:00
f41dac3efb
- Uprobes: - Add BPF session support (Jiri Olsa) - Switch to RCU Tasks Trace flavor for better performance (Andrii Nakryiko) - Massively increase uretprobe SMP scalability by SRCU-protecting the uretprobe lifetime (Andrii Nakryiko) - Kill xol_area->slot_count (Oleg Nesterov) - Core facilities: - Implement targeted high-frequency profiling by adding the ability for an event to "pause" or "resume" AUX area tracing (Adrian Hunter) - VM profiling/sampling: - Correct perf sampling with guest VMs (Colton Lewis) - New hardware support: - x86/intel: Add PMU support for Intel ArrowLake-H CPUs (Dapeng Mi) - Misc fixes and enhancements: - x86/intel/pt: Fix buffer full but size is 0 case (Adrian Hunter) - x86/amd: Warn only on new bits set (Breno Leitao) - x86/amd/uncore: Avoid a false positive warning about snprintf truncation in amd_uncore_umc_ctx_init (Jean Delvare) - uprobes: Re-order struct uprobe_task to save some space (Christophe JAILLET) - x86/rapl: Move the pmu allocation out of CPU hotplug (Kan Liang) - x86/rapl: Clean up cpumask and hotplug (Kan Liang) - uprobes: Deuglify xol_get_insn_slot/xol_free_insn_slot paths (Oleg Nesterov) Signed-off-by: Ingo Molnar <mingo@kernel.org> -----BEGIN PGP SIGNATURE----- iQJFBAABCgAvFiEEBpT5eoXrXCwVQwEKEnMQ0APhK1gFAmc7eKERHG1pbmdvQGtl cm5lbC5vcmcACgkQEnMQ0APhK1i57A/+KQ6TrIoICVTE+BPlDfUw8NU+N3DagVb0 dzoyDxlDRsnsYzeXZipPn+3IitX1w+DrGxBNIojSoiFVCLnHIKgo4uHbj7cVrR7J fBTVSnoJ94SGAk5ySebvLwMLce/YhXBeHK2lx6W/pI6acNcxzDfIabjjETeqltUo g7hmT9lo10pzZEZyuUfYX9khlWBxda1dKHc9pMIq7baeLe4iz/fCGlJ0K4d4M4z3 NPZw239Np6iHUwu3Lcs4gNKe4rcDe7Bt47hpedemHe0Y+7c4s2HaPxbXWxvDtE76 mlsg93i28f8SYxeV83pREn0EOCptXcljhiek+US+GR7NSbltMnV+uUiDfPKIE9+Y vYP/DYF9hx73FsOucEFrHxYYcePorn3pne5/khBYWdQU6TnlrBYWpoLQsjgCKTTR 4JhCFlBZ5cDpc6ihtpwCwVTQ4Q/H7vM1XOlDwx0hPhcIPPHDreaQD/wxo61jBdXf PY0EPAxh3BcQxfPYuDS+XiYjQ8qO8MtXMKz5bZyHBZlbHwccV6T4ExjsLKxFk5As 6BG8pkBWLg7drXAgVdleIY0ux+34w/Zzv7gemdlQxvWLlZrVvpjiG93oU3PTpZeq A2UD9eAOuXVD6+HsF/dmn88sFmcLWbrMskFWujkvhEUmCvSGAnz3YSS/mLEawBiT 2xI8xykNWSY= =ItOT -----END PGP SIGNATURE----- Merge tag 'perf-core-2024-11-18' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip Pull performance events updates from Ingo Molnar: "Uprobes: - Add BPF session support (Jiri Olsa) - Switch to RCU Tasks Trace flavor for better performance (Andrii Nakryiko) - Massively increase uretprobe SMP scalability by SRCU-protecting the uretprobe lifetime (Andrii Nakryiko) - Kill xol_area->slot_count (Oleg Nesterov) Core facilities: - Implement targeted high-frequency profiling by adding the ability for an event to "pause" or "resume" AUX area tracing (Adrian Hunter) VM profiling/sampling: - Correct perf sampling with guest VMs (Colton Lewis) New hardware support: - x86/intel: Add PMU support for Intel ArrowLake-H CPUs (Dapeng Mi) Misc fixes and enhancements: - x86/intel/pt: Fix buffer full but size is 0 case (Adrian Hunter) - x86/amd: Warn only on new bits set (Breno Leitao) - x86/amd/uncore: Avoid a false positive warning about snprintf truncation in amd_uncore_umc_ctx_init (Jean Delvare) - uprobes: Re-order struct uprobe_task to save some space (Christophe JAILLET) - x86/rapl: Move the pmu allocation out of CPU hotplug (Kan Liang) - x86/rapl: Clean up cpumask and hotplug (Kan Liang) - uprobes: Deuglify xol_get_insn_slot/xol_free_insn_slot paths (Oleg Nesterov)" * tag 'perf-core-2024-11-18' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (32 commits) perf/core: Correct perf sampling with guest VMs perf/x86: Refactor misc flag assignments perf/powerpc: Use perf_arch_instruction_pointer() perf/core: Hoist perf_instruction_pointer() and perf_misc_flags() perf/arm: Drop unused functions uprobes: Re-order struct uprobe_task to save some space perf/x86/amd/uncore: Avoid a false positive warning about snprintf truncation in amd_uncore_umc_ctx_init perf/x86/intel: Do not enable large PEBS for events with aux actions or aux sampling perf/x86/intel/pt: Add support for pause / resume perf/core: Add aux_pause, aux_resume, aux_start_paused perf/x86/intel/pt: Fix buffer full but size is 0 case uprobes: SRCU-protect uretprobe lifetime (with timeout) uprobes: allow put_uprobe() from non-sleepable softirq context perf/x86/rapl: Clean up cpumask and hotplug perf/x86/rapl: Move the pmu allocation out of CPU hotplug uprobe: Add support for session consumer uprobe: Add data pointer to consumer handlers perf/x86/amd: Warn only on new bits set uprobes: fold xol_take_insn_slot() into xol_get_insn_slot() uprobes: kill xol_area->slot_count ...
233 lines
5.8 KiB
C
233 lines
5.8 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Performance event support for s390x
|
|
*
|
|
* Copyright IBM Corp. 2012, 2013
|
|
* Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
|
|
*/
|
|
#define KMSG_COMPONENT "perf"
|
|
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/perf_event.h>
|
|
#include <linux/kvm_host.h>
|
|
#include <linux/percpu.h>
|
|
#include <linux/export.h>
|
|
#include <linux/seq_file.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/uaccess.h>
|
|
#include <linux/compat.h>
|
|
#include <linux/sysfs.h>
|
|
#include <asm/stacktrace.h>
|
|
#include <asm/irq.h>
|
|
#include <asm/cpu_mf.h>
|
|
#include <asm/lowcore.h>
|
|
#include <asm/processor.h>
|
|
#include <asm/sysinfo.h>
|
|
#include <asm/unwind.h>
|
|
|
|
static struct kvm_s390_sie_block *sie_block(struct pt_regs *regs)
|
|
{
|
|
struct stack_frame *stack = (struct stack_frame *) regs->gprs[15];
|
|
|
|
if (!stack)
|
|
return NULL;
|
|
|
|
return (struct kvm_s390_sie_block *)stack->sie_control_block;
|
|
}
|
|
|
|
static bool is_in_guest(struct pt_regs *regs)
|
|
{
|
|
if (user_mode(regs))
|
|
return false;
|
|
#if IS_ENABLED(CONFIG_KVM)
|
|
return instruction_pointer(regs) == (unsigned long) &sie_exit;
|
|
#else
|
|
return false;
|
|
#endif
|
|
}
|
|
|
|
static unsigned long guest_is_user_mode(struct pt_regs *regs)
|
|
{
|
|
return sie_block(regs)->gpsw.mask & PSW_MASK_PSTATE;
|
|
}
|
|
|
|
static unsigned long instruction_pointer_guest(struct pt_regs *regs)
|
|
{
|
|
return sie_block(regs)->gpsw.addr;
|
|
}
|
|
|
|
unsigned long perf_arch_instruction_pointer(struct pt_regs *regs)
|
|
{
|
|
return is_in_guest(regs) ? instruction_pointer_guest(regs)
|
|
: instruction_pointer(regs);
|
|
}
|
|
|
|
static unsigned long perf_misc_guest_flags(struct pt_regs *regs)
|
|
{
|
|
return guest_is_user_mode(regs) ? PERF_RECORD_MISC_GUEST_USER
|
|
: PERF_RECORD_MISC_GUEST_KERNEL;
|
|
}
|
|
|
|
static unsigned long perf_misc_flags_sf(struct pt_regs *regs)
|
|
{
|
|
struct perf_sf_sde_regs *sde_regs;
|
|
unsigned long flags;
|
|
|
|
sde_regs = (struct perf_sf_sde_regs *) ®s->int_parm_long;
|
|
if (sde_regs->in_guest)
|
|
flags = user_mode(regs) ? PERF_RECORD_MISC_GUEST_USER
|
|
: PERF_RECORD_MISC_GUEST_KERNEL;
|
|
else
|
|
flags = user_mode(regs) ? PERF_RECORD_MISC_USER
|
|
: PERF_RECORD_MISC_KERNEL;
|
|
return flags;
|
|
}
|
|
|
|
unsigned long perf_arch_misc_flags(struct pt_regs *regs)
|
|
{
|
|
/* Check if the cpum_sf PMU has created the pt_regs structure.
|
|
* In this case, perf misc flags can be easily extracted. Otherwise,
|
|
* do regular checks on the pt_regs content.
|
|
*/
|
|
if (regs->int_code == 0x1407 && regs->int_parm == CPU_MF_INT_SF_PRA)
|
|
if (!regs->gprs[15])
|
|
return perf_misc_flags_sf(regs);
|
|
|
|
if (is_in_guest(regs))
|
|
return perf_misc_guest_flags(regs);
|
|
|
|
return user_mode(regs) ? PERF_RECORD_MISC_USER
|
|
: PERF_RECORD_MISC_KERNEL;
|
|
}
|
|
|
|
static void print_debug_cf(void)
|
|
{
|
|
struct cpumf_ctr_info cf_info;
|
|
int cpu = smp_processor_id();
|
|
|
|
memset(&cf_info, 0, sizeof(cf_info));
|
|
if (!qctri(&cf_info))
|
|
pr_info("CPU[%i] CPUM_CF: ver=%u.%u A=%04x E=%04x C=%04x\n",
|
|
cpu, cf_info.cfvn, cf_info.csvn,
|
|
cf_info.auth_ctl, cf_info.enable_ctl, cf_info.act_ctl);
|
|
}
|
|
|
|
static void print_debug_sf(void)
|
|
{
|
|
struct hws_qsi_info_block si;
|
|
int cpu = smp_processor_id();
|
|
|
|
memset(&si, 0, sizeof(si));
|
|
if (qsi(&si))
|
|
return;
|
|
|
|
pr_info("CPU[%i] CPUM_SF: basic=%i diag=%i min=%lu max=%lu cpu_speed=%u\n",
|
|
cpu, si.as, si.ad, si.min_sampl_rate, si.max_sampl_rate,
|
|
si.cpu_speed);
|
|
|
|
if (si.as)
|
|
pr_info("CPU[%i] CPUM_SF: Basic-sampling: a=%i e=%i c=%i"
|
|
" bsdes=%i tear=%016lx dear=%016lx\n", cpu,
|
|
si.as, si.es, si.cs, si.bsdes, si.tear, si.dear);
|
|
if (si.ad)
|
|
pr_info("CPU[%i] CPUM_SF: Diagnostic-sampling: a=%i e=%i c=%i"
|
|
" dsdes=%i tear=%016lx dear=%016lx\n", cpu,
|
|
si.ad, si.ed, si.cd, si.dsdes, si.tear, si.dear);
|
|
}
|
|
|
|
void perf_event_print_debug(void)
|
|
{
|
|
unsigned long flags;
|
|
|
|
local_irq_save(flags);
|
|
if (cpum_cf_avail())
|
|
print_debug_cf();
|
|
if (cpum_sf_avail())
|
|
print_debug_sf();
|
|
local_irq_restore(flags);
|
|
}
|
|
|
|
/* Service level infrastructure */
|
|
static void sl_print_counter(struct seq_file *m)
|
|
{
|
|
struct cpumf_ctr_info ci;
|
|
|
|
memset(&ci, 0, sizeof(ci));
|
|
if (qctri(&ci))
|
|
return;
|
|
|
|
seq_printf(m, "CPU-MF: Counter facility: version=%u.%u "
|
|
"authorization=%04x\n", ci.cfvn, ci.csvn, ci.auth_ctl);
|
|
}
|
|
|
|
static void sl_print_sampling(struct seq_file *m)
|
|
{
|
|
struct hws_qsi_info_block si;
|
|
|
|
memset(&si, 0, sizeof(si));
|
|
if (qsi(&si))
|
|
return;
|
|
|
|
if (!si.as && !si.ad)
|
|
return;
|
|
|
|
seq_printf(m, "CPU-MF: Sampling facility: min_rate=%lu max_rate=%lu"
|
|
" cpu_speed=%u\n", si.min_sampl_rate, si.max_sampl_rate,
|
|
si.cpu_speed);
|
|
if (si.as)
|
|
seq_printf(m, "CPU-MF: Sampling facility: mode=basic"
|
|
" sample_size=%u\n", si.bsdes);
|
|
if (si.ad)
|
|
seq_printf(m, "CPU-MF: Sampling facility: mode=diagnostic"
|
|
" sample_size=%u\n", si.dsdes);
|
|
}
|
|
|
|
static void service_level_perf_print(struct seq_file *m,
|
|
struct service_level *sl)
|
|
{
|
|
if (cpum_cf_avail())
|
|
sl_print_counter(m);
|
|
if (cpum_sf_avail())
|
|
sl_print_sampling(m);
|
|
}
|
|
|
|
static struct service_level service_level_perf = {
|
|
.seq_print = service_level_perf_print,
|
|
};
|
|
|
|
static int __init service_level_perf_register(void)
|
|
{
|
|
return register_service_level(&service_level_perf);
|
|
}
|
|
arch_initcall(service_level_perf_register);
|
|
|
|
void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
|
|
struct pt_regs *regs)
|
|
{
|
|
struct unwind_state state;
|
|
unsigned long addr;
|
|
|
|
unwind_for_each_frame(&state, current, regs, 0) {
|
|
addr = unwind_get_return_address(&state);
|
|
if (!addr || perf_callchain_store(entry, addr))
|
|
return;
|
|
}
|
|
}
|
|
|
|
void perf_callchain_user(struct perf_callchain_entry_ctx *entry,
|
|
struct pt_regs *regs)
|
|
{
|
|
arch_stack_walk_user_common(NULL, NULL, entry, regs, true);
|
|
}
|
|
|
|
/* Perf definitions for PMU event attributes in sysfs */
|
|
ssize_t cpumf_events_sysfs_show(struct device *dev,
|
|
struct device_attribute *attr, char *page)
|
|
{
|
|
struct perf_pmu_events_attr *pmu_attr;
|
|
|
|
pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
|
|
return sysfs_emit(page, "event=0x%04llx\n", pmu_attr->id);
|
|
}
|