mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-28 04:24:26 +01:00
improve gem5 memory model and cpufreq experiments
This commit is contained in:
28
userland/c/malloc_touch.c
Normal file
28
userland/c/malloc_touch.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* https://cirosantilli.com/linux-kernel-module-cheat#gem5-memory-latency */
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
size_t nbytes, step;
|
||||
if (argc > 1) {
|
||||
nbytes = strtoull(argv[1], NULL, 0);
|
||||
} else {
|
||||
nbytes = 0x10;
|
||||
}
|
||||
if (argc > 2) {
|
||||
step = strtoull(argv[2], NULL, 0);
|
||||
} else {
|
||||
step = 1;
|
||||
}
|
||||
|
||||
char *base = malloc(nbytes);
|
||||
assert(base);
|
||||
char *i = base;
|
||||
while (i < base + nbytes) {
|
||||
*i = 13;
|
||||
i += step;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user