Changes in kernel/test/mm/falloc2.c [cd3b380:6eef3c4] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/mm/falloc2.c
rcd3b380 r6eef3c4 40 40 #include <arch.h> 41 41 42 #define MAX_FRAMES 256 42 #define MAX_FRAMES 256U 43 #define MAX_ORDER 8 43 44 44 45 #define THREAD_RUNS 1 … … 52 53 uint8_t val = THREAD->tid % THREADS; 53 54 54 uintptr_t *frames = (uintptr_t*)55 malloc(MAX_FRAMES * sizeof( uintptr_t), FRAME_ATOMIC);55 void **frames = (void **) 56 malloc(MAX_FRAMES * sizeof(void *), FRAME_ATOMIC); 56 57 if (frames == NULL) { 57 58 TPRINTF("Thread #%" PRIu64 " (cpu%u): " … … 65 66 66 67 for (unsigned int run = 0; run < THREAD_RUNS; run++) { 67 for (size_t count = 1; count <= MAX_FRAMES; count++) { 68 size_t bytes = FRAMES2SIZE(count); 69 68 for (unsigned int order = 0; order <= MAX_ORDER; order++) { 70 69 TPRINTF("Thread #%" PRIu64 " (cpu%u): " 71 "Allocating % zu frames blocks (%zu bytes)... \n", THREAD->tid,72 CPU->id, count, bytes);70 "Allocating %u frames blocks ... \n", THREAD->tid, 71 CPU->id, 1 << order); 73 72 74 73 unsigned int allocated = 0; 75 for (unsigned int i = 0; i < (MAX_FRAMES / count); i++) { 76 frames[allocated] = frame_alloc(count, FRAME_ATOMIC, 0); 74 for (unsigned int i = 0; i < (MAX_FRAMES >> order); i++) { 75 frames[allocated] = 76 frame_alloc(order, FRAME_ATOMIC | FRAME_KA); 77 77 if (frames[allocated]) { 78 memsetb( (void *) PA2KA(frames[allocated]), bytes, val);78 memsetb(frames[allocated], FRAME_SIZE << order, val); 79 79 allocated++; 80 80 } else … … 89 89 90 90 for (unsigned int i = 0; i < allocated; i++) { 91 for (size_t k = 0; k < bytes; k++) { 92 if (((uint8_t *) PA2KA(frames[i]))[k] != val) { 91 for (size_t k = 0; k <= (((size_t) FRAME_SIZE << order) - 1); 92 k++) { 93 if (((uint8_t *) frames[i])[k] != val) { 93 94 TPRINTF("Thread #%" PRIu64 " (cpu%u): " 94 "Unexpected data (%c) in block % zuoffset %zu\n",95 THREAD->tid, CPU->id, ((char *) PA2KA(frames[i]))[k],95 "Unexpected data (%c) in block %p offset %zu\n", 96 THREAD->tid, CPU->id, ((char *) frames[i])[k], 96 97 frames[i], k); 97 98 atomic_inc(&thread_fail); … … 99 100 } 100 101 } 101 frame_free( frames[i], count);102 frame_free(KA2PA(frames[i])); 102 103 } 103 104
Note:
See TracChangeset
for help on using the changeset viewer.