aboutsummaryrefslogtreecommitdiffstats
path: root/litmus
diff options
context:
space:
mode:
Diffstat (limited to 'litmus')
-rw-r--r--litmus/litmus.c60
-rw-r--r--litmus/replicate_lib.c2
2 files changed, 51 insertions, 11 deletions
diff --git a/litmus/litmus.c b/litmus/litmus.c
index 402c495f62c6..8e7f5e2e68df 100644
--- a/litmus/litmus.c
+++ b/litmus/litmus.c
@@ -353,6 +353,10 @@ extern void putback_movable_page(struct page *page);
353extern struct page *new_alloc_page(struct page *page, unsigned long node, int **x); 353extern struct page *new_alloc_page(struct page *page, unsigned long node, int **x);
354 354
355DECLARE_PER_CPU(struct list_head, shared_lib_page_list); 355DECLARE_PER_CPU(struct list_head, shared_lib_page_list);
356#define INVALID_PFN (0xffffffff)
357LIST_HEAD(shared_lib_pages);
358//struct list_head shared_lib_pages = LIST_HEAD_INIT(shared_lib_pages);
359EXPORT_SYMBOL(shared_lib_pages);
356 360
357asmlinkage long sys_set_page_color(int cpu) 361asmlinkage long sys_set_page_color(int cpu)
358{ 362{
@@ -366,8 +370,8 @@ asmlinkage long sys_set_page_color(int cpu)
366 //struct list_head *shared_pagelist = this_cpu_ptr(&shared_lib_page_list); 370 //struct list_head *shared_pagelist = this_cpu_ptr(&shared_lib_page_list);
367 371
368 LIST_HEAD(pagelist); 372 LIST_HEAD(pagelist);
369 LIST_HEAD(shared_pagelist); 373 LIST_HEAD(task_shared_pagelist);
370 374
371 migrate_prep(); 375 migrate_prep();
372 376
373 rcu_read_lock(); 377 rcu_read_lock();
@@ -408,10 +412,36 @@ asmlinkage long sys_set_page_color(int cpu)
408 412
409 if (page_count(old_page) > 2 && vma_itr->vm_file != NULL && !(vma_itr->vm_flags&VM_WRITE)) { 413 if (page_count(old_page) > 2 && vma_itr->vm_file != NULL && !(vma_itr->vm_flags&VM_WRITE)) {
410 struct shared_lib_page *lib_page; 414 struct shared_lib_page *lib_page;
411 lib_page = kmalloc(sizeof(struct shared_lib_page), GFP_KERNEL); 415 int is_exist = 0;
412 lib_page->p_page = old_page; 416
413 lib_page->pfn = page_to_pfn(old_page); 417 /* update PSL list */
414 list_add_tail(&lib_page->list, &shared_pagelist); 418 /* check if this page is in the PSL list */
419 rcu_read_lock();
420 list_for_each_entry(lib_page, &shared_lib_pages, list)
421 {
422 if (page_to_pfn(old_page) == lib_page->p_pfn) {
423 is_exist = 1;
424 break;
425 }
426 }
427 rcu_read_unlock();
428
429 if (is_exist == 0) {
430 lib_page = kmalloc(sizeof(struct shared_lib_page), GFP_KERNEL);
431 lib_page->p_page = old_page;
432 lib_page->r_page = NULL;
433 lib_page->p_pfn = page_to_pfn(old_page);
434 lib_page->r_pfn = INVALID_PFN;
435 list_add_tail(&lib_page->list, &shared_lib_pages);
436 TRACE_TASK(current, "NEW PAGE %ld ADDED.\n", lib_page->p_pfn);
437 }
438 else {
439 TRACE_TASK(current, "FOUND PAGE %ld in the list.\n", lib_page->p_pfn);
440 }
441
442 /* add to task_shared_pagelist */
443 list_add_tail(&old_page->lru, &task_shared_pagelist);
444
415 nr_shared_pages++; 445 nr_shared_pages++;
416 TRACE_TASK(current, "SHARED\n"); 446 TRACE_TASK(current, "SHARED\n");
417 } 447 }
@@ -428,7 +458,7 @@ asmlinkage long sys_set_page_color(int cpu)
428 } 458 }
429 //printk(KERN_INFO "PRIVATE _mapcount = %d, _count = %d\n", page_mapcount(old_page), page_count(old_page)); 459 //printk(KERN_INFO "PRIVATE _mapcount = %d, _count = %d\n", page_mapcount(old_page), page_count(old_page));
430 put_page(old_page); 460 put_page(old_page);
431 TRACE_TASK(current, "PRIVATE\n"); 461 //TRACE_TASK(current, "PRIVATE\n");
432 } 462 }
433 } 463 }
434 TRACE_TASK(current, "PAGES_IN_VMA = %d size = %d KB\n", pages_in_vma, pages_in_vma*4); 464 TRACE_TASK(current, "PAGES_IN_VMA = %d size = %d KB\n", pages_in_vma, pages_in_vma*4);
@@ -454,13 +484,21 @@ asmlinkage long sys_set_page_color(int cpu)
454 if (!list_empty(&pagelist)) { 484 if (!list_empty(&pagelist)) {
455 ret = migrate_pages(&pagelist, new_alloc_page, NULL, node, MIGRATE_SYNC, MR_SYSCALL); 485 ret = migrate_pages(&pagelist, new_alloc_page, NULL, node, MIGRATE_SYNC, MR_SYSCALL);
456 TRACE_TASK(current, "%ld pages not migrated.\n", ret); 486 TRACE_TASK(current, "%ld pages not migrated.\n", ret);
457 printk(KERN_INFO "%ld pages not migrated.\n", ret);
458 nr_not_migrated = ret; 487 nr_not_migrated = ret;
459 if (ret) { 488 if (ret) {
460 putback_movable_pages(&pagelist); 489 putback_movable_pages(&pagelist);
461 } 490 }
462 } 491 }
463 492
493 if (!list_empty(&task_shared_pagelist)) {
494 ret = replicate_pages(&task_shared_pagelist, new_alloc_page, NULL, node, MIGRATE_SYNC, MR_SYSCALL);
495 TRACE_TASK(current, "%ld shared pages not migrated.\n", ret);
496 nr_not_migrated += ret;
497 if (ret) {
498 putback_movable_pages(&task_shared_pagelist);
499 }
500 }
501
464 /* handle sigpage and litmus ctrl_page */ 502 /* handle sigpage and litmus ctrl_page */
465/* vma_itr = current->mm->mmap; 503/* vma_itr = current->mm->mmap;
466 while (vma_itr != NULL) { 504 while (vma_itr != NULL) {
@@ -480,14 +518,14 @@ asmlinkage long sys_set_page_color(int cpu)
480 518
481 flush_cache(1); 519 flush_cache(1);
482/* for debug START */ 520/* for debug START */
483 TRACE_TASK(current, "SHARED PAGES\n"); 521 TRACE_TASK(current, "PSL PAGES\n");
484 { 522 {
485 struct shared_lib_page *lpage; 523 struct shared_lib_page *lpage;
486 524
487 rcu_read_lock(); 525 rcu_read_lock();
488 list_for_each_entry(lpage, &shared_pagelist, list) 526 list_for_each_entry(lpage, &shared_lib_pages, list)
489 { 527 {
490 TRACE_TASK(current, "PFN = %ld\n", lpage->pfn); 528 TRACE_TASK(current, "p_PFN = %ld r_PFN = %ld\n", lpage->p_pfn, lpage->r_pfn);
491 } 529 }
492 rcu_read_unlock(); 530 rcu_read_unlock();
493 } 531 }
diff --git a/litmus/replicate_lib.c b/litmus/replicate_lib.c
index 7aa240058ef5..cfc525809412 100644
--- a/litmus/replicate_lib.c
+++ b/litmus/replicate_lib.c
@@ -25,6 +25,8 @@ DEFINE_PER_CPU(struct list_head, shared_lib_page_list);
25#define shared_lib_pages_for(cpu_id) (&per_cpu(shared_lib_page_list, cpu_id)) 25#define shared_lib_pages_for(cpu_id) (&per_cpu(shared_lib_page_list, cpu_id))
26#define local_shared_lib_pages() (this_cpu_ptr(&shared_lib_page_list)) 26#define local_shared_lib_pages() (this_cpu_ptr(&shared_lib_page_list))
27 27
28#define INVALID_PFN (0xffffffff)
29
28static int __init litmus_replicate_lib_init(void) 30static int __init litmus_replicate_lib_init(void)
29{ 31{
30 int cpu, ret = 0; 32 int cpu, ret = 0;