include/linux/perf_event.h
Source file repositories/reference/linux-study-clean/include/linux/perf_event.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/perf_event.h- Extension
.h- Size
- 62107 bytes
- Lines
- 2140
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
uapi/linux/perf_event.huapi/linux/bpf_perf_event.hasm/perf_event.hasm/local64.hlinux/rhashtable-types.hasm/hw_breakpoint.hlinux/list.hlinux/mutex.hlinux/rculist.hlinux/rcupdate.hlinux/spinlock.hlinux/hrtimer.hlinux/fs.hlinux/pid_namespace.hlinux/workqueue.hlinux/ftrace.hlinux/cpu.hlinux/irq_work.hlinux/static_key.hlinux/jump_label_ratelimit.hlinux/atomic.hlinux/sysfs.hlinux/perf_regs.hlinux/cgroup.hlinux/refcount.hlinux/security.hlinux/static_call.hlinux/lockdep.hasm/local.h
Detected Declarations
struct perf_callchain_entrystruct perf_callchain_entry_ctxstruct perf_raw_fragstruct perf_raw_recordstruct perf_branch_stackstruct task_structstruct hw_perf_event_extrastruct hw_perf_eventstruct perf_eventstruct perf_event_pmu_contextstruct perf_output_handlestruct pmustruct perf_addr_filterstruct perf_addr_filters_headstruct perf_addr_filter_rangestruct filestruct perf_sample_datastruct swevent_hliststruct bpf_progstruct perf_cgroupstruct perf_bufferstruct pmu_event_liststruct perf_eventstruct perf_event_pmu_contextstruct perf_event_groupsstruct perf_time_ctxstruct perf_event_contextstruct perf_ctx_datastruct perf_cpu_pmu_contextstruct perf_cpu_contextstruct perf_output_handlestruct bpf_perf_event_data_kernstruct perf_cgroup_infostruct perf_cgroupstruct perf_sample_datastruct perf_guest_info_callbacksstruct perf_pmu_events_attrstruct perf_pmu_events_ht_attrstruct perf_pmu_events_hybrid_attrstruct perf_pmu_format_hybrid_attrenum perf_pmu_scopeenum perf_addr_filter_action_tenum perf_event_statefunction perf_raw_frag_lastfunction perf_pmu_ctx_is_activefunction pinnedfunction branch_sample_no_flagsfunction branch_sample_no_cycles
Annotated Snippet
struct perf_callchain_entry {
u64 nr;
u64 ip[]; /* /proc/sys/kernel/perf_event_max_stack */
};
struct perf_callchain_entry_ctx {
struct perf_callchain_entry *entry;
u32 max_stack;
u32 nr;
short contexts;
bool contexts_maxed;
};
typedef unsigned long (*perf_copy_f)(void *dst, const void *src,
unsigned long off, unsigned long len);
struct perf_raw_frag {
union {
struct perf_raw_frag *next;
unsigned long pad;
};
perf_copy_f copy;
void *data;
u32 size;
} __packed;
struct perf_raw_record {
struct perf_raw_frag frag;
u32 size;
};
static __always_inline bool perf_raw_frag_last(const struct perf_raw_frag *frag)
{
return frag->pad < sizeof(u64);
}
/*
* branch stack layout:
* nr: number of taken branches stored in entries[]
* hw_idx: The low level index of raw branch records
* for the most recent branch.
* -1ULL means invalid/unknown.
*
* Note that nr can vary from sample to sample
* branches (to, from) are stored from most recent
* to least recent, i.e., entries[0] contains the most
* recent branch.
* The entries[] is an abstraction of raw branch records,
* which may not be stored in age order in HW, e.g. Intel LBR.
* The hw_idx is to expose the low level index of raw
* branch record for the most recent branch aka entries[0].
* The hw_idx index is between -1 (unknown) and max depth,
* which can be retrieved in /sys/devices/cpu/caps/branches.
* For the architectures whose raw branch records are
* already stored in age order, the hw_idx should be 0.
*/
struct perf_branch_stack {
u64 nr;
u64 hw_idx;
struct perf_branch_entry entries[];
};
struct task_struct;
/*
* extra PMU register associated with an event
*/
struct hw_perf_event_extra {
u64 config; /* register value */
unsigned int reg; /* register address or index */
int alloc; /* extra register already allocated */
int idx; /* index in shared_regs->regs[] */
};
/**
* hw_perf_event::flag values
*
* PERF_EVENT_FLAG_ARCH bits are reserved for architecture-specific
* usage.
*/
#define PERF_EVENT_FLAG_ARCH 0x0fffffff
#define PERF_EVENT_FLAG_USER_READ_CNT 0x80000000
static_assert((PERF_EVENT_FLAG_USER_READ_CNT & PERF_EVENT_FLAG_ARCH) == 0);
/**
* struct hw_perf_event - performance event hardware details:
*/
struct hw_perf_event {
#ifdef CONFIG_PERF_EVENTS
Annotation
- Immediate include surface: `uapi/linux/perf_event.h`, `uapi/linux/bpf_perf_event.h`, `asm/perf_event.h`, `asm/local64.h`, `linux/rhashtable-types.h`, `asm/hw_breakpoint.h`, `linux/list.h`, `linux/mutex.h`.
- Detected declarations: `struct perf_callchain_entry`, `struct perf_callchain_entry_ctx`, `struct perf_raw_frag`, `struct perf_raw_record`, `struct perf_branch_stack`, `struct task_struct`, `struct hw_perf_event_extra`, `struct hw_perf_event`, `struct perf_event`, `struct perf_event_pmu_context`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.