diff options
author | ChengYang Fu <chengyangfu@gmail.com> | 2015-03-27 14:27:42 -0400 |
---|---|---|
committer | ChengYang Fu <chengyangfu@gmail.com> | 2015-03-27 14:27:42 -0400 |
commit | 1bbe2730b0bd7755253ab8e5471699d3f2297d22 (patch) | |
tree | 14794a9eb35baf3796faac8f7a9b8eecc9767c2b | |
parent | 701f70e21800aabf5d5d6042fd105adf531843a4 (diff) |
make bank_proc be more robust
-rw-r--r-- | litmus/bank_proc.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/litmus/bank_proc.c b/litmus/bank_proc.c index 888b6a6542c5..e1025b5e4d7c 100644 --- a/litmus/bank_proc.c +++ b/litmus/bank_proc.c | |||
@@ -97,9 +97,10 @@ unsigned int counting_one_set(unsigned int v) | |||
97 | // unsigned int v; // count the number of bits set in v | 97 | // unsigned int v; // count the number of bits set in v |
98 | unsigned int c; // c accumulates the total bits set in v | 98 | unsigned int c; // c accumulates the total bits set in v |
99 | 99 | ||
100 | for (c = 0; v; v >>= 1) | 100 | for (c = 0; v; v = v>>1) |
101 | { | 101 | { |
102 | c += v & 1; | 102 | if(v&1) |
103 | c++; | ||
103 | } | 104 | } |
104 | return c; | 105 | return c; |
105 | } | 106 | } |
@@ -214,7 +215,7 @@ void add_page_to_color_list(struct page *page) | |||
214 | */ | 215 | */ |
215 | static int do_add_pages(void) | 216 | static int do_add_pages(void) |
216 | { | 217 | { |
217 | printk("LITMUS do add pages\n"); | 218 | // printk("LITMUS do add pages\n"); |
218 | 219 | ||
219 | struct page *page, *page_tmp; | 220 | struct page *page, *page_tmp; |
220 | LIST_HEAD(free_later); | 221 | LIST_HEAD(free_later); |
@@ -236,7 +237,7 @@ static int do_add_pages(void) | |||
236 | // page = alloc_pages_exact_node(0, GFP_HIGHUSER_MOVABLE, 0); | 237 | // page = alloc_pages_exact_node(0, GFP_HIGHUSER_MOVABLE, 0); |
237 | 238 | ||
238 | if (unlikely(!page)) { | 239 | if (unlikely(!page)) { |
239 | printk(KERN_WARNING "Could not allocate pages.\n"); | 240 | // printk(KERN_WARNING "Could not allocate pages.\n"); |
240 | ret = -ENOMEM; | 241 | ret = -ENOMEM; |
241 | goto out; | 242 | goto out; |
242 | } | 243 | } |
@@ -271,7 +272,7 @@ static int do_add_pages(void) | |||
271 | } | 272 | } |
272 | */ | 273 | */ |
273 | } | 274 | } |
274 | printk("page counter = \n"); | 275 | /*printk("page counter = \n"); |
275 | for (i=0; i<128; i++) | 276 | for (i=0; i<128; i++) |
276 | { | 277 | { |
277 | printk("(%03d) = %4d, ", i , counter[i]); | 278 | printk("(%03d) = %4d, ", i , counter[i]); |
@@ -280,6 +281,7 @@ static int do_add_pages(void) | |||
280 | } | 281 | } |
281 | 282 | ||
282 | } | 283 | } |
284 | */ | ||
283 | printk("After refill : \n"); | 285 | printk("After refill : \n"); |
284 | show_nr_pages(); | 286 | show_nr_pages(); |
285 | #if 1 | 287 | #if 1 |
@@ -357,18 +359,24 @@ struct page *new_alloc_page(struct page *page, unsigned long node, int **x) | |||
357 | struct color_group *cgroup; | 359 | struct color_group *cgroup; |
358 | struct page *rPage = NULL; | 360 | struct page *rPage = NULL; |
359 | unsigned int color; | 361 | unsigned int color; |
360 | 362 | unsigned int randvalue; | |
363 | get_random_bytes(&randvalue, sizeof(unsigned int)); | ||
364 | |||
361 | 365 | ||
362 | unsigned int idx = 0; | 366 | unsigned int idx = 0; |
363 | idx += num_by_bitmask_index(set_partition[node], set_index[node]); | 367 | // printk("set = %lx, counting %d\n", set_partition[node], counting_one_set(set_partition[node])); |
364 | idx += number_cachecolors* num_by_bitmask_index(bank_partition[node], bank_index[node]); | 368 | // printk("bank = %lx, counting %d\n", bank_partition[node], counting_one_set(bank_partition[node])); |
365 | //printk("node = %d, idx = %d\n", node, idx); | 369 | |
370 | |||
371 | idx += num_by_bitmask_index(set_partition[node], randvalue % counting_one_set(set_partition[node])); | ||
372 | idx += number_cachecolors* num_by_bitmask_index(bank_partition[node],randvalue % counting_one_set(bank_partition[node]) ); | ||
373 | // printk("node = %d, idx = %d\n", node, idx); | ||
366 | 374 | ||
367 | rPage = new_alloc_page_color(idx); | 375 | rPage = new_alloc_page_color(idx); |
368 | 376 | ||
369 | 377 | ||
370 | set_index[node] = (set_index[node]+1) % counting_one_set(set_partition[node]); | 378 | // set_index[node] = (set_index[node]+1) % counting_one_set(set_partition[node]); |
371 | bank_index[node] = (bank_index[node]+1) % counting_one_set(bank_partition[node]); | 379 | // bank_index[node] = (bank_index[node]+1) % counting_one_set(bank_partition[node]); |
372 | return rPage; | 380 | return rPage; |
373 | } | 381 | } |
374 | 382 | ||