X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=t%2Fmemlock.c;h=418dc3c48fd0c1b4cf8596564ee22f3f661fd92a;hb=63ef965dc21350ad093f3072b201ae965800c41b;hp=d9d586d8a5ac4db84c5f7fa0978ce06897543975;hpb=3bf80dad77448afcb18148e72dc6cfe04bcf7e57;p=fio.git diff --git a/t/memlock.c b/t/memlock.c index d9d586d8..418dc3c4 100644 --- a/t/memlock.c +++ b/t/memlock.c @@ -4,7 +4,7 @@ #include static struct thread_data { - unsigned long mb; + unsigned long mib; } td; static void *worker(void *data) @@ -15,36 +15,41 @@ static void *worker(void *data) char *buf; int i, first = 1; - size = td->mb * 1024UL * 1024UL; + size = td->mib * 1024UL * 1024UL; buf = malloc(size); for (i = 0; i < 100000; i++) { for (index = 0; index + 4096 < size; index += 4096) memset(&buf[index+512], 0x89, 512); if (first) { - printf("loop%d: did %lu MB\n", i+1, size/(1024UL*1024UL)); + printf("loop%d: did %lu MiB\n", i+1, size/(1024UL*1024UL)); first = 0; } } + free(buf); return NULL; } int main(int argc, char *argv[]) { - unsigned long mb, threads; + unsigned long mib, threads; pthread_t *pthreads; int i; if (argc < 3) { - printf("%s: \n", argv[0]); + printf("%s: \n", argv[0]); return 1; } - mb = strtoul(argv[1], NULL, 10); + mib = strtoul(argv[1], NULL, 10); threads = strtoul(argv[2], NULL, 10); + if (threads < 1 || threads > 65536) { + printf("%s: invalid 'threads' argument\n", argv[0]); + return 1; + } pthreads = calloc(threads, sizeof(pthread_t)); - td.mb = mb; + td.mib = mib; for (i = 0; i < threads; i++) pthread_create(&pthreads[i], NULL, worker, &td);