^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Performance event support for s390x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright IBM Corp. 2012, 2013
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define KMSG_COMPONENT "perf"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/perf_event.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/kvm_host.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/percpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/sysfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <asm/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <asm/cpu_mf.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <asm/lowcore.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <asm/processor.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <asm/sysinfo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <asm/unwind.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) const char *perf_pmu_name(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) if (cpum_cf_avail() || cpum_sf_avail())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) return "CPU-Measurement Facilities (CPU-MF)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) return "pmu";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) EXPORT_SYMBOL(perf_pmu_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) int perf_num_counters(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int num = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) if (cpum_cf_avail())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) num += PERF_CPUM_CF_MAX_CTR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) if (cpum_sf_avail())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) num += PERF_CPUM_SF_MAX_CTR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) return num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) EXPORT_SYMBOL(perf_num_counters);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static struct kvm_s390_sie_block *sie_block(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct stack_frame *stack = (struct stack_frame *) regs->gprs[15];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) if (!stack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) return (struct kvm_s390_sie_block *) stack->empty1[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static bool is_in_guest(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) if (user_mode(regs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #if IS_ENABLED(CONFIG_KVM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) return instruction_pointer(regs) == (unsigned long) &sie_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) static unsigned long guest_is_user_mode(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) return sie_block(regs)->gpsw.mask & PSW_MASK_PSTATE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) static unsigned long instruction_pointer_guest(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) return sie_block(regs)->gpsw.addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) unsigned long perf_instruction_pointer(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) return is_in_guest(regs) ? instruction_pointer_guest(regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) : instruction_pointer(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) static unsigned long perf_misc_guest_flags(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) return guest_is_user_mode(regs) ? PERF_RECORD_MISC_GUEST_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) : PERF_RECORD_MISC_GUEST_KERNEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) static unsigned long perf_misc_flags_sf(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) struct perf_sf_sde_regs *sde_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) sde_regs = (struct perf_sf_sde_regs *) ®s->int_parm_long;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) if (sde_regs->in_guest)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) flags = user_mode(regs) ? PERF_RECORD_MISC_GUEST_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) : PERF_RECORD_MISC_GUEST_KERNEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) flags = user_mode(regs) ? PERF_RECORD_MISC_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) : PERF_RECORD_MISC_KERNEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) return flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) unsigned long perf_misc_flags(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) /* Check if the cpum_sf PMU has created the pt_regs structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * In this case, perf misc flags can be easily extracted. Otherwise,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * do regular checks on the pt_regs content.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) if (regs->int_code == 0x1407 && regs->int_parm == CPU_MF_INT_SF_PRA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) if (!regs->gprs[15])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) return perf_misc_flags_sf(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) if (is_in_guest(regs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) return perf_misc_guest_flags(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) return user_mode(regs) ? PERF_RECORD_MISC_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) : PERF_RECORD_MISC_KERNEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static void print_debug_cf(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct cpumf_ctr_info cf_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) int cpu = smp_processor_id();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) memset(&cf_info, 0, sizeof(cf_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) if (!qctri(&cf_info))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) pr_info("CPU[%i] CPUM_CF: ver=%u.%u A=%04x E=%04x C=%04x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) cpu, cf_info.cfvn, cf_info.csvn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) cf_info.auth_ctl, cf_info.enable_ctl, cf_info.act_ctl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) static void print_debug_sf(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) struct hws_qsi_info_block si;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) int cpu = smp_processor_id();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) memset(&si, 0, sizeof(si));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) if (qsi(&si))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) pr_info("CPU[%i] CPUM_SF: basic=%i diag=%i min=%lu max=%lu cpu_speed=%u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) cpu, si.as, si.ad, si.min_sampl_rate, si.max_sampl_rate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) si.cpu_speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (si.as)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) pr_info("CPU[%i] CPUM_SF: Basic-sampling: a=%i e=%i c=%i"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) " bsdes=%i tear=%016lx dear=%016lx\n", cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) si.as, si.es, si.cs, si.bsdes, si.tear, si.dear);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) if (si.ad)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) pr_info("CPU[%i] CPUM_SF: Diagnostic-sampling: a=%i e=%i c=%i"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) " dsdes=%i tear=%016lx dear=%016lx\n", cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) si.ad, si.ed, si.cd, si.dsdes, si.tear, si.dear);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) void perf_event_print_debug(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) local_irq_save(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) if (cpum_cf_avail())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) print_debug_cf();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) if (cpum_sf_avail())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) print_debug_sf();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) local_irq_restore(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /* Service level infrastructure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) static void sl_print_counter(struct seq_file *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) struct cpumf_ctr_info ci;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) memset(&ci, 0, sizeof(ci));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) if (qctri(&ci))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) seq_printf(m, "CPU-MF: Counter facility: version=%u.%u "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) "authorization=%04x\n", ci.cfvn, ci.csvn, ci.auth_ctl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) static void sl_print_sampling(struct seq_file *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) struct hws_qsi_info_block si;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) memset(&si, 0, sizeof(si));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) if (qsi(&si))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) if (!si.as && !si.ad)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) seq_printf(m, "CPU-MF: Sampling facility: min_rate=%lu max_rate=%lu"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) " cpu_speed=%u\n", si.min_sampl_rate, si.max_sampl_rate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) si.cpu_speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) if (si.as)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) seq_printf(m, "CPU-MF: Sampling facility: mode=basic"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) " sample_size=%u\n", si.bsdes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if (si.ad)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) seq_printf(m, "CPU-MF: Sampling facility: mode=diagnostic"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) " sample_size=%u\n", si.dsdes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) static void service_level_perf_print(struct seq_file *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) struct service_level *sl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (cpum_cf_avail())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) sl_print_counter(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) if (cpum_sf_avail())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) sl_print_sampling(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) static struct service_level service_level_perf = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) .seq_print = service_level_perf_print,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) static int __init service_level_perf_register(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return register_service_level(&service_level_perf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) arch_initcall(service_level_perf_register);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) struct unwind_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) unsigned long addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) unwind_for_each_frame(&state, current, regs, 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) addr = unwind_get_return_address(&state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) if (!addr || perf_callchain_store(entry, addr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) /* Perf definitions for PMU event attributes in sysfs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) ssize_t cpumf_events_sysfs_show(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) struct device_attribute *attr, char *page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) struct perf_pmu_events_attr *pmu_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) return sprintf(page, "event=0x%04llx\n", pmu_attr->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }