Reduce blocksize in memtool to 64K
Let's see if we can hang a bit later on.
This commit is contained in:
parent
4707a8b143
commit
c6726cce28
@ -92,9 +92,10 @@
|
||||
# while [ 1 ]; do xxd -s $((0x1bfff0000 - 0x60000000)) \
|
||||
# -l 4 /dev/qdma34000-MM-1; sleep 0.2; done
|
||||
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))
|
||||
''
|
||||
+
|
||||
''
|
||||
|
17
memtool.c
17
memtool.c
@ -22,13 +22,14 @@ struct block *front = NULL;
|
||||
struct block *tail = NULL;
|
||||
long nblocks = 0;
|
||||
long nbytes = 0;
|
||||
long maxsize = MAX_SIZE;
|
||||
|
||||
static int
|
||||
allocate(void)
|
||||
{
|
||||
long n = (long) rand() % MAX_SIZE;
|
||||
/* Constraint the size */
|
||||
n = n % MAX_SIZE;
|
||||
/* Constraint the number of elements based on the maxsize */
|
||||
long maxn = maxsize / sizeof(uint32_t);
|
||||
long n = (long) rand() % maxn;
|
||||
|
||||
size_t size = sizeof(struct block) + n * sizeof(uint32_t);
|
||||
|
||||
@ -106,14 +107,20 @@ torture(void)
|
||||
c = '-';
|
||||
}
|
||||
|
||||
printf("iter %ld, nblocks %ld, nbytes %.1fM (%c)\n",
|
||||
iter, nblocks, (double) nbytes / (1024. * 1024.),
|
||||
printf("iter=%ld nblocks=%ld allocated=%ldK (%c)\n",
|
||||
iter, nblocks, nbytes / 1024,
|
||||
c);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc > 1)
|
||||
maxsize = atol(argv[1]);
|
||||
|
||||
printf("memtool v1.0.0 maxsize=%ldK\n", maxsize / 1024);
|
||||
|
||||
torture();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user