arch/x86/kernel/cpu/resctrl/core.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/cpu/resctrl/core.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/cpu/resctrl/core.c- Extension
.c- Size
- 29366 bytes
- Lines
- 1172
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/cpu.hlinux/slab.hlinux/err.hlinux/cpuhotplug.hasm/cpu_device_id.hasm/cpuid/api.hasm/msr.hasm/resctrl.hinternal.h
Detected Declarations
struct rdt_optionsfunction resctrl_arch_system_num_rmid_idxfunction cache_alloc_hsw_probefunction rdt_get_mb_tablefunction __get_mem_config_intelfunction __rdt_get_mem_config_amdfunction rdt_get_cache_alloc_cfgfunction rdt_get_cdp_configfunction rdt_set_io_alloc_capablefunction rdt_get_cdp_l3_configfunction rdt_get_cdp_l2_configfunction mba_wrmsr_amdfunction delay_bw_mapfunction mba_wrmsr_intelfunction cat_wrmsrfunction resctrl_arch_get_num_closidfunction rdt_ctrl_updatefunction setup_default_ctrlvalfunction ctrl_domain_freefunction l3_mon_domain_freefunction domain_setup_ctrlvalfunction l3_mon_domain_mbm_allocfunction for_each_mbm_event_idfunction get_domain_id_from_scopefunction domain_add_cpu_ctrlfunction l3_mon_domain_setupfunction domain_add_cpu_monfunction domain_add_cpufunction domain_remove_cpu_ctrlfunction domain_remove_cpu_monfunction domain_remove_cpufunction clear_closid_rmidfunction resctrl_arch_online_cpufunction resctrl_arch_offline_cpufunction resctrl_arch_pre_mountfunction set_rdt_optionsfunction rdt_cpu_hasfunction resctrl_arch_is_evt_configurablefunction get_mem_configfunction get_slow_mem_configfunction get_rdt_alloc_resourcesfunction get_rdt_mon_resourcesfunction __check_quirks_intelfunction check_quirksfunction get_rdt_resourcesfunction rdt_init_res_defs_intelfunction for_each_rdt_resourcefunction rdt_init_res_defs_amd
Annotated Snippet
struct rdt_options {
char *name;
int flag;
bool force_off, force_on;
};
static struct rdt_options rdt_options[] __ro_after_init = {
RDT_OPT(RDT_FLAG_CMT, "cmt", X86_FEATURE_CQM_OCCUP_LLC),
RDT_OPT(RDT_FLAG_MBM_TOTAL, "mbmtotal", X86_FEATURE_CQM_MBM_TOTAL),
RDT_OPT(RDT_FLAG_MBM_LOCAL, "mbmlocal", X86_FEATURE_CQM_MBM_LOCAL),
RDT_OPT(RDT_FLAG_L3_CAT, "l3cat", X86_FEATURE_CAT_L3),
RDT_OPT(RDT_FLAG_L3_CDP, "l3cdp", X86_FEATURE_CDP_L3),
RDT_OPT(RDT_FLAG_L2_CAT, "l2cat", X86_FEATURE_CAT_L2),
RDT_OPT(RDT_FLAG_L2_CDP, "l2cdp", X86_FEATURE_CDP_L2),
RDT_OPT(RDT_FLAG_MBA, "mba", X86_FEATURE_MBA),
RDT_OPT(RDT_FLAG_SMBA, "smba", X86_FEATURE_SMBA),
RDT_OPT(RDT_FLAG_BMEC, "bmec", X86_FEATURE_BMEC),
RDT_OPT(RDT_FLAG_ABMC, "abmc", X86_FEATURE_ABMC),
RDT_OPT(RDT_FLAG_SDCIAE, "sdciae", X86_FEATURE_SDCIAE),
};
#define NUM_RDT_OPTIONS ARRAY_SIZE(rdt_options)
static int __init set_rdt_options(char *str)
{
struct rdt_options *o;
bool force_off;
char *tok;
if (*str == '=')
str++;
while ((tok = strsep(&str, ",")) != NULL) {
force_off = *tok == '!';
if (force_off)
tok++;
if (intel_handle_aet_option(force_off, tok))
continue;
for (o = rdt_options; o < &rdt_options[NUM_RDT_OPTIONS]; o++) {
if (strcmp(tok, o->name) == 0) {
if (force_off)
o->force_off = true;
else
o->force_on = true;
break;
}
}
}
return 1;
}
__setup("rdt", set_rdt_options);
bool rdt_cpu_has(int flag)
{
bool ret = boot_cpu_has(flag);
struct rdt_options *o;
if (!ret)
return ret;
for (o = rdt_options; o < &rdt_options[NUM_RDT_OPTIONS]; o++) {
if (flag == o->flag) {
if (o->force_off)
ret = false;
if (o->force_on)
ret = true;
break;
}
}
return ret;
}
bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt)
{
if (!rdt_cpu_has(X86_FEATURE_BMEC))
return false;
switch (evt) {
case QOS_L3_MBM_TOTAL_EVENT_ID:
return rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL);
case QOS_L3_MBM_LOCAL_EVENT_ID:
return rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL);
default:
return false;
}
}
static __init bool get_mem_config(void)
{
struct rdt_hw_resource *hw_res = &rdt_resources_all[RDT_RESOURCE_MBA];
if (!rdt_cpu_has(X86_FEATURE_MBA))
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/slab.h`, `linux/err.h`, `linux/cpuhotplug.h`, `asm/cpu_device_id.h`, `asm/cpuid/api.h`, `asm/msr.h`, `asm/resctrl.h`.
- Detected declarations: `struct rdt_options`, `function resctrl_arch_system_num_rmid_idx`, `function cache_alloc_hsw_probe`, `function rdt_get_mb_table`, `function __get_mem_config_intel`, `function __rdt_get_mem_config_amd`, `function rdt_get_cache_alloc_cfg`, `function rdt_get_cdp_config`, `function rdt_set_io_alloc_capable`, `function rdt_get_cdp_l3_config`.
- Atlas domain: Architecture Layer / arch/x86.
- 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.