arch/x86/include/asm/resctrl.h
Source file repositories/reference/linux-study-clean/arch/x86/include/asm/resctrl.h
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/include/asm/resctrl.h- Extension
.h- Size
- 5544 bytes
- Lines
- 204
- 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/jump_label.hlinux/percpu.hlinux/resctrl_types.hlinux/sched.hasm/msr.h
Detected Declarations
struct resctrl_pqr_statestruct rdt_resourcefunction resctrl_arch_alloc_capablefunction resctrl_arch_enable_allocfunction resctrl_arch_disable_allocfunction resctrl_arch_mon_capablefunction resctrl_arch_enable_monfunction resctrl_arch_disable_monfunction __resctrl_sched_infunction resctrl_arch_round_mon_valfunction resctrl_arch_set_cpu_default_closid_rmidfunction resctrl_arch_set_closid_rmidfunction resctrl_arch_match_closidfunction resctrl_arch_match_rmidfunction resctrl_arch_sched_infunction resctrl_arch_rmid_idx_decodefunction resctrl_arch_rmid_idx_encodefunction resctrl_arch_mon_ctx_freefunction resctrl_arch_sched_in
Annotated Snippet
struct resctrl_pqr_state {
u32 cur_rmid;
u32 cur_closid;
u32 default_rmid;
u32 default_closid;
};
DECLARE_PER_CPU(struct resctrl_pqr_state, pqr_state);
extern bool rdt_alloc_capable;
extern bool rdt_mon_capable;
DECLARE_STATIC_KEY_FALSE(rdt_enable_key);
DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key);
DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);
static inline bool resctrl_arch_alloc_capable(void)
{
return rdt_alloc_capable;
}
static inline void resctrl_arch_enable_alloc(void)
{
static_branch_enable_cpuslocked(&rdt_alloc_enable_key);
static_branch_inc_cpuslocked(&rdt_enable_key);
}
static inline void resctrl_arch_disable_alloc(void)
{
static_branch_disable_cpuslocked(&rdt_alloc_enable_key);
static_branch_dec_cpuslocked(&rdt_enable_key);
}
static inline bool resctrl_arch_mon_capable(void)
{
return rdt_mon_capable;
}
static inline void resctrl_arch_enable_mon(void)
{
static_branch_enable_cpuslocked(&rdt_mon_enable_key);
static_branch_inc_cpuslocked(&rdt_enable_key);
}
static inline void resctrl_arch_disable_mon(void)
{
static_branch_disable_cpuslocked(&rdt_mon_enable_key);
static_branch_dec_cpuslocked(&rdt_enable_key);
}
/*
* __resctrl_sched_in() - Writes the task's CLOSid/RMID to IA32_PQR_MSR
*
* Following considerations are made so that this has minimal impact
* on scheduler hot path:
* - This will stay as no-op unless we are running on an Intel SKU
* which supports resource control or monitoring and we enable by
* mounting the resctrl file system.
* - Caches the per cpu CLOSid/RMID values and does the MSR write only
* when a task with a different CLOSid/RMID is scheduled in.
* - We allocate RMIDs/CLOSids globally in order to keep this as
* simple as possible.
* Must be called with preemption disabled.
*/
static inline void __resctrl_sched_in(struct task_struct *tsk)
{
struct resctrl_pqr_state *state = this_cpu_ptr(&pqr_state);
u32 closid = READ_ONCE(state->default_closid);
u32 rmid = READ_ONCE(state->default_rmid);
u32 tmp;
/*
* If this task has a closid/rmid assigned, use it.
* Else use the closid/rmid assigned to this cpu.
*/
if (static_branch_likely(&rdt_alloc_enable_key)) {
tmp = READ_ONCE(tsk->closid);
if (tmp)
closid = tmp;
}
if (static_branch_likely(&rdt_mon_enable_key)) {
tmp = READ_ONCE(tsk->rmid);
if (tmp)
rmid = tmp;
}
if (closid != state->cur_closid || rmid != state->cur_rmid) {
state->cur_closid = closid;
state->cur_rmid = rmid;
Annotation
- Immediate include surface: `linux/jump_label.h`, `linux/percpu.h`, `linux/resctrl_types.h`, `linux/sched.h`, `asm/msr.h`.
- Detected declarations: `struct resctrl_pqr_state`, `struct rdt_resource`, `function resctrl_arch_alloc_capable`, `function resctrl_arch_enable_alloc`, `function resctrl_arch_disable_alloc`, `function resctrl_arch_mon_capable`, `function resctrl_arch_enable_mon`, `function resctrl_arch_disable_mon`, `function __resctrl_sched_in`, `function resctrl_arch_round_mon_val`.
- 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.