cregit-Linux how code gets into the kernel

Release 4.14 arch/s390/kernel/perf_event.c

Directory: arch/s390/kernel
/*
 * Performance event support for s390x
 *
 *  Copyright IBM Corp. 2012, 2013
 *  Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License (version 2 only)
 * as published by the Free Software Foundation.
 */

#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/sysfs.h>
#include <asm/irq.h>
#include <asm/cpu_mf.h>
#include <asm/lowcore.h>
#include <asm/processor.h>
#include <asm/sysinfo.h>


const char *perf_pmu_name(void) { if (cpum_cf_avail() || cpum_sf_avail()) return "CPU-Measurement Facilities (CPU-MF)"; return "pmu"; }

Contributors

PersonTokensPropCommitsCommitProp
Hendrik Brueckner23100.00%2100.00%
Total23100.00%2100.00%

EXPORT_SYMBOL(perf_pmu_name);
int perf_num_counters(void) { int num = 0; if (cpum_cf_avail()) num += PERF_CPUM_CF_MAX_CTR; if (cpum_sf_avail()) num += PERF_CPUM_SF_MAX_CTR; return num; }

Contributors

PersonTokensPropCommitsCommitProp
Hendrik Brueckner33100.00%2100.00%
Total33100.00%2100.00%

EXPORT_SYMBOL(perf_num_counters);
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->empty1[0]; }

Contributors

PersonTokensPropCommitsCommitProp
Heinz Graalfs51100.00%1100.00%
Total51100.00%1100.00%


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 }

Contributors

PersonTokensPropCommitsCommitProp
Heinz Graalfs3063.83%133.33%
Heiko Carstens1736.17%266.67%
Total47100.00%3100.00%


static unsigned long guest_is_user_mode(struct pt_regs *regs) { return sie_block(regs)->gpsw.mask & PSW_MASK_PSTATE; }

Contributors

PersonTokensPropCommitsCommitProp
Heinz Graalfs24100.00%1100.00%
Total24100.00%1100.00%


static unsigned long instruction_pointer_guest(struct pt_regs *regs) { return sie_block(regs)->gpsw.addr; }

Contributors

PersonTokensPropCommitsCommitProp
Heinz Graalfs22100.00%1100.00%
Total22100.00%1100.00%


unsigned long perf_instruction_pointer(struct pt_regs *regs) { return is_in_guest(regs) ? instruction_pointer_guest(regs) : instruction_pointer(regs); }

Contributors

PersonTokensPropCommitsCommitProp
Heinz Graalfs27100.00%1100.00%
Total27100.00%1100.00%


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; }

Contributors

PersonTokensPropCommitsCommitProp
Heinz Graalfs22100.00%1100.00%
Total22100.00%1100.00%


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 *) &regs->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; }

Contributors

PersonTokensPropCommitsCommitProp
Hendrik Brueckner65100.00%1100.00%
Total65100.00%1100.00%


unsigned long perf_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; }

Contributors

PersonTokensPropCommitsCommitProp
Heinz Graalfs3452.31%150.00%
Hendrik Brueckner3147.69%150.00%
Total65100.00%2100.00%


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); }

Contributors

PersonTokensPropCommitsCommitProp
Hendrik Brueckner6698.51%266.67%
Heiko Carstens11.49%133.33%
Total67100.00%3100.00%


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); }

Contributors

PersonTokensPropCommitsCommitProp
Hendrik Brueckner143100.00%3100.00%
Total143100.00%3100.00%


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); }

Contributors

PersonTokensPropCommitsCommitProp
Hendrik Brueckner37100.00%2100.00%
Total37100.00%2100.00%

/* 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); }

Contributors

PersonTokensPropCommitsCommitProp
Hendrik Brueckner57100.00%1100.00%
Total57100.00%1100.00%


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); }

Contributors

PersonTokensPropCommitsCommitProp
Hendrik Brueckner106100.00%1100.00%
Total106100.00%1100.00%


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); }

Contributors

PersonTokensPropCommitsCommitProp
Hendrik Brueckner36100.00%1100.00%
Total36100.00%1100.00%

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); }

Contributors

PersonTokensPropCommitsCommitProp
Hendrik Brueckner16100.00%1100.00%
Total16100.00%1100.00%

arch_initcall(service_level_perf_register);
static int __perf_callchain_kernel(void *data, unsigned long address, int reliable) { struct perf_callchain_entry_ctx *entry = data; perf_callchain_store(entry, address); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Hendrik Brueckner2058.82%125.00%
Heiko Carstens1338.24%250.00%
Arnaldo Carvalho de Melo12.94%125.00%
Total34100.00%4100.00%


void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs) { if (user_mode(regs)) return; dump_trace(__perf_callchain_kernel, entry, NULL, regs->gprs[15]); }

Contributors

PersonTokensPropCommitsCommitProp
Hendrik Brueckner3076.92%125.00%
Heiko Carstens820.51%250.00%
Arnaldo Carvalho de Melo12.56%125.00%
Total39100.00%4100.00%

/* 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 sprintf(page, "event=0x%04llx\n", pmu_attr->id); }

Contributors

PersonTokensPropCommitsCommitProp
Hendrik Brueckner4797.92%150.00%
Thomas Richter12.08%150.00%
Total48100.00%2100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Hendrik Brueckner78675.43%741.18%
Heinz Graalfs21320.44%15.88%
Heiko Carstens393.74%635.29%
Arnaldo Carvalho de Melo20.19%15.88%
Thomas Richter10.10%15.88%
Adam Buchbinder10.10%15.88%
Total1042100.00%17100.00%
Directory: arch/s390/kernel
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.