First try at fixing rediculous COW problem
authorDavid Katz <dgk8293@vt.edu>
Wed, 21 May 2014 01:52:14 +0000 (21:52 -0400)
committerDavid Katz <dgk8293@vt.edu>
Wed, 21 May 2014 01:52:14 +0000 (21:52 -0400)
kernel/process_server.c
mm/mmap.c

index 38b08ea..05af244 100644 (file)
@@ -7303,6 +7303,25 @@ not_handled_no_perf:
     return 0;
 }
 
+/**
+ *  
+ */
+void break_all_cow_pages(struct task_struct* task) {
+    struct mm_struct* mm = task->mm;
+    struct vm_area_struct* curr = mm->mmap;
+    unsigned long i,start, end;
+    while(curr) {
+        if(is_maybe_cow(curr)) {
+            start = curr->vm_start;
+            end = curr->vm_end;
+            for(i = start; i < end; i += PAGE_SIZE) {
+                break_cow(mm,curr,i);
+            }
+        }
+        curr = curr->vm_next;
+    }
+}
+
 /**
  * @brief Propagate origin thread group to children, and initialize other 
  * task members.  If the parent was member of a remote thread group,
@@ -7352,6 +7371,12 @@ int process_server_dup_task(struct task_struct* orig, struct task_struct* task)
         task->tgroup_home_cpu = home_kernel;
         task->tgroup_home_id = task->tgid;
         task->tgroup_distributed = 0;
+
+        // COW problem fix, necessary for coherency.
+        if(orig->tgroup_distributed) {
+            break_all_cow_pages(task);
+        }
+
         return 1;
     }
 
index 3ec6042..908c989 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -985,7 +985,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
        /* Obtain the address to map to. we verify (or select) it and ensure
         * that it represents a valid section of the address space.
         */
-    if(addr) {
+    if(addr || !current->enable_do_mmap_pgoff_hook) {
         addr = get_unmapped_area(file, addr, len, pgoff, flags);
     } else {
         int pserv_conflict = 0;
@@ -1024,7 +1024,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
         } while(pserv_conflict);
     }
        if (addr & ~PAGE_MASK) {
-        if(range_locked) {
+        if(range_locked && current->enable_do_mmap_pgoff_hook) {
 #ifdef PROCESS_SERVER_USE_HEAVY_LOCK
             process_server_release_heavy_lock();
 #else