47,6 → 47,7 |
|
static atomic_t thread_count; |
static atomic_t thread_fail; |
static bool sh_quiet; |
|
static void falloc(void * arg) |
{ |
56,6 → 57,7 |
|
uintptr_t * frames = (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), FRAME_ATOMIC); |
if (frames == NULL) { |
if (!sh_quiet) |
printf("Thread #%d (cpu%d): Unable to allocate frames\n", THREAD->tid, CPU->id); |
atomic_inc(&thread_fail); |
atomic_dec(&thread_count); |
66,7 → 68,9 |
|
for (run = 0; run < THREAD_RUNS; run++) { |
for (order = 0; order <= MAX_ORDER; order++) { |
if (!sh_quiet) |
printf("Thread #%d (cpu%d): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order); |
|
allocated = 0; |
for (i = 0; i < (MAX_FRAMES >> order); i++) { |
frames[allocated] = (uintptr_t)frame_alloc(order, FRAME_ATOMIC | FRAME_KA); |
76,12 → 80,17 |
} else |
break; |
} |
|
if (!sh_quiet) |
printf("Thread #%d (cpu%d): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated); |
|
if (!sh_quiet) |
printf("Thread #%d (cpu%d): Deallocating ... \n", THREAD->tid, CPU->id); |
|
for (i = 0; i < allocated; i++) { |
for (k = 0; k <= ((FRAME_SIZE << order) - 1); k++) { |
if (((uint8_t *) frames[i])[k] != val) { |
if (!sh_quiet) |
printf("Thread #%d (cpu%d): Unexpected data (%d) in block %p offset %#zx\n", THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k); |
atomic_inc(&thread_fail); |
goto cleanup; |
89,6 → 98,8 |
} |
frame_free(KA2PA(frames[i])); |
} |
|
if (!sh_quiet) |
printf("Thread #%d (cpu%d): Finished run.\n", THREAD->tid, CPU->id); |
} |
} |
95,6 → 106,8 |
|
cleanup: |
free(frames); |
|
if (!sh_quiet) |
printf("Thread #%d (cpu%d): Exiting\n", THREAD->tid, CPU->id); |
atomic_dec(&thread_count); |
} |
102,6 → 115,7 |
char * test_falloc2(bool quiet) |
{ |
unsigned int i; |
sh_quiet = quiet; |
|
atomic_set(&thread_count, THREADS); |
atomic_set(&thread_fail, 0); |
109,6 → 123,7 |
for (i = 0; i < THREADS; i++) { |
thread_t * thrd = thread_create(falloc, NULL, TASK, 0, "falloc", false); |
if (!thrd) { |
if (!quiet) |
printf("Could not create thread %d\n", i); |
break; |
} |
116,6 → 131,7 |
} |
|
while (atomic_get(&thread_count) > 0) { |
if (!quiet) |
printf("Threads left: %d\n", atomic_get(&thread_count)); |
thread_sleep(1); |
} |