arch/x86/events/zhaoxin/core.c
Source file repositories/reference/linux-study-clean/arch/x86/events/zhaoxin/core.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/events/zhaoxin/core.c- Extension
.c- Size
- 14220 bytes
- Lines
- 621
- Domain
- Architecture Layer
- Bucket
- arch/x86
- 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/stddef.hlinux/types.hlinux/init.hlinux/slab.hlinux/export.hlinux/nmi.hasm/cpufeature.hasm/cpuid/api.hasm/hardirq.hasm/apic.hasm/msr.h../perf_event.h
Detected Declarations
function zhaoxin_pmu_disable_allfunction zhaoxin_pmu_enable_allfunction zhaoxin_pmu_get_statusfunction zhaoxin_pmu_ack_statusfunction zxc_pmu_ack_statusfunction zhaoxin_pmu_disable_fixedfunction zhaoxin_pmu_disable_eventfunction zhaoxin_pmu_enable_fixedfunction zhaoxin_pmu_enable_eventfunction zhaoxin_pmu_handle_irqfunction for_each_set_bitfunction zhaoxin_pmu_event_mapfunction zhaoxin_get_event_constraintsfunction zhaoxin_event_sysfs_showfunction zhaoxin_arch_events_quirkfunction zhaoxin_pmu_init
Annotated Snippet
for_each_event_constraint(c, x86_pmu.event_constraints) {
if ((event->hw.config & c->cmask) == c->code)
return c;
}
}
return &unconstrained;
}
PMU_FORMAT_ATTR(event, "config:0-7");
PMU_FORMAT_ATTR(umask, "config:8-15");
PMU_FORMAT_ATTR(edge, "config:18");
PMU_FORMAT_ATTR(inv, "config:23");
PMU_FORMAT_ATTR(cmask, "config:24-31");
static struct attribute *zx_arch_formats_attr[] = {
&format_attr_event.attr,
&format_attr_umask.attr,
&format_attr_edge.attr,
&format_attr_inv.attr,
&format_attr_cmask.attr,
NULL,
};
static ssize_t zhaoxin_event_sysfs_show(char *page, u64 config)
{
u64 event = (config & ARCH_PERFMON_EVENTSEL_EVENT);
return x86_event_sysfs_show(page, config, event);
}
static const struct x86_pmu zhaoxin_pmu __initconst = {
.name = "zhaoxin",
.handle_irq = zhaoxin_pmu_handle_irq,
.disable_all = zhaoxin_pmu_disable_all,
.enable_all = zhaoxin_pmu_enable_all,
.enable = zhaoxin_pmu_enable_event,
.disable = zhaoxin_pmu_disable_event,
.hw_config = x86_pmu_hw_config,
.schedule_events = x86_schedule_events,
.eventsel = MSR_ARCH_PERFMON_EVENTSEL0,
.perfctr = MSR_ARCH_PERFMON_PERFCTR0,
.event_map = zhaoxin_pmu_event_map,
.max_events = ARRAY_SIZE(zx_pmon_event_map),
.apic = 1,
/*
* For zxd/zxe, read/write operation for PMCx MSR is 48 bits.
*/
.max_period = (1ULL << 47) - 1,
.get_event_constraints = zhaoxin_get_event_constraints,
.format_attrs = zx_arch_formats_attr,
.events_sysfs_show = zhaoxin_event_sysfs_show,
};
static const struct { int id; char *name; } zx_arch_events_map[] __initconst = {
{ PERF_COUNT_HW_CPU_CYCLES, "cpu cycles" },
{ PERF_COUNT_HW_INSTRUCTIONS, "instructions" },
{ PERF_COUNT_HW_BUS_CYCLES, "bus cycles" },
{ PERF_COUNT_HW_CACHE_REFERENCES, "cache references" },
{ PERF_COUNT_HW_CACHE_MISSES, "cache misses" },
{ PERF_COUNT_HW_BRANCH_INSTRUCTIONS, "branch instructions" },
{ PERF_COUNT_HW_BRANCH_MISSES, "branch misses" },
};
static __init void zhaoxin_arch_events_quirk(void)
{
int bit;
/* disable event that reported as not present by cpuid */
for_each_set_bit(bit, x86_pmu.events_mask, ARRAY_SIZE(zx_arch_events_map)) {
zx_pmon_event_map[zx_arch_events_map[bit].id] = 0;
pr_warn("CPUID marked event: \'%s\' unavailable\n",
zx_arch_events_map[bit].name);
}
}
__init int zhaoxin_pmu_init(void)
{
union cpuid10_edx edx;
union cpuid10_eax eax;
union cpuid10_ebx ebx;
struct event_constraint *c;
unsigned int unused;
int version;
pr_info("Welcome to zhaoxin pmu!\n");
/*
* Check whether the Architectural PerfMon supports
Annotation
- Immediate include surface: `linux/stddef.h`, `linux/types.h`, `linux/init.h`, `linux/slab.h`, `linux/export.h`, `linux/nmi.h`, `asm/cpufeature.h`, `asm/cpuid/api.h`.
- Detected declarations: `function zhaoxin_pmu_disable_all`, `function zhaoxin_pmu_enable_all`, `function zhaoxin_pmu_get_status`, `function zhaoxin_pmu_ack_status`, `function zxc_pmu_ack_status`, `function zhaoxin_pmu_disable_fixed`, `function zhaoxin_pmu_disable_event`, `function zhaoxin_pmu_enable_fixed`, `function zhaoxin_pmu_enable_event`, `function zhaoxin_pmu_handle_irq`.
- Atlas domain: Architecture Layer / arch/x86.
- 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.