1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Artificial memory access program for testing DAMON. 4 * 5 * Receives number of regions and size of each region from user. Allocate the 6 * regions and repeatedly access even numbered (starting from zero) regions. 7 */ 8 9 #include <stdio.h> 10 #include <stdlib.h> 11 #include <string.h> 12 #include <time.h> 13 14 int main(int argc, char *argv[]) 15 { 16 char **regions; 17 int nr_regions; 18 int sz_region; 19 int i; 20 21 if (argc != 3) { 22 printf("Usage: %s <number> <size (bytes)>\n", argv[0]); 23 return -1; 24 } 25 26 nr_regions = atoi(argv[1]); 27 sz_region = atoi(argv[2]); 28 29 regions = malloc(sizeof(*regions) * nr_regions); 30 for (i = 0; i < nr_regions; i++) 31 regions[i] = malloc(sz_region); 32 33 while (1) { 34 for (i = 0; i < nr_regions; i++) { 35 if (i % 2 == 0) 36 memset(regions[i], i, sz_region); 37 } 38 } 39 return 0; 40 } 41