Reduce blocksize in memtool to 64K

Let's see if we can hang a bit later on.
This commit is contained in:
Rodrigo Arias 2024-07-09 17:58:12 +02:00
parent 4707a8b143
commit c6726cce28
2 changed files with 15 additions and 7 deletions

View File

@ -92,9 +92,10 @@
# while [ 1 ]; do xxd -s $((0x1bfff0000 - 0x60000000)) \ # while [ 1 ]; do xxd -s $((0x1bfff0000 - 0x60000000)) \
# -l 4 /dev/qdma34000-MM-1; sleep 0.2; done # -l 4 /dev/qdma34000-MM-1; sleep 0.2; done
preDeviceCommands = preDeviceCommands =
# Run our memtool to hang the kernel here. # Run our memtool to hang the kernel here. Set the maximum block
# size to 64K.
'' ''
memtool memtool $((64 * 1024))
'' ''
+ +
'' ''

View File

@ -22,13 +22,14 @@ struct block *front = NULL;
struct block *tail = NULL; struct block *tail = NULL;
long nblocks = 0; long nblocks = 0;
long nbytes = 0; long nbytes = 0;
long maxsize = MAX_SIZE;
static int static int
allocate(void) allocate(void)
{ {
long n = (long) rand() % MAX_SIZE; /* Constraint the number of elements based on the maxsize */
/* Constraint the size */ long maxn = maxsize / sizeof(uint32_t);
n = n % MAX_SIZE; long n = (long) rand() % maxn;
size_t size = sizeof(struct block) + n * sizeof(uint32_t); size_t size = sizeof(struct block) + n * sizeof(uint32_t);
@ -106,14 +107,20 @@ torture(void)
c = '-'; c = '-';
} }
printf("iter %ld, nblocks %ld, nbytes %.1fM (%c)\n", printf("iter=%ld nblocks=%ld allocated=%ldK (%c)\n",
iter, nblocks, (double) nbytes / (1024. * 1024.), iter, nblocks, nbytes / 1024,
c); c);
} }
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
if (argc > 1)
maxsize = atol(argv[1]);
printf("memtool v1.0.0 maxsize=%ldK\n", maxsize / 1024);
torture(); torture();
return 0; return 0;
} }