aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamhoon Kim <namhoonk@cs.unc.edu>2016-09-30 04:15:27 -0400
committerNamhoon Kim <namhoonk@cs.unc.edu>2016-09-30 04:15:27 -0400
commit4172fff1a3870af7d65675e05eb0b7aba3804ea8 (patch)
tree07a9a55df4a74622f99aa15841b8513341d7399b
parent267b5fb8e3786eee621d434e4892020edd0fdf72 (diff)
Support Multiple replica
-rw-r--r--include/litmus/replicate_lib.h4
-rw-r--r--litmus/litmus.c11
-rw-r--r--mm/migrate.c18
3 files changed, 19 insertions, 14 deletions
diff --git a/include/litmus/replicate_lib.h b/include/litmus/replicate_lib.h
index 16db7d81b66b..773468497416 100644
--- a/include/litmus/replicate_lib.h
+++ b/include/litmus/replicate_lib.h
@@ -7,9 +7,9 @@
7 7
8struct shared_lib_page { 8struct shared_lib_page {
9 struct page *master_page; 9 struct page *master_page;
10 struct page *r_page; 10 struct page *r_page[NR_CPUS];
11 unsigned long int master_pfn; 11 unsigned long int master_pfn;
12 unsigned long int r_pfn; 12 unsigned long int r_pfn[NR_CPUS];
13 struct list_head list; 13 struct list_head list;
14}; 14};
15 15
diff --git a/litmus/litmus.c b/litmus/litmus.c
index 652e70df69bb..11e4c5da9c10 100644
--- a/litmus/litmus.c
+++ b/litmus/litmus.c
@@ -429,11 +429,16 @@ asmlinkage long sys_set_page_color(int cpu)
429 rcu_read_unlock(); 429 rcu_read_unlock();
430 430
431 if (is_exist == 0) { 431 if (is_exist == 0) {
432 int cpu_i;
432 lib_page = kmalloc(sizeof(struct shared_lib_page), GFP_KERNEL); 433 lib_page = kmalloc(sizeof(struct shared_lib_page), GFP_KERNEL);
433 lib_page->master_page = old_page; 434 lib_page->master_page = old_page;
434 lib_page->r_page = NULL; 435 //lib_page->r_page = NULL;
435 lib_page->master_pfn = page_to_pfn(old_page); 436 lib_page->master_pfn = page_to_pfn(old_page);
436 lib_page->r_pfn = INVALID_PFN; 437 //lib_page->r_pfn = INVALID_PFN;
438 for (cpu_i = 0; cpu_i < NR_CPUS; cpu_i++) {
439 lib_page->r_page[cpu_i] = NULL;
440 lib_page->r_pfn[cpu_i] = INVALID_PFN;
441 }
437 list_add_tail(&lib_page->list, &shared_lib_pages); 442 list_add_tail(&lib_page->list, &shared_lib_pages);
438 TRACE_TASK(current, "NEW PAGE %05lx ADDED.\n", lib_page->master_pfn); 443 TRACE_TASK(current, "NEW PAGE %05lx ADDED.\n", lib_page->master_pfn);
439 } 444 }
@@ -551,7 +556,7 @@ asmlinkage long sys_set_page_color(int cpu)
551 rcu_read_lock(); 556 rcu_read_lock();
552 list_for_each_entry(lpage, &shared_lib_pages, list) 557 list_for_each_entry(lpage, &shared_lib_pages, list)
553 { 558 {
554 TRACE_TASK(current, "master_PFN = %05lx r_PFN = %05lx PageSwapCache=%d\n", lpage->master_pfn, lpage->r_pfn, PageSwapCache(lpage->master_page)); 559 TRACE_TASK(current, "master_PFN = %05lx r_PFN = %05lx, %05lx, %05lx, %05lx\n", lpage->master_pfn, lpage->r_pfn[0], lpage->r_pfn[1], lpage->r_pfn[2], lpage->r_pfn[3]);
555 } 560 }
556 rcu_read_unlock(); 561 rcu_read_unlock();
557 } 562 }
diff --git a/mm/migrate.c b/mm/migrate.c
index 0df1841282eb..d25cc2c2736d 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1398,29 +1398,29 @@ static ICE_noinline int unmap_and_copy(new_page_t get_new_page,
1398 int *result = NULL; 1398 int *result = NULL;
1399 struct page *newpage; 1399 struct page *newpage;
1400 struct shared_lib_page *lib_page; 1400 struct shared_lib_page *lib_page;
1401 int is_exist_in_psl = 0, has_replica = 0; 1401 int master_exist_in_psl = 0, has_replica = 0, cpu = private/2;
1402 1402
1403 /* check if this page is in the PSL list */ 1403 /* check if this page is in the PSL list */
1404 rcu_read_lock(); 1404 rcu_read_lock();
1405 list_for_each_entry(lib_page, &shared_lib_pages, list) 1405 list_for_each_entry(lib_page, &shared_lib_pages, list)
1406 { 1406 {
1407 if (page_to_pfn(page) == lib_page->master_pfn) { 1407 if (page_to_pfn(page) == lib_page->master_pfn) {
1408 is_exist_in_psl = 1; 1408 master_exist_in_psl = 1;
1409 break; 1409 break;
1410 } 1410 }
1411 } 1411 }
1412 rcu_read_unlock(); 1412 rcu_read_unlock();
1413 1413
1414 if (is_exist_in_psl) 1414 if (master_exist_in_psl)
1415 TRACE_TASK(current, "Page %x exists in PSL list\n", lib_page->master_pfn); 1415 TRACE_TASK(current, "Page %05lx exists in PSL list\n", lib_page->master_pfn);
1416 1416
1417 if (lib_page->r_page == NULL) { 1417 if (lib_page->r_page[cpu] == NULL) {
1418 newpage = get_new_page(page, private, &result); 1418 newpage = get_new_page(page, private, &result);
1419 if (!newpage) 1419 if (!newpage)
1420 return -ENOMEM; 1420 return -ENOMEM;
1421 //printk(KERN_ERR "Page %lx allocated\n", page_to_pfn(newpage)); 1421 //printk(KERN_ERR "Page %lx allocated\n", page_to_pfn(newpage));
1422 } else { 1422 } else {
1423 newpage = lib_page->r_page; 1423 newpage = lib_page->r_page[cpu];
1424 has_replica = 1; 1424 has_replica = 1;
1425 //printk(KERN_ERR "Page %lx found\n", page_to_pfn(newpage)); 1425 //printk(KERN_ERR "Page %lx found\n", page_to_pfn(newpage));
1426 } 1426 }
@@ -1438,8 +1438,8 @@ static ICE_noinline int unmap_and_copy(new_page_t get_new_page,
1438 rc = __unmap_and_copy(page, newpage, force, mode, has_replica); 1438 rc = __unmap_and_copy(page, newpage, force, mode, has_replica);
1439 1439
1440 if (has_replica == 0 && rc == MIGRATEPAGE_SUCCESS) { 1440 if (has_replica == 0 && rc == MIGRATEPAGE_SUCCESS) {
1441 lib_page->r_page = newpage; 1441 lib_page->r_page[cpu] = newpage;
1442 lib_page->r_pfn = page_to_pfn(newpage); 1442 lib_page->r_pfn[cpu] = page_to_pfn(newpage);
1443 } 1443 }
1444 1444
1445out: 1445out: