mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-08-21 16:31:14 +02:00

To test schemes_tried_regions feature, we need to have a program having specific number of regions that having different access pattern. Existing artificial access pattern generator, 'access_memory', cannot be used for the purpose, since it accesses only one region at a given time. Extending it could be an option, but since the purpose and the implementation are pretty simple, implementing another one from the scratch is better. Implement such another artificial memory access program that allocates user-defined number/size regions and accesses even-numbered regions. Link: https://lkml.kernel.org/r/20240625180538.73134-4-sj@kernel.org Signed-off-by: SeongJae Park <sj@kernel.org> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
43 lines
870 B
C
43 lines
870 B
C
// 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>
|
|
#include <time.h>
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
char **regions;
|
|
clock_t start_clock;
|
|
int nr_regions;
|
|
int sz_region;
|
|
int access_time_ms;
|
|
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;
|
|
}
|