arch/powerpc/perf/core-fsl-emb.c
Source file repositories/reference/linux-study-clean/arch/powerpc/perf/core-fsl-emb.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/perf/core-fsl-emb.c- Extension
.c- Size
- 14775 bytes
- Lines
- 698
- 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.
- 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/perf_event.hlinux/percpu.hlinux/hardirq.hasm/reg_fsl_emb.hasm/pmc.hasm/machdep.hasm/firmware.hasm/ptrace.h
Detected Declarations
struct cpu_hw_eventsfunction counterfunction write_pmcfunction write_pmlcafunction write_pmlcbfunction fsl_emb_pmu_readfunction fsl_emb_pmu_disablefunction fsl_emb_pmu_enablefunction collect_eventsfunction fsl_emb_pmu_addfunction fsl_emb_pmu_delfunction fsl_emb_pmu_startfunction fsl_emb_pmu_stopfunction hw_perf_event_destroyfunction hw_perf_cache_eventfunction fsl_emb_pmu_event_initfunction record_and_restartfunction perf_event_interruptfunction fsl_emb_pmu_prepare_cpufunction register_fsl_emb_pmu
Annotated Snippet
struct cpu_hw_events {
int n_events;
int disabled;
u8 pmcs_enabled;
struct perf_event *event[MAX_HWEVENTS];
};
static DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events);
static struct fsl_emb_pmu *ppmu;
/* Number of perf_events counting hardware events */
static atomic_t num_events;
/* Used to avoid races in calling reserve/release_pmc_hardware */
static DEFINE_MUTEX(pmc_reserve_mutex);
static void perf_event_interrupt(struct pt_regs *regs);
/*
* Read one performance monitor counter (PMC).
*/
static unsigned long read_pmc(int idx)
{
unsigned long val;
switch (idx) {
case 0:
val = mfpmr(PMRN_PMC0);
break;
case 1:
val = mfpmr(PMRN_PMC1);
break;
case 2:
val = mfpmr(PMRN_PMC2);
break;
case 3:
val = mfpmr(PMRN_PMC3);
break;
case 4:
val = mfpmr(PMRN_PMC4);
break;
case 5:
val = mfpmr(PMRN_PMC5);
break;
default:
printk(KERN_ERR "oops trying to read PMC%d\n", idx);
val = 0;
}
return val;
}
/*
* Write one PMC.
*/
static void write_pmc(int idx, unsigned long val)
{
switch (idx) {
case 0:
mtpmr(PMRN_PMC0, val);
break;
case 1:
mtpmr(PMRN_PMC1, val);
break;
case 2:
mtpmr(PMRN_PMC2, val);
break;
case 3:
mtpmr(PMRN_PMC3, val);
break;
case 4:
mtpmr(PMRN_PMC4, val);
break;
case 5:
mtpmr(PMRN_PMC5, val);
break;
default:
printk(KERN_ERR "oops trying to write PMC%d\n", idx);
}
isync();
}
/*
* Write one local control A register
*/
static void write_pmlca(int idx, unsigned long val)
{
switch (idx) {
case 0:
mtpmr(PMRN_PMLCA0, val);
break;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/sched.h`, `linux/perf_event.h`, `linux/percpu.h`, `linux/hardirq.h`, `asm/reg_fsl_emb.h`, `asm/pmc.h`, `asm/machdep.h`.
- Detected declarations: `struct cpu_hw_events`, `function counter`, `function write_pmc`, `function write_pmlca`, `function write_pmlcb`, `function fsl_emb_pmu_read`, `function fsl_emb_pmu_disable`, `function fsl_emb_pmu_enable`, `function collect_events`, `function fsl_emb_pmu_add`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.