arch/arc/kernel/perf_event.c
Source file repositories/reference/linux-study-clean/arch/arc/kernel/perf_event.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arc/kernel/perf_event.c- Extension
.c- Size
- 22433 bytes
- Lines
- 849
- Domain
- Architecture Layer
- Bucket
- arch/arc
- 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 IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/interrupt.hlinux/module.hlinux/of.hlinux/perf_event.hlinux/platform_device.hasm/arcregs.hasm/stacktrace.h
Detected Declarations
struct arc_pmu_raw_event_entrystruct arc_pmustruct arc_pmu_cpustruct arc_callchain_traceenum arc_pmu_attr_groupsfunction callchain_tracefunction perf_callchain_kernelfunction perf_callchain_userfunction arc_pmu_read_counterfunction arc_perf_event_updatefunction arc_pmu_readfunction arc_pmu_cache_eventfunction arc_pmu_event_initfunction arc_pmu_enablefunction arc_pmu_disablefunction arc_pmu_event_set_periodfunction arc_pmu_startfunction arc_pmu_stopfunction arc_pmu_delfunction arc_pmu_addfunction arc_pmu_intrfunction arc_pmu_intrfunction arc_cpu_pmu_irq_initfunction arc_pmu_events_sysfs_showfunction arc_pmu_add_raw_event_attrfunction arc_pmu_raw_allocfunction event_in_hw_event_mapfunction arc_pmu_map_hw_eventfunction arc_pmu_device_probe
Annotated Snippet
struct arc_pmu_raw_event_entry {
char name[ARCPMU_EVENT_NAME_LEN];
};
struct arc_pmu {
struct pmu pmu;
unsigned int irq;
int n_counters;
int n_events;
u64 max_period;
int ev_hw_idx[PERF_COUNT_ARC_HW_MAX];
struct arc_pmu_raw_event_entry *raw_entry;
struct attribute **attrs;
struct perf_pmu_events_attr *attr;
const struct attribute_group *attr_groups[ARCPMU_NR_ATTR_GR + 1];
};
struct arc_pmu_cpu {
/*
* A 1 bit for an index indicates that the counter is being used for
* an event. A 0 means that the counter can be used.
*/
unsigned long used_mask[BITS_TO_LONGS(ARC_PERF_MAX_COUNTERS)];
/*
* The events that are active on the PMU for the given index.
*/
struct perf_event *act_counter[ARC_PERF_MAX_COUNTERS];
};
struct arc_callchain_trace {
int depth;
void *perf_stuff;
};
static int callchain_trace(unsigned int addr, void *data)
{
struct arc_callchain_trace *ctrl = data;
struct perf_callchain_entry_ctx *entry = ctrl->perf_stuff;
perf_callchain_store(entry, addr);
if (ctrl->depth++ < 3)
return 0;
return -1;
}
void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
struct pt_regs *regs)
{
struct arc_callchain_trace ctrl = {
.depth = 0,
.perf_stuff = entry,
};
arc_unwind_core(NULL, regs, callchain_trace, &ctrl);
}
void perf_callchain_user(struct perf_callchain_entry_ctx *entry,
struct pt_regs *regs)
{
/*
* User stack can't be unwound trivially with kernel dwarf unwinder
* So for now just record the user PC
*/
perf_callchain_store(entry, instruction_pointer(regs));
}
static struct arc_pmu *arc_pmu;
static DEFINE_PER_CPU(struct arc_pmu_cpu, arc_pmu_cpu);
/* read counter #idx; note that counter# != event# on ARC! */
static u64 arc_pmu_read_counter(int idx)
{
u32 tmp;
u64 result;
/*
* ARC supports making 'snapshots' of the counters, so we don't
* need to care about counters wrapping to 0 underneath our feet
*/
write_aux_reg(ARC_REG_PCT_INDEX, idx);
tmp = read_aux_reg(ARC_REG_PCT_CONTROL);
write_aux_reg(ARC_REG_PCT_CONTROL, tmp | ARC_REG_PCT_CONTROL_SN);
result = (u64) (read_aux_reg(ARC_REG_PCT_SNAPH)) << 32;
result |= read_aux_reg(ARC_REG_PCT_SNAPL);
return result;
Annotation
- Immediate include surface: `linux/errno.h`, `linux/interrupt.h`, `linux/module.h`, `linux/of.h`, `linux/perf_event.h`, `linux/platform_device.h`, `asm/arcregs.h`, `asm/stacktrace.h`.
- Detected declarations: `struct arc_pmu_raw_event_entry`, `struct arc_pmu`, `struct arc_pmu_cpu`, `struct arc_callchain_trace`, `enum arc_pmu_attr_groups`, `function callchain_trace`, `function perf_callchain_kernel`, `function perf_callchain_user`, `function arc_pmu_read_counter`, `function arc_perf_event_update`.
- Atlas domain: Architecture Layer / arch/arc.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.