arch/s390/kernel/perf_event.c
Source file repositories/reference/linux-study-clean/arch/s390/kernel/perf_event.c
File Facts
- System
- Linux kernel
- Corpus path
arch/s390/kernel/perf_event.c- Extension
.c- Size
- 5801 bytes
- Lines
- 230
- Domain
- Architecture Layer
- Bucket
- arch/s390
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/perf_event.hlinux/kvm_host.hlinux/percpu.hlinux/seq_file.hlinux/spinlock.hlinux/uaccess.hlinux/sysfs.hasm/stacktrace.hasm/irq.hasm/cpu_mf.hasm/lowcore.hasm/processor.hasm/sysinfo.hasm/unwind.h
Detected Declarations
function Authorfunction is_in_guestfunction guest_is_user_modefunction instruction_pointer_guestfunction perf_arch_instruction_pointerfunction perf_misc_guest_flagsfunction perf_misc_flags_sffunction perf_arch_misc_flagsfunction print_debug_cffunction print_debug_sffunction perf_event_print_debugfunction sl_print_counterfunction sl_print_samplingfunction service_level_perf_printfunction service_level_perf_registerfunction perf_callchain_kernelfunction unwind_for_each_framefunction perf_callchain_userfunction cpumf_events_sysfs_show
Annotated Snippet
// 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 pr_fmt(fmt) "perf: " fmt
#include <linux/kernel.h>
#include <linux/perf_event.h>
#include <linux/kvm_host.h>
#include <linux/percpu.h>
#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/uaccess.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)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/perf_event.h`, `linux/kvm_host.h`, `linux/percpu.h`, `linux/seq_file.h`, `linux/spinlock.h`, `linux/uaccess.h`, `linux/sysfs.h`.
- Detected declarations: `function Author`, `function is_in_guest`, `function guest_is_user_mode`, `function instruction_pointer_guest`, `function perf_arch_instruction_pointer`, `function perf_misc_guest_flags`, `function perf_misc_flags_sf`, `function perf_arch_misc_flags`, `function print_debug_cf`, `function print_debug_sf`.
- Atlas domain: Architecture Layer / arch/s390.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.