tools/testing/selftests/cgroup/test_kmem.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/cgroup/test_kmem.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/cgroup/test_kmem.c- Extension
.c- Size
- 9878 bytes
- Lines
- 460
- 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
linux/limits.hfcntl.hstdio.hstdlib.hstring.hsys/stat.hsys/types.hunistd.hsys/wait.herrno.hsys/sysinfo.hpthread.hkselftest.hcgroup_util.h
Detected Declarations
struct kmem_testfunction bigfunction test_kmem_basicfunction alloc_kmem_smpfunction cg_run_in_subcgroupsfunction memoryfunction successfullyfunction spawn_1000_threadsfunction test_kmem_kernel_stacksfunction test_kmem_dead_cgroupsfunction test_percpu_basicfunction main
Annotated Snippet
struct kmem_test {
int (*fn)(const char *root);
const char *name;
} tests[] = {
T(test_kmem_basic),
T(test_kmem_memcg_deletion),
T(test_kmem_proc_kpagecgroup),
T(test_kmem_kernel_stacks),
T(test_kmem_dead_cgroups),
T(test_percpu_basic),
};
#undef T
int main(int argc, char **argv)
{
char root[PATH_MAX];
int i;
ksft_print_header();
ksft_set_plan(ARRAY_SIZE(tests));
if (cg_find_unified_root(root, sizeof(root), NULL))
ksft_exit_skip("cgroup v2 isn't mounted\n");
/*
* Check that memory controller is available:
* memory is listed in cgroup.controllers
*/
if (cg_read_strstr(root, "cgroup.controllers", "memory"))
ksft_exit_skip("memory controller isn't available\n");
if (cg_read_strstr(root, "cgroup.subtree_control", "memory"))
if (cg_write(root, "cgroup.subtree_control", "+memory"))
ksft_exit_skip("Failed to set memory controller\n");
for (i = 0; i < ARRAY_SIZE(tests); i++) {
switch (tests[i].fn(root)) {
case KSFT_PASS:
ksft_test_result_pass("%s\n", tests[i].name);
break;
case KSFT_SKIP:
ksft_test_result_skip("%s\n", tests[i].name);
break;
default:
ksft_test_result_fail("%s\n", tests[i].name);
break;
}
}
ksft_finished();
}
Annotation
- Immediate include surface: `linux/limits.h`, `fcntl.h`, `stdio.h`, `stdlib.h`, `string.h`, `sys/stat.h`, `sys/types.h`, `unistd.h`.
- Detected declarations: `struct kmem_test`, `function big`, `function test_kmem_basic`, `function alloc_kmem_smp`, `function cg_run_in_subcgroups`, `function memory`, `function successfully`, `function spawn_1000_threads`, `function test_kmem_kernel_stacks`, `function test_kmem_dead_cgroups`.
- 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.