arch/arm64/kernel/topology.c
Source file repositories/reference/linux-study-clean/arch/arm64/kernel/topology.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/kernel/topology.c- Extension
.c- Size
- 12598 bytes
- Lines
- 477
- Domain
- Architecture Layer
- Bucket
- arch/arm64
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/arch_topology.hlinux/cacheinfo.hlinux/cpufreq.hlinux/cpu_smt.hlinux/init.hlinux/percpu.hlinux/sched/isolation.hlinux/xarray.hasm/cpu.hasm/cputype.hasm/topology.hacpi/cppc_acpi.h
Detected Declarations
struct amu_cntr_samplefunction update_freq_counters_refsfunction freq_counters_validfunction freq_inv_set_max_ratiofunction amu_scale_freq_tickfunction amu_fie_cpu_supportedfunction arch_cpu_idle_enterfunction arch_freq_get_on_cpufunction for_each_cpu_wrapfunction amu_fie_setupfunction init_amu_fie_callbackfunction cpuhp_topology_onlinefunction init_amu_fiefunction cpu_read_corecntfunction cpu_read_constcntfunction counters_read_on_cpufunction cpc_ffh_supportedfunction cpc_read_ffhfunction cpc_write_ffhmodule init init_amu_fie
Annotated Snippet
core_initcall(init_amu_fie);
#ifdef CONFIG_ACPI_CPPC_LIB
#include <acpi/cppc_acpi.h>
static void cpu_read_corecnt(void *val)
{
/*
* A value of 0 can be returned if the current CPU does not support AMUs
* or if the counter is disabled for this CPU. A return value of 0 at
* counter read is properly handled as an error case by the users of the
* counter.
*/
*(u64 *)val = read_corecnt();
}
static void cpu_read_constcnt(void *val)
{
/*
* Return 0 if the current CPU is affected by erratum 2457168. A value
* of 0 is also returned if the current CPU does not support AMUs or if
* the counter is disabled. A return value of 0 at counter read is
* properly handled as an error case by the users of the counter.
*/
*(u64 *)val = this_cpu_has_cap(ARM64_WORKAROUND_2457168) ?
0UL : read_constcnt();
}
static inline
int counters_read_on_cpu(int cpu, smp_call_func_t func, u64 *val)
{
/*
* Abort call on counterless CPU.
*/
if (!cpu_has_amu_feat(cpu))
return -EOPNOTSUPP;
if (irqs_disabled()) {
/*
* When IRQs are disabled (tick path: sched_tick ->
* topology_scale_freq_tick or cppc_scale_freq_tick), only local
* CPU counter reads are allowed. Remote CPU counter read would
* require smp_call_function_single() which is unsafe with IRQs
* disabled.
*/
if (WARN_ON_ONCE(cpu != smp_processor_id()))
return -EPERM;
func(val);
} else {
smp_call_function_single(cpu, func, val, 1);
}
return 0;
}
/*
* Refer to drivers/acpi/cppc_acpi.c for the description of the functions
* below.
*/
bool cpc_ffh_supported(void)
{
int cpu = get_cpu_with_amu_feat();
/*
* FFH is considered supported if there is at least one present CPU that
* supports AMUs. Using FFH to read core and reference counters for CPUs
* that do not support AMUs, have counters disabled or that are affected
* by errata, will result in a return value of 0.
*
* This is done to allow any enabled and valid counters to be read
* through FFH, knowing that potentially returning 0 as counter value is
* properly handled by the users of these counters.
*/
if ((cpu >= nr_cpu_ids) || !cpumask_test_cpu(cpu, cpu_present_mask))
return false;
return true;
}
int cpc_read_ffh(int cpu, struct cpc_reg *reg, u64 *val)
{
int ret = -EOPNOTSUPP;
switch ((u64)reg->address) {
case 0x0:
ret = counters_read_on_cpu(cpu, cpu_read_corecnt, val);
break;
case 0x1:
ret = counters_read_on_cpu(cpu, cpu_read_constcnt, val);
break;
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/arch_topology.h`, `linux/cacheinfo.h`, `linux/cpufreq.h`, `linux/cpu_smt.h`, `linux/init.h`, `linux/percpu.h`, `linux/sched/isolation.h`.
- Detected declarations: `struct amu_cntr_sample`, `function update_freq_counters_refs`, `function freq_counters_valid`, `function freq_inv_set_max_ratio`, `function amu_scale_freq_tick`, `function amu_fie_cpu_supported`, `function arch_cpu_idle_enter`, `function arch_freq_get_on_cpu`, `function for_each_cpu_wrap`, `function amu_fie_setup`.
- Atlas domain: Architecture Layer / arch/arm64.
- Implementation status: integration 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.