]> Zhao Yanbai Git Server - minix.git/commitdiff
vm: NONCONTIGUOUS - try to make physical memory as maximally noncontiguous
authorBen Gras <ben@minix3.org>
Fri, 9 Jul 2010 12:22:33 +0000 (12:22 +0000)
committerBen Gras <ben@minix3.org>
Fri, 9 Jul 2010 12:22:33 +0000 (12:22 +0000)
servers/vm/alloc.c
servers/vm/vm.h

index a2c249c670da561367a0542a8bb067ef92ba83e9..019053526fab14089f547e929bc741407d627e87 100644 (file)
@@ -435,6 +435,17 @@ PRIVATE PUBLIC phys_bytes alloc_pages(int pages, int memflags, phys_bytes *len)
                incr = 0;
        }
 
+#if NONCONTIGUOUS
+       /* If NONCONTIGUOUS is on, allocate physical pages single
+        * pages at a time, accomplished by returning single pages
+        * if the caller can handle that (indicated by PAF_FIRSTBLOCK).
+        */
+       if(memflags & PAF_FIRSTBLOCK) {
+               assert(!(memflags & PAF_CONTIG));
+               pages = 1;
+       }
+#endif
+
        while((pr = addr_get_iter(&iter))) {
                SLABSANE(pr);
                assert(pr->size > 0);
@@ -862,7 +873,7 @@ int usedpages_add_f(phys_bytes addr, phys_bytes len, char *file, int line)
 struct memlist *alloc_mem_in_list(phys_bytes bytes, u32_t flags)
 {
        phys_bytes rempages;
-       struct memlist *head = NULL, *ml;
+       struct memlist *head = NULL, *tail = NULL;
 
        assert(bytes > 0);
        assert(!(bytes % VM_PAGE_SIZE));
@@ -909,15 +920,29 @@ struct memlist *alloc_mem_in_list(phys_bytes bytes, u32_t flags)
                USE(ml,
                        ml->phys = CLICK2ABS(mem);
                        ml->length = CLICK2ABS(gotpages);
-                       ml->next = head;);
-               head = ml;
+                       ml->next = NULL;);
+               if(tail)
+                       tail->next = ml;
+               tail = ml;
+               if(!head)
+                       head = ml;
                rempages -= gotpages;
        } while(rempages > 0);
 
+    {
+       struct memlist *ml;
        for(ml = head; ml; ml = ml->next) {
                assert(ml->phys);
                assert(ml->length);
+#if NONCONTIGUOUS
+               if(!(flags & PAF_CONTIG)) {
+                       assert(ml->length == VM_PAGE_SIZE);
+                       if(ml->next)
+                               assert(ml->phys + ml->length != ml->next->phys);
+               }
+#endif
        }
+    }
 
        return head;
 }
index f3d9b57220a69da16c9caca2388a243a9f99b5da..e8eaade383eac326e99ecb171810a1608b2be468 100644 (file)
 /* Compile in asserts and custom sanity checks at all? */
 #define SANITYCHECKS   0
 #define VMSTATS                0
+
+/* VM behaviour */
 #define JUNKFREE       0       /* Fill freed pages with junk */
+#define NONCONTIGUOUS  0       /* Make phys pages max. noncontiguous */
 
 /* How noisy are we supposed to be? */
 #define VERBOSE                0