aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChengYang Fu <chengyangfu@gmail.com>2015-03-25 10:59:55 -0400
committerChengYang Fu <chengyangfu@gmail.com>2015-03-25 10:59:55 -0400
commitf441fa3f923ccb825d9888c8a75c033a67316d91 (patch)
treed66c46b4594f1880e8d516a6e18092931352090e
parent6941230b519e96be0ea464206e795046c0938d01 (diff)
add reclaim_page function in bank_proc.c to recyle all the pages.
And only do_add_pages in the kernel booting stage
-rw-r--r--litmus/bank_proc.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/litmus/bank_proc.c b/litmus/bank_proc.c
index 2688d79b353f..9771529876b6 100644
--- a/litmus/bank_proc.c
+++ b/litmus/bank_proc.c
@@ -38,6 +38,7 @@ unsigned int bank_partition_max = 0x000000ff;
38unsigned int bank_partition_min = 0; 38unsigned int bank_partition_min = 0;
39 39
40int show_page_pool = 0; 40int show_page_pool = 0;
41spinlock_t reclaim_lock;
41 42
42unsigned int set_partition[9] = { 43unsigned int set_partition[9] = {
43 0x00000003, /* Core 0, and Level A*/ 44 0x00000003, /* Core 0, and Level A*/
@@ -227,7 +228,7 @@ static int do_add_pages(void)
227 228
228 // until all the page lists contain enough pages 229 // until all the page lists contain enough pages
229 //for (i =0; i<5; i++) { 230 //for (i =0; i<5; i++) {
230 for (i=0; i< 1024*100;i++) { 231 for (i=0; i< 1024*200;i++) {
231// while (smallest_nr_pages() < PAGES_PER_COLOR) { 232// while (smallest_nr_pages() < PAGES_PER_COLOR) {
232 // printk("smallest = %d\n", smallest_nr_pages()); 233 // printk("smallest = %d\n", smallest_nr_pages());
233 page = alloc_page(GFP_HIGHUSER_MOVABLE); 234 page = alloc_page(GFP_HIGHUSER_MOVABLE);
@@ -243,7 +244,7 @@ static int do_add_pages(void)
243 // printk("page(%d) = color %x, bank %x, [color] =%d \n", color, page_color(page), page_bank(page), atomic_read(&color_groups[color].nr_pages)); 244 // printk("page(%d) = color %x, bank %x, [color] =%d \n", color, page_color(page), page_bank(page), atomic_read(&color_groups[color].nr_pages));
244 //show_nr_pages(); 245 //show_nr_pages();
245 //if (atomic_read(&color_groups[color].nr_pages) < PAGES_PER_COLOR && color>=32) { 246 //if (atomic_read(&color_groups[color].nr_pages) < PAGES_PER_COLOR && color>=32) {
246 if ( PAGES_PER_COLOR && color>=32) { 247 if ( PAGES_PER_COLOR && color>=16*2) {
247 add_page_to_color_list(page); 248 add_page_to_color_list(page);
248 // printk("add page(%d) = color %x, bank %x\n", color, page_color(page), page_bank(page)); 249 // printk("add page(%d) = color %x, bank %x\n", color, page_color(page), page_bank(page));
249 } else{ 250 } else{
@@ -319,7 +320,7 @@ static struct page *new_alloc_page_color( unsigned long color)
319 } 320 }
320 rPage = list_first_entry(&cgroup->list, struct page, lru); 321 rPage = list_first_entry(&cgroup->list, struct page, lru);
321 BUG_ON(page_count(rPage) > 1); 322 BUG_ON(page_count(rPage) > 1);
322// get_page(rPage); 323 get_page(rPage);
323 list_del(&rPage->lru); 324 list_del(&rPage->lru);
324 atomic_dec(&cgroup->nr_pages); 325 atomic_dec(&cgroup->nr_pages);
325 ClearPageLRU(rPage); 326 ClearPageLRU(rPage);
@@ -327,7 +328,11 @@ out_unlock:
327 spin_unlock(&cgroup->lock); 328 spin_unlock(&cgroup->lock);
328out: 329out:
329 if( smallest_nr_pages() == 0) 330 if( smallest_nr_pages() == 0)
330 do_add_pages(); 331 {
332// do_add_pages();
333 printk("ERROR(bank_proc.c) = We don't have enough pages in bank_proc.c\n");
334
335 }
331 return rPage; 336 return rPage;
332} 337}
333 338
@@ -367,6 +372,20 @@ struct page *new_alloc_page(struct page *page, unsigned long node, int **x)
367} 372}
368 373
369 374
375/*
376 * Reclaim pages.
377 */
378void reclaim_page(struct page *page)
379{
380 const unsigned long color = page_list_index(page);
381 unsigned long nr_reclaimed = 0;
382 spin_lock(&reclaim_lock);
383 put_page(page);
384 add_page_to_color_list(page);
385
386 spin_unlock(&reclaim_lock);
387 printk("Reclaimed page(%d) = color %x, bank %x, [color] =%d \n", color, page_color(page), page_bank(page), atomic_read(&color_groups[color].nr_pages));
388}
370 389
371 390
372/* 391/*
@@ -382,6 +401,8 @@ static int __init init_variables(void)
382 NUM_PAGE_LIST = number_banks * number_cachecolors; 401 NUM_PAGE_LIST = number_banks * number_cachecolors;
383 printk(KERN_WARNING "number of banks = %d, number of cachecolors=%d\n", number_banks, number_cachecolors); 402 printk(KERN_WARNING "number of banks = %d, number of cachecolors=%d\n", number_banks, number_cachecolors);
384 mutex_init(&void_lockdown_proc); 403 mutex_init(&void_lockdown_proc);
404 spin_lock_init(&reclaim_lock);
405
385} 406}
386 407
387 408
@@ -663,8 +684,6 @@ static int __init litmus_color_init(void)
663 int err=0; 684 int err=0;
664 printk("Init bankproc.c\n"); 685 printk("Init bankproc.c\n");
665 686
666 //INIT_LIST_HEAD(&alloced_pages.list);
667 //spin_lock_init(&alloced_pages.lock);
668 init_variables(); 687 init_variables();
669 688
670 printk(KERN_INFO "Registering LITMUS^RT proc color sysctl.\n"); 689 printk(KERN_INFO "Registering LITMUS^RT proc color sysctl.\n");