tools/testing/selftests/damon/access_memory_even.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/damon/access_memory_even.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/damon/access_memory_even.c- Extension
.c- Size
- 809 bytes
- Lines
- 40
- 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.
Dependency Surface
stdio.hstdlib.hstring.h
Detected Declarations
function numbered
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Artificial memory access program for testing DAMON.
*
* Receives number of regions and size of each region from user. Allocate the
* regions and repeatedly access even numbered (starting from zero) regions.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
char **regions;
int nr_regions;
int sz_region;
int i;
if (argc != 3) {
printf("Usage: %s <number> <size (bytes)>\n", argv[0]);
return -1;
}
nr_regions = atoi(argv[1]);
sz_region = atoi(argv[2]);
regions = malloc(sizeof(*regions) * nr_regions);
for (i = 0; i < nr_regions; i++)
regions[i] = malloc(sz_region);
while (1) {
for (i = 0; i < nr_regions; i++) {
if (i % 2 == 0)
memset(regions[i], i, sz_region);
}
}
return 0;
}
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `string.h`.
- Detected declarations: `function numbered`.
- 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.