arch/powerpc/perf/core-book3s.c
Source file repositories/reference/linux-study-clean/arch/powerpc/perf/core-book3s.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/perf/core-book3s.c- Extension
.c- Size
- 68985 bytes
- Lines
- 2642
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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
linux/kernel.hlinux/sched.hlinux/sched/clock.hlinux/perf_event.hlinux/percpu.hlinux/hardirq.hlinux/sysfs.hlinux/uaccess.hasm/reg.hasm/pmc.hasm/machdep.hasm/firmware.hasm/ptrace.hasm/text-patching.hasm/hw_irq.hasm/interrupt.hinternal.h
Detected Declarations
struct cpu_hw_eventsfunction registersfunction perf_get_data_addrfunction perf_read_regsfunction siar_validfunction is_ebb_eventfunction ebb_event_checkfunction ebb_event_addfunction power_pmu_bhrb_enablefunction get_pmcs_ext_regsfunction regs_use_siarfunction perf_ip_adjustfunction perf_get_data_addrfunction regs_sihvfunction regs_siprfunction perf_flags_from_msrfunction perf_get_misc_flagsfunction perf_read_regsfunction siar_validfunction power_pmu_bhrb_resetfunction power_pmu_bhrb_enablefunction power_pmu_bhrb_disablefunction power_pmu_sched_taskfunction power_pmu_bhrb_tofunction power_pmu_bhrb_readfunction targetfunction is_ebb_eventfunction ebb_event_checkfunction ebb_event_addfunction ebb_switch_outfunction ebb_switch_infunction pmao_restore_workaroundfunction possiblefunction counterfunction write_pmcfunction any_pmc_overflownfunction perf_event_print_debugfunction power_check_constraintsfunction check_excludesfunction check_and_compute_deltafunction power_pmu_readfunction is_limited_pmcfunction freeze_limited_countersfunction thaw_limited_countersfunction delayfunction power_pmu_disablefunction power_pmu_enablefunction collect_events
Annotated Snippet
struct cpu_hw_events {
int n_events;
int n_percpu;
int disabled;
int n_added;
int n_limited;
u8 pmcs_enabled;
struct perf_event *event[MAX_HWEVENTS];
u64 events[MAX_HWEVENTS];
unsigned int flags[MAX_HWEVENTS];
struct mmcr_regs mmcr;
struct perf_event *limited_counter[MAX_LIMITED_HWCOUNTERS];
u8 limited_hwidx[MAX_LIMITED_HWCOUNTERS];
u64 alternatives[MAX_HWEVENTS][MAX_EVENT_ALTERNATIVES];
unsigned long amasks[MAX_HWEVENTS][MAX_EVENT_ALTERNATIVES];
unsigned long avalues[MAX_HWEVENTS][MAX_EVENT_ALTERNATIVES];
unsigned int txn_flags;
int n_txn_start;
/* BHRB bits */
u64 bhrb_filter; /* BHRB HW branch filter */
unsigned int bhrb_users;
void *bhrb_context;
struct perf_branch_stack bhrb_stack;
struct perf_branch_entry bhrb_entries[BHRB_MAX_ENTRIES];
u64 ic_init;
/* Store the PMC values */
unsigned long pmcs[MAX_HWEVENTS];
};
static DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events);
static struct power_pmu *ppmu;
/*
* Normally, to ignore kernel events we set the FCS (freeze counters
* in supervisor mode) bit in MMCR0, but if the kernel runs with the
* hypervisor bit set in the MSR, or if we are running on a processor
* where the hypervisor bit is forced to 1 (as on Apple G5 processors),
* then we need to use the FCHV bit to ignore kernel events.
*/
static unsigned int freeze_events_kernel = MMCR0_FCS;
/*
* 32-bit doesn't have MMCRA but does have an MMCR2,
* and a few other names are different.
* Also 32-bit doesn't have MMCR3, SIER2 and SIER3.
* Define them as zero knowing that any code path accessing
* these registers (via mtspr/mfspr) are done under ppmu flag
* check for PPMU_ARCH_31 and we will not enter that code path
* for 32-bit.
*/
#ifdef CONFIG_PPC32
#define MMCR0_FCHV 0
#define MMCR0_PMCjCE MMCR0_PMCnCE
#define MMCR0_FC56 0
#define MMCR0_PMAO 0
#define MMCR0_EBE 0
#define MMCR0_BHRBA 0
#define MMCR0_PMCC 0
#define MMCR0_PMCC_U6 0
#define SPRN_MMCRA SPRN_MMCR2
#define SPRN_MMCR3 0
#define SPRN_SIER2 0
#define SPRN_SIER3 0
#define MMCRA_SAMPLE_ENABLE 0
#define MMCRA_BHRB_DISABLE 0
#define MMCR0_PMCCEXT 0
static inline unsigned long perf_ip_adjust(struct pt_regs *regs)
{
return 0;
}
static inline void perf_get_data_addr(struct perf_event *event, struct pt_regs *regs, u64 *addrp) { }
static inline u32 perf_get_misc_flags(struct pt_regs *regs)
{
return 0;
}
static inline void perf_read_regs(struct pt_regs *regs)
{
regs->result = 0;
}
static inline int siar_valid(struct pt_regs *regs)
{
return 1;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/sched.h`, `linux/sched/clock.h`, `linux/perf_event.h`, `linux/percpu.h`, `linux/hardirq.h`, `linux/sysfs.h`, `linux/uaccess.h`.
- Detected declarations: `struct cpu_hw_events`, `function registers`, `function perf_get_data_addr`, `function perf_read_regs`, `function siar_valid`, `function is_ebb_event`, `function ebb_event_check`, `function ebb_event_add`, `function power_pmu_bhrb_enable`, `function get_pmcs_ext_regs`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.