tools/testing/selftests/resctrl/mbm_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/resctrl/mbm_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/resctrl/mbm_test.c- Extension
.c- Size
- 4410 bytes
- Lines
- 185
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
resctrl.h
Detected Declarations
function Monitoringfunction check_resultsfunction mbm_initfunction mbm_setupfunction mbm_measurefunction mbm_test_cleanupfunction mbm_run_testfunction mbm_feature_check
Annotated Snippet
while (token) {
token_array[i++] = token;
token = strtok(NULL, ":\t");
}
bw_resc[runs] = strtoul(token_array[5], NULL, 0);
bw_imc[runs] = strtoul(token_array[3], NULL, 0);
runs++;
}
ret = show_bw_info(bw_imc, bw_resc, span);
fclose(fp);
return ret;
}
static int mbm_init(const struct resctrl_test *test,
const struct user_params *uparams,
const struct resctrl_val_param *param, int domain_id)
{
int ret;
ret = initialize_read_mem_bw_imc();
if (ret)
return ret;
initialize_mem_bw_resctrl(param, domain_id);
return 0;
}
static int mbm_setup(const struct resctrl_test *test,
const struct user_params *uparams,
struct resctrl_val_param *p)
{
int ret = 0;
/* Run NUM_OF_RUNS times */
if (p->num_of_runs >= NUM_OF_RUNS)
return END_OF_TESTS;
/* Set up shemata with 100% allocation on the first run. */
if (p->num_of_runs == 0 && resctrl_resource_exists("MB"))
ret = write_schemata(p->ctrlgrp, "100", uparams->cpu, test->resource);
p->num_of_runs++;
return ret;
}
static int mbm_measure(const struct user_params *uparams,
struct resctrl_val_param *param, pid_t bm_pid)
{
return measure_read_mem_bw(uparams, param, bm_pid);
}
static void mbm_test_cleanup(void)
{
remove(RESULT_FILE_NAME);
}
static int mbm_run_test(const struct resctrl_test *test, const struct user_params *uparams)
{
struct resctrl_val_param param = {
.ctrlgrp = "c1",
.filename = RESULT_FILE_NAME,
.init = mbm_init,
.setup = mbm_setup,
.measure = mbm_measure,
};
struct fill_buf_param fill_buf = {};
int ret;
remove(RESULT_FILE_NAME);
if (uparams->fill_buf) {
fill_buf.buf_size = uparams->fill_buf->buf_size;
fill_buf.memflush = uparams->fill_buf->memflush;
param.fill_buf = &fill_buf;
} else if (!uparams->benchmark_cmd[0]) {
ssize_t buf_size;
buf_size = get_fill_buf_size(uparams->cpu, "L3");
if (buf_size < 0)
return buf_size;
fill_buf.buf_size = buf_size;
fill_buf.memflush = true;
param.fill_buf = &fill_buf;
}
Annotation
- Immediate include surface: `resctrl.h`.
- Detected declarations: `function Monitoring`, `function check_results`, `function mbm_init`, `function mbm_setup`, `function mbm_measure`, `function mbm_test_cleanup`, `function mbm_run_test`, `function mbm_feature_check`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.