Changeset a35b458 in mainline for kernel/test/mm


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

Location:
kernel/test/mm
Files:
6 edited

Legend:

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

    r3061bc1 ra35b458  
    4545        if (TEST_RUNS < 2)
    4646                return "Test is compiled with TEST_RUNS < 2";
    47        
     47
    4848        uintptr_t *frames = (uintptr_t *)
    4949            malloc(MAX_FRAMES * sizeof(uintptr_t), 0);
    5050        if (frames == NULL)
    5151                return "Unable to allocate frames";
    52        
     52
    5353        unsigned int results[MAX_FRAMES + 1];
    54        
     54
    5555        for (unsigned int run = 0; run < TEST_RUNS; run++) {
    5656                for (size_t count = 1; count <= MAX_FRAMES; count++) {
    5757                        size_t bytes = FRAMES2SIZE(count);
    58                        
     58
    5959                        TPRINTF("Allocating %zu frames blocks (%zu bytes) ... ",
    6060                            count, bytes);
    61                        
     61
    6262                        unsigned int allocated = 0;
    6363                        for (unsigned int i = 0; i < (MAX_FRAMES / count); i++) {
     
    7070                                }
    7171                        }
    72                        
     72
    7373                        TPRINTF("%d blocks allocated.\n", allocated);
    74                        
     74
    7575                        if (run > 0) {
    7676                                if (results[count] != allocated)
     
    7878                        } else
    7979                                results[count] = allocated;
    80                        
     80
    8181                        TPRINTF("Deallocating ... ");
    82                        
     82
    8383                        for (unsigned int i = 0; i < allocated; i++)
    8484                                frame_free(frames[i], count);
    85                        
     85
    8686                        TPRINTF("done.\n");
    8787                }
    8888        }
    89        
     89
    9090        free(frames);
    91        
     91
    9292        return NULL;
    9393}
  • kernel/test/mm/falloc2.c

    r3061bc1 ra35b458  
    5151{
    5252        uint8_t val = THREAD->tid % THREADS;
    53        
     53
    5454        uintptr_t *frames = (uintptr_t *)
    5555            malloc(MAX_FRAMES * sizeof(uintptr_t), FRAME_ATOMIC);
     
    6161                return;
    6262        }
    63        
     63
    6464        thread_detach(THREAD);
    65        
     65
    6666        for (unsigned int run = 0; run < THREAD_RUNS; run++) {
    6767                for (size_t count = 1; count <= MAX_FRAMES; count++) {
    6868                        size_t bytes = FRAMES2SIZE(count);
    69                        
     69
    7070                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
    7171                            "Allocating %zu frames blocks (%zu bytes) ... \n", THREAD->tid,
    7272                            CPU->id, count, bytes);
    73                        
     73
    7474                        unsigned int allocated = 0;
    7575                        for (unsigned int i = 0; i < (MAX_FRAMES / count); i++) {
     
    8181                                        break;
    8282                        }
    83                        
     83
    8484                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
    8585                            "%u blocks allocated.\n", THREAD->tid, CPU->id,
     
    8787                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
    8888                            "Deallocating ... \n", THREAD->tid, CPU->id);
    89                        
     89
    9090                        for (unsigned int i = 0; i < allocated; i++) {
    9191                                for (size_t k = 0; k < bytes; k++) {
     
    101101                                frame_free(frames[i], count);
    102102                        }
    103                        
     103
    104104                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
    105105                            "Finished run.\n", THREAD->tid, CPU->id);
    106106                }
    107107        }
    108        
     108
    109109cleanup:
    110110        free(frames);
    111        
     111
    112112        TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n",
    113113            THREAD->tid, CPU->id);
     
    119119        atomic_set(&thread_count, THREADS);
    120120        atomic_set(&thread_fail, 0);
    121        
     121
    122122        for (unsigned int i = 0; i < THREADS; i++) {
    123123                thread_t *thrd = thread_create(falloc, NULL, TASK,
     
    129129                thread_ready(thrd);
    130130        }
    131        
     131
    132132        while (atomic_get(&thread_count) > 0) {
    133133                TPRINTF("Threads left: %" PRIua "\n",
     
    135135                thread_sleep(1);
    136136        }
    137        
     137
    138138        if (atomic_get(&thread_fail) == 0)
    139139                return NULL;
    140        
     140
    141141        return "Test failed";
    142142}
  • kernel/test/mm/mapping1.c

    r3061bc1 ra35b458  
    4242{
    4343        uintptr_t frame = frame_alloc(1, FRAME_NONE, 0);
    44        
     44
    4545        uintptr_t page0 = km_map(frame, FRAME_SIZE,
    4646            PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE);
    4747        TPRINTF("Virtual address %p mapped to physical address %p.\n",
    4848            (void *) page0, (void *) frame);
    49        
     49
    5050        uintptr_t page1 = km_map(frame, FRAME_SIZE,
    5151            PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE);
    5252        TPRINTF("Virtual address %p mapped to physical address %p.\n",
    5353            (void *) page1, (void *) frame);
    54        
     54
    5555        for (unsigned int i = 0; i < 2; i++) {
    5656                TPRINTF("Writing magic using the first virtual address.\n");
    57                
     57
    5858                *((uint32_t *) page0) = TEST_MAGIC;
    59                
     59
    6060                TPRINTF("Reading magic using the second virtual address.\n");
    61                
     61
    6262                uint32_t v = *((uint32_t *) page1);
    63                
     63
    6464                if (v != TEST_MAGIC) {
    6565                        km_unmap(page0, PAGE_SIZE);
     
    6868                        return "Criss-cross read does not match the value written.";
    6969                }
    70                
     70
    7171                TPRINTF("Writing zero using the second virtual address.\n");
    72                
     72
    7373                *((uint32_t *) page1) = 0;
    74                
     74
    7575                TPRINTF("Reading zero using the first virtual address.\n");
    76                
     76
    7777                v = *((uint32_t *) page0);
    78                
     78
    7979                if (v != 0) {
    8080                        km_unmap(page0, PAGE_SIZE);
     
    8484                }
    8585        }
    86        
     86
    8787        km_unmap(page0, PAGE_SIZE);
    8888        km_unmap(page1, PAGE_SIZE);
    8989        frame_free(frame, 1);
    90        
     90
    9191        return NULL;
    9292}
  • kernel/test/mm/purge1.c

    r3061bc1 ra35b458  
    4444        tlb_entry_t entryi;
    4545        tlb_entry_t entryd;
    46        
     46
    4747        int i;
    48        
     48
    4949        entryd.word[0] = 0;
    5050        entryd.word[1] = 0;
    51        
     51
    5252        entryd.p = true;                 /* present */
    5353        entryd.ma = MA_WRITEBACK;
     
    5858        entryd.ppn = 0;
    5959        entryd.ps = PAGE_WIDTH;
    60        
     60
    6161        entryi.word[0] = 0;
    6262        entryi.word[1] = 0;
    63        
     63
    6464        entryi.p = true;                 /* present */
    6565        entryi.ma = MA_WRITEBACK;
     
    7070        entryi.ppn = 0;
    7171        entryi.ps = PAGE_WIDTH;
    72        
     72
    7373        for (i = 0; i < 100; i++) {
    7474                itc_mapping_insert(0 + i * (1 << PAGE_WIDTH), 8, entryi);
    7575                dtc_mapping_insert(0 + i * (1 << PAGE_WIDTH), 9, entryd);
    7676        }
    77        
     77
    7878        tlb_invalidate_pages(8, 0x0c000, 14);
    79        
     79
    8080        /* tlb_invalidate_all(); */
    81        
     81
    8282        return NULL;
    8383}
  • kernel/test/mm/slab1.c

    r3061bc1 ra35b458  
    4242        slab_cache_t *cache;
    4343        int i;
    44        
     44
    4545        TPRINTF("Creating cache, object size: %d.\n", size);
    46        
     46
    4747        cache = slab_cache_create("test_cache", size, 0, NULL, NULL,
    4848            SLAB_CACHE_NOMAGAZINE);
    49        
     49
    5050        TPRINTF("Allocating %d items...", count);
    51        
     51
    5252        for (i = 0; i < count; i++) {
    5353                data[i] = slab_alloc(cache, 0);
    5454                memsetb(data[i], size, 0);
    5555        }
    56        
     56
    5757        TPRINTF("done.\n");
    58        
     58
    5959        TPRINTF("Freeing %d items...", count);
    60        
     60
    6161        for (i = 0; i < count; i++)
    6262                slab_free(cache, data[i]);
    63        
     63
    6464        TPRINTF("done.\n");
    65        
     65
    6666        TPRINTF("Allocating %d items...", count);
    67        
     67
    6868        for (i = 0; i < count; i++) {
    6969                data[i] = slab_alloc(cache, 0);
    7070                memsetb(data[i], size, 0);
    7171        }
    72        
     72
    7373        TPRINTF("done.\n");
    74        
     74
    7575        TPRINTF("Freeing %d items...", count / 2);
    76        
     76
    7777        for (i = count - 1; i >= count / 2; i--)
    7878                slab_free(cache, data[i]);
    79        
     79
    8080        TPRINTF("done.\n");
    81        
     81
    8282        TPRINTF("Allocating %d items...", count / 2);
    83        
     83
    8484        for (i = count / 2; i < count; i++) {
    8585                data[i] = slab_alloc(cache, 0);
    8686                memsetb(data[i], size, 0);
    8787        }
    88        
     88
    8989        TPRINTF("done.\n");
    90        
     90
    9191        TPRINTF("Freeing %d items...", count);
    92        
     92
    9393        for (i = 0; i < count; i++)
    9494                slab_free(cache, data[i]);
    95        
     95
    9696        TPRINTF("done.\n");
    97        
     97
    9898        slab_cache_destroy(cache);
    99        
     99
    100100        TPRINTF("Test complete.\n");
    101101}
     
    125125        int offs = (int) (sysarg_t) data;
    126126        int i, j;
    127        
     127
    128128        thread_detach(THREAD);
    129        
     129
    130130        TPRINTF("Starting thread #%" PRIu64 "...\n", THREAD->tid);
    131        
     131
    132132        for (j = 0; j < 10; j++) {
    133133                for (i = 0; i < THR_MEM_COUNT; i++)
     
    140140                        slab_free(thr_cache, thr_data[offs][i]);
    141141        }
    142        
     142
    143143        TPRINTF("Thread #%" PRIu64 " finished\n", THREAD->tid);
    144        
     144
    145145        semaphore_up(&thr_sem);
    146146}
     
    150150        thread_t *t;
    151151        int i;
    152        
     152
    153153        thr_cache = slab_cache_create("thread_cache", THR_MEM_SIZE, 0, NULL, NULL,
    154154            SLAB_CACHE_NOMAGAZINE);
    155        
     155
    156156        semaphore_initialize(&thr_sem, 0);
    157157        for (i = 0; i < THREADS; i++) {
     
    164164        for (i = 0; i < THREADS; i++)
    165165                semaphore_down(&thr_sem);
    166        
     166
    167167        slab_cache_destroy(thr_cache);
    168        
     168
    169169        TPRINTF("Test complete.\n");
    170170}
     
    174174        testsimple();
    175175        testthreads();
    176        
     176
    177177        return NULL;
    178178}
  • kernel/test/mm/slab2.c

    r3061bc1 ra35b458  
    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.