diff options
-rw-r--r-- | litmus/bank_proc.c | 135 |
1 files changed, 131 insertions, 4 deletions
diff --git a/litmus/bank_proc.c b/litmus/bank_proc.c index ed195359e65f..bd1fb961436f 100644 --- a/litmus/bank_proc.c +++ b/litmus/bank_proc.c | |||
@@ -31,6 +31,9 @@ | |||
31 | #define CACHE_SHIFT 12 | 31 | #define CACHE_SHIFT 12 |
32 | 32 | ||
33 | #define PAGES_PER_COLOR 2000 | 33 | #define PAGES_PER_COLOR 2000 |
34 | #define NUM_BANKS 8 | ||
35 | #define NUM_COLORS 16 | ||
36 | |||
34 | unsigned int NUM_PAGE_LIST; //8*16 | 37 | unsigned int NUM_PAGE_LIST; //8*16 |
35 | 38 | ||
36 | unsigned int number_banks; | 39 | unsigned int number_banks; |
@@ -77,6 +80,10 @@ unsigned int bank_index[9] = { | |||
77 | 0, 0, 0, 0, 0, 0, 0, 0, 0 | 80 | 0, 0, 0, 0, 0, 0, 0, 0, 0 |
78 | }; | 81 | }; |
79 | 82 | ||
83 | int node_index[9] = { | ||
84 | -1, -1, -1, -1, -1, -1, -1, -1, -1 | ||
85 | }; | ||
86 | |||
80 | struct mutex void_lockdown_proc; | 87 | struct mutex void_lockdown_proc; |
81 | 88 | ||
82 | 89 | ||
@@ -138,7 +145,100 @@ unsigned int num_by_bitmask_index(unsigned int bitmask, unsigned int index) | |||
138 | return pos; | 145 | return pos; |
139 | } | 146 | } |
140 | 147 | ||
148 | static inline unsigned int first_index(unsigned long node) | ||
149 | { | ||
150 | unsigned int bank_no = 0, color_no = 0; | ||
151 | |||
152 | while(bank_no < NUM_BANKS) { | ||
153 | if ((bank_partition[node]>>bank_no) & 0x1) | ||
154 | break; | ||
155 | bank_no++; | ||
156 | } | ||
157 | while(color_no < NUM_COLORS) { | ||
158 | if ((set_partition[node]>>color_no) & 0x1) | ||
159 | break; | ||
160 | color_no++; | ||
161 | } | ||
162 | return NUM_COLORS*bank_no + color_no; | ||
163 | } | ||
164 | |||
165 | static inline unsigned int last_index(unsigned long node) | ||
166 | { | ||
167 | unsigned int bank_no = 7, color_no = 15; | ||
168 | |||
169 | while(bank_no >= 0) { | ||
170 | if ((bank_partition[node]>>bank_no) & 0x1) | ||
171 | break; | ||
172 | bank_no--; | ||
173 | } | ||
174 | while(color_no >= 0) { | ||
175 | if ((set_partition[node]>>color_no) & 0x1) | ||
176 | break; | ||
177 | color_no--; | ||
178 | } | ||
179 | return NUM_COLORS*bank_no + color_no; | ||
180 | } | ||
141 | 181 | ||
182 | static inline unsigned int next_color(unsigned long node, unsigned int current_color) | ||
183 | { | ||
184 | int try = 0, ret = 0; | ||
185 | current_color++; | ||
186 | if (current_color == NUM_COLORS) { | ||
187 | current_color = 0; | ||
188 | ret = 1; | ||
189 | } | ||
190 | |||
191 | while (try < NUM_COLORS) { | ||
192 | if ((set_partition[node]>>current_color)&0x1) | ||
193 | break; | ||
194 | current_color++; | ||
195 | if (current_color == NUM_COLORS) { | ||
196 | current_color = 0; | ||
197 | ret = 1; | ||
198 | } | ||
199 | try++; | ||
200 | } | ||
201 | if (!ret) | ||
202 | return current_color; | ||
203 | else | ||
204 | return current_color + NUM_COLORS; | ||
205 | } | ||
206 | |||
207 | static inline unsigned int next_bank(unsigned long node, unsigned int current_bank) | ||
208 | { | ||
209 | int try = 0; | ||
210 | current_bank++; | ||
211 | if (current_bank == NUM_BANKS) { | ||
212 | current_bank = 0; | ||
213 | } | ||
214 | |||
215 | while (try < NUM_BANKS) { | ||
216 | if ((bank_partition[node]>>current_bank)&0x1) | ||
217 | break; | ||
218 | current_bank++; | ||
219 | if (current_bank == NUM_BANKS) { | ||
220 | current_bank = 0; | ||
221 | } | ||
222 | try++; | ||
223 | } | ||
224 | return current_bank; | ||
225 | } | ||
226 | |||
227 | static inline unsigned int get_next_index(unsigned long node, unsigned int current_index) | ||
228 | { | ||
229 | unsigned int bank_no, color_no, color_ret, bank_ret; | ||
230 | bank_no = current_index>>4; | ||
231 | color_no = current_index - bank_no*NUM_COLORS; | ||
232 | bank_ret = bank_no; | ||
233 | color_ret = next_color(node, color_no); | ||
234 | if (color_ret >= NUM_COLORS) { | ||
235 | // next bank | ||
236 | color_ret -= NUM_COLORS; | ||
237 | bank_ret = next_bank(node, bank_no); | ||
238 | } | ||
239 | |||
240 | return bank_ret * NUM_COLORS + color_ret; | ||
241 | } | ||
142 | 242 | ||
143 | /* Decoding page color, 0~15 */ | 243 | /* Decoding page color, 0~15 */ |
144 | static inline unsigned int page_color(struct page *page) | 244 | static inline unsigned int page_color(struct page *page) |
@@ -327,11 +427,12 @@ static struct page *new_alloc_page_color( unsigned long color) | |||
327 | out_unlock: | 427 | out_unlock: |
328 | spin_unlock(&cgroup->lock); | 428 | spin_unlock(&cgroup->lock); |
329 | out: | 429 | out: |
430 | /* | ||
330 | if( smallest_nr_pages() == 0) { | 431 | if( smallest_nr_pages() == 0) { |
331 | //do_add_pages(); | 432 | //do_add_pages(); |
332 | //printk(KERN_ALERT "ERROR(bank_proc.c) = We don't have enough pages in bank_proc.c\n"); | 433 | //printk(KERN_ALERT "ERROR(bank_proc.c) = We don't have enough pages in bank_proc.c\n"); |
333 | } | 434 | } |
334 | 435 | */ | |
335 | return rPage; | 436 | return rPage; |
336 | } | 437 | } |
337 | 438 | ||
@@ -361,7 +462,8 @@ struct page *new_alloc_page(struct page *page, unsigned long node, int **x) | |||
361 | unsigned int color; | 462 | unsigned int color; |
362 | int try = 0; | 463 | int try = 0; |
363 | 464 | ||
364 | 465 | ||
466 | /* | ||
365 | unsigned int idx = 0; | 467 | unsigned int idx = 0; |
366 | idx += num_by_bitmask_index(set_partition[node], set_index[node]); | 468 | idx += num_by_bitmask_index(set_partition[node], set_index[node]); |
367 | idx += number_cachecolors* num_by_bitmask_index(bank_partition[node], bank_index[node]); | 469 | idx += number_cachecolors* num_by_bitmask_index(bank_partition[node], bank_index[node]); |
@@ -373,16 +475,41 @@ struct page *new_alloc_page(struct page *page, unsigned long node, int **x) | |||
373 | bank_index[node] = (bank_index[node]+1) % counting_one_set(bank_partition[node]); | 475 | bank_index[node] = (bank_index[node]+1) % counting_one_set(bank_partition[node]); |
374 | while (!rPage) { | 476 | while (!rPage) { |
375 | try++; | 477 | try++; |
376 | if (try>=64) | 478 | if (try>=256) |
377 | break; | 479 | break; |
378 | idx = 0; | 480 | idx = 0; |
379 | idx += num_by_bitmask_index(set_partition[node], set_index[node]); | 481 | idx += num_by_bitmask_index(set_partition[node], set_index[node]); |
380 | idx += number_cachecolors* num_by_bitmask_index(bank_partition[node], bank_index[node]); | 482 | idx += number_cachecolors* num_by_bitmask_index(bank_partition[node], bank_index[node]); |
483 | printk(KERN_ALERT "out of page! requesting node = %d, idx = %d\n", node, idx); | ||
381 | rPage = new_alloc_page_color(idx); | 484 | rPage = new_alloc_page_color(idx); |
382 | set_index[node] = (set_index[node]+1) % counting_one_set(set_partition[node]); | 485 | set_index[node] = (set_index[node]+1) % counting_one_set(set_partition[node]); |
383 | bank_index[node] = (bank_index[node]+1) % counting_one_set(bank_partition[node]); | 486 | bank_index[node] = (bank_index[node]+1) % counting_one_set(bank_partition[node]); |
384 | } | 487 | } |
385 | 488 | */ | |
489 | unsigned int idx; | ||
490 | |||
491 | if (node_index[node] == -1) | ||
492 | idx = first_index(node); | ||
493 | else | ||
494 | idx = node_index[node]; | ||
495 | |||
496 | BUG_ON(idx<0 || idx>127); | ||
497 | rPage = new_alloc_page_color(idx); | ||
498 | if (node_index[node] == last_index(node)) | ||
499 | node_index[node] = first_index(node); | ||
500 | else | ||
501 | node_index[node]++; | ||
502 | |||
503 | while (!rPage) { | ||
504 | try++; | ||
505 | if (try>=256) | ||
506 | break; | ||
507 | idx = get_next_index(node, idx); | ||
508 | printk(KERN_ALERT "try = %d out of page! requesting node = %d, idx = %d\n", try, node, idx); | ||
509 | BUG_ON(idx<0 || idx>127); | ||
510 | rPage = new_alloc_page_color(idx); | ||
511 | } | ||
512 | node_index[node] = idx; | ||
386 | return rPage; | 513 | return rPage; |
387 | } | 514 | } |
388 | 515 | ||