Path: blob/master/tools/testing/selftests/damon/access_memory_even.c
29268 views
// SPDX-License-Identifier: GPL-2.01/*2* Artificial memory access program for testing DAMON.3*4* Receives number of regions and size of each region from user. Allocate the5* regions and repeatedly access even numbered (starting from zero) regions.6*/78#include <stdio.h>9#include <stdlib.h>10#include <string.h>1112int main(int argc, char *argv[])13{14char **regions;15int nr_regions;16int sz_region;17int i;1819if (argc != 3) {20printf("Usage: %s <number> <size (bytes)>\n", argv[0]);21return -1;22}2324nr_regions = atoi(argv[1]);25sz_region = atoi(argv[2]);2627regions = malloc(sizeof(*regions) * nr_regions);28for (i = 0; i < nr_regions; i++)29regions[i] = malloc(sz_region);3031while (1) {32for (i = 0; i < nr_regions; i++) {33if (i % 2 == 0)34memset(regions[i], i, sz_region);35}36}37return 0;38}394041