Changes in kernel/test/mm/slab2.c [a35b458:44a7ee5] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/test/mm/slab2.c

    ra35b458 r44a7ee5  
    4848        slab_cache_t *cache2;
    4949        int i;
    50 
     50       
    5151        void *data1, *data2;
    5252        void *olddata1 = NULL, *olddata2 = NULL;
    53 
     53       
    5454        cache1 = slab_cache_create("test_cache1", ITEM_SIZE, 0, NULL, NULL, 0);
    5555        cache2 = slab_cache_create("test_cache2", ITEM_SIZE, 0, NULL, NULL, 0);
    56 
     56       
    5757        TPRINTF("Allocating...");
    58 
     58       
    5959        /* Use atomic alloc, so that we find end of memory */
    6060        do {
     
    7575                olddata2 = data2;
    7676        } while (true);
    77 
     77       
    7878        TPRINTF("done.\n");
    79 
     79       
    8080        TPRINTF("Deallocating cache2...");
    81 
     81       
    8282        /* We do not have memory - now deallocate cache2 */
    8383        while (olddata2) {
     
    8686                olddata2 = data2;
    8787        }
    88 
     88       
    8989        TPRINTF("done.\n");
    90 
     90       
    9191        TPRINTF("Allocating to cache1...\n");
    92 
     92       
    9393        for (i = 0; i < 30; i++) {
    9494                data1 = slab_alloc(cache1, FRAME_ATOMIC);
     
    109109                olddata1 = data1;
    110110        }
    111 
     111       
    112112        TPRINTF("Deallocating cache1...");
    113 
     113       
    114114        while (olddata1) {
    115115                data1 = *((void **) olddata1);
     
    117117                olddata1 = data1;
    118118        }
    119 
     119       
    120120        TPRINTF("done.\n");
    121 
     121       
    122122        if (!test_quiet)
    123123                slab_print_list();
    124 
     124       
    125125        slab_cache_destroy(cache1);
    126126        slab_cache_destroy(cache2);
     
    137137{
    138138        void *data = NULL, *new;
    139 
     139       
    140140        thread_detach(THREAD);
    141 
     141       
    142142        mutex_lock(&starter_mutex);
    143143        condvar_wait(&thread_starter,&starter_mutex);
    144144        mutex_unlock(&starter_mutex);
    145 
     145       
    146146        TPRINTF("Starting thread #%" PRIu64 "...\n", THREAD->tid);
    147147
    148148        /* Alloc all */
    149149        TPRINTF("Thread #%" PRIu64 " allocating...\n", THREAD->tid);
    150 
     150       
    151151        while (true) {
    152152                /* Call with atomic to detect end of memory */
     
    157157                data = new;
    158158        }
    159 
     159       
    160160        TPRINTF("Thread #%" PRIu64 " releasing...\n", THREAD->tid);
    161 
     161       
    162162        while (data) {
    163163                new = *((void **)data);
     
    166166                data = new;
    167167        }
    168 
     168       
    169169        TPRINTF("Thread #%" PRIu64 " allocating...\n", THREAD->tid);
    170 
     170       
    171171        while (true) {
    172172                /* Call with atomic to detect end of memory */
     
    177177                data = new;
    178178        }
    179 
     179       
    180180        TPRINTF("Thread #%" PRIu64 " releasing...\n", THREAD->tid);
    181 
     181       
    182182        while (data) {
    183183                new = *((void **)data);
     
    186186                data = new;
    187187        }
    188 
     188       
    189189        TPRINTF("Thread #%" PRIu64 " finished\n", THREAD->tid);
    190 
     190       
    191191        if (!test_quiet)
    192192                slab_print_list();
    193 
     193       
    194194        semaphore_up(&thr_sem);
    195195}
     
    202202        thread_t *t;
    203203        int i;
    204 
     204       
    205205        TPRINTF("Running stress test with size %d\n", size);
    206 
     206       
    207207        condvar_initialize(&thread_starter);
    208208        mutex_initialize(&starter_mutex, MUTEX_PASSIVE);
    209 
     209       
    210210        thr_cache = slab_cache_create("thread_cache", size, 0, NULL, NULL, 0);
    211211        semaphore_initialize(&thr_sem,0);
     
    218218        thread_sleep(1);
    219219        condvar_broadcast(&thread_starter);
    220 
     220       
    221221        for (i = 0; i < THREADS; i++)
    222222                semaphore_down(&thr_sem);
    223 
     223       
    224224        slab_cache_destroy(thr_cache);
    225225        TPRINTF("Stress test complete.\n");
     
    230230        TPRINTF("Running reclaim single-thread test .. pass 1\n");
    231231        totalmemtest();
    232 
     232       
    233233        TPRINTF("Running reclaim single-thread test .. pass 2\n");
    234234        totalmemtest();
    235 
     235       
    236236        TPRINTF("Reclaim test OK.\n");
    237 
     237       
    238238        multitest(128);
    239239        multitest(2048);
    240240        multitest(8192);
    241 
     241       
    242242        return NULL;
    243243}
Note: See TracChangeset for help on using the changeset viewer.