Changeset a35b458 in mainline for kernel/test/mm/slab2.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/mm/slab2.c
r3061bc1 ra35b458 48 48 slab_cache_t *cache2; 49 49 int i; 50 50 51 51 void *data1, *data2; 52 52 void *olddata1 = NULL, *olddata2 = NULL; 53 53 54 54 cache1 = slab_cache_create("test_cache1", ITEM_SIZE, 0, NULL, NULL, 0); 55 55 cache2 = slab_cache_create("test_cache2", ITEM_SIZE, 0, NULL, NULL, 0); 56 56 57 57 TPRINTF("Allocating..."); 58 58 59 59 /* Use atomic alloc, so that we find end of memory */ 60 60 do { … … 75 75 olddata2 = data2; 76 76 } while (true); 77 77 78 78 TPRINTF("done.\n"); 79 79 80 80 TPRINTF("Deallocating cache2..."); 81 81 82 82 /* We do not have memory - now deallocate cache2 */ 83 83 while (olddata2) { … … 86 86 olddata2 = data2; 87 87 } 88 88 89 89 TPRINTF("done.\n"); 90 90 91 91 TPRINTF("Allocating to cache1...\n"); 92 92 93 93 for (i = 0; i < 30; i++) { 94 94 data1 = slab_alloc(cache1, FRAME_ATOMIC); … … 109 109 olddata1 = data1; 110 110 } 111 111 112 112 TPRINTF("Deallocating cache1..."); 113 113 114 114 while (olddata1) { 115 115 data1 = *((void **) olddata1); … … 117 117 olddata1 = data1; 118 118 } 119 119 120 120 TPRINTF("done.\n"); 121 121 122 122 if (!test_quiet) 123 123 slab_print_list(); 124 124 125 125 slab_cache_destroy(cache1); 126 126 slab_cache_destroy(cache2); … … 137 137 { 138 138 void *data = NULL, *new; 139 139 140 140 thread_detach(THREAD); 141 141 142 142 mutex_lock(&starter_mutex); 143 143 condvar_wait(&thread_starter,&starter_mutex); 144 144 mutex_unlock(&starter_mutex); 145 145 146 146 TPRINTF("Starting thread #%" PRIu64 "...\n", THREAD->tid); 147 147 148 148 /* Alloc all */ 149 149 TPRINTF("Thread #%" PRIu64 " allocating...\n", THREAD->tid); 150 150 151 151 while (true) { 152 152 /* Call with atomic to detect end of memory */ … … 157 157 data = new; 158 158 } 159 159 160 160 TPRINTF("Thread #%" PRIu64 " releasing...\n", THREAD->tid); 161 161 162 162 while (data) { 163 163 new = *((void **)data); … … 166 166 data = new; 167 167 } 168 168 169 169 TPRINTF("Thread #%" PRIu64 " allocating...\n", THREAD->tid); 170 170 171 171 while (true) { 172 172 /* Call with atomic to detect end of memory */ … … 177 177 data = new; 178 178 } 179 179 180 180 TPRINTF("Thread #%" PRIu64 " releasing...\n", THREAD->tid); 181 181 182 182 while (data) { 183 183 new = *((void **)data); … … 186 186 data = new; 187 187 } 188 188 189 189 TPRINTF("Thread #%" PRIu64 " finished\n", THREAD->tid); 190 190 191 191 if (!test_quiet) 192 192 slab_print_list(); 193 193 194 194 semaphore_up(&thr_sem); 195 195 } … … 202 202 thread_t *t; 203 203 int i; 204 204 205 205 TPRINTF("Running stress test with size %d\n", size); 206 206 207 207 condvar_initialize(&thread_starter); 208 208 mutex_initialize(&starter_mutex, MUTEX_PASSIVE); 209 209 210 210 thr_cache = slab_cache_create("thread_cache", size, 0, NULL, NULL, 0); 211 211 semaphore_initialize(&thr_sem,0); … … 218 218 thread_sleep(1); 219 219 condvar_broadcast(&thread_starter); 220 220 221 221 for (i = 0; i < THREADS; i++) 222 222 semaphore_down(&thr_sem); 223 223 224 224 slab_cache_destroy(thr_cache); 225 225 TPRINTF("Stress test complete.\n"); … … 230 230 TPRINTF("Running reclaim single-thread test .. pass 1\n"); 231 231 totalmemtest(); 232 232 233 233 TPRINTF("Running reclaim single-thread test .. pass 2\n"); 234 234 totalmemtest(); 235 235 236 236 TPRINTF("Reclaim test OK.\n"); 237 237 238 238 multitest(128); 239 239 multitest(2048); 240 240 multitest(8192); 241 241 242 242 return NULL; 243 243 }
Note:
See TracChangeset
for help on using the changeset viewer.