fs/resctrl/ctrlmondata.c
Source file repositories/reference/linux-study-clean/fs/resctrl/ctrlmondata.c
File Facts
- System
- Linux kernel
- Corpus path
fs/resctrl/ctrlmondata.c- Extension
.c- Size
- 25892 bytes
- Lines
- 1059
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cpu.hlinux/kernfs.hlinux/math.hlinux/seq_file.hlinux/slab.hlinux/tick.hinternal.h
Detected Declarations
struct rdt_parse_datafunction bw_validatefunction parse_bwfunction cbm_validatefunction maskfunction rdtgroup_pseudo_locked_in_hierarchyfunction parse_linefunction rdtgroup_parse_resourcefunction list_for_each_entryfunction rdtgroup_schemata_writefunction list_for_each_entryfunction show_domsfunction rdtgroup_schemata_showfunction list_for_each_entryfunction smp_mon_event_countfunction rdtgroup_mba_mbps_event_writefunction rdtgroup_mba_mbps_event_showfunction list_for_eachfunction mon_event_readfunction resctrl_is_mbm_eventfunction print_event_valuefunction rdtgroup_mondata_showfunction list_for_each_entryfunction resctrl_io_alloc_showfunction resctrl_io_alloc_closid_supportedfunction usablefunction resctrl_io_alloc_closidfunction resctrl_io_alloc_writefunction resctrl_io_alloc_cbm_showfunction resctrl_io_alloc_parse_linefunction resctrl_io_alloc_cbm_write
Annotated Snippet
struct rdt_parse_data {
u32 closid;
enum rdtgrp_mode mode;
char *buf;
};
typedef int (ctrlval_parser_t)(struct rdt_parse_data *data,
struct resctrl_schema *s,
struct rdt_ctrl_domain *d);
/*
* Check whether MBA bandwidth percentage value is correct. The value is
* checked against the minimum and max bandwidth values specified by the
* hardware. The allocated bandwidth percentage is rounded to the next
* control step available on the hardware.
*/
static bool bw_validate(char *buf, u32 *data, struct rdt_resource *r)
{
int ret;
u32 bw;
/*
* Only linear delay values is supported for current Intel SKUs.
*/
if (!r->membw.delay_linear && r->membw.arch_needs_linear) {
rdt_last_cmd_puts("No support for non-linear MB domains\n");
return false;
}
ret = kstrtou32(buf, 10, &bw);
if (ret) {
rdt_last_cmd_printf("Invalid MB value %s\n", buf);
return false;
}
/* Nothing else to do if software controller is enabled. */
if (is_mba_sc(r)) {
*data = bw;
return true;
}
if (bw < r->membw.min_bw || bw > r->membw.max_bw) {
rdt_last_cmd_printf("MB value %u out of range [%d,%d]\n",
bw, r->membw.min_bw, r->membw.max_bw);
return false;
}
*data = roundup(bw, (unsigned long)r->membw.bw_gran);
return true;
}
static int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s,
struct rdt_ctrl_domain *d)
{
struct resctrl_staged_config *cfg;
struct rdt_resource *r = s->res;
u32 closid = data->closid;
u32 bw_val;
cfg = &d->staged_config[s->conf_type];
if (cfg->have_new_ctrl) {
rdt_last_cmd_printf("Duplicate domain %d\n", d->hdr.id);
return -EINVAL;
}
if (!bw_validate(data->buf, &bw_val, r))
return -EINVAL;
if (is_mba_sc(r)) {
d->mbps_val[closid] = bw_val;
return 0;
}
cfg->new_ctrl = bw_val;
cfg->have_new_ctrl = true;
return 0;
}
/*
* Check whether a cache bit mask is valid.
* On Intel CPUs, non-contiguous 1s value support is indicated by CPUID:
* - CPUID.0x10.1:ECX[3]: L3 non-contiguous 1s value supported if 1
* - CPUID.0x10.2:ECX[3]: L2 non-contiguous 1s value supported if 1
*
* Haswell does not support a non-contiguous 1s value and additionally
* requires at least two bits set.
* AMD allows non-contiguous bitmasks.
*/
static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/kernfs.h`, `linux/math.h`, `linux/seq_file.h`, `linux/slab.h`, `linux/tick.h`, `internal.h`.
- Detected declarations: `struct rdt_parse_data`, `function bw_validate`, `function parse_bw`, `function cbm_validate`, `function mask`, `function rdtgroup_pseudo_locked_in_hierarchy`, `function parse_line`, `function rdtgroup_parse_resource`, `function list_for_each_entry`, `function rdtgroup_schemata_write`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- 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.