]> Zhao Yanbai Git Server - minix.git/commitdiff
vm: restore sanity checks in NONCONTIGUOUS case.
authorBen Gras <ben@minix3.org>
Mon, 19 Jul 2010 18:20:14 +0000 (18:20 +0000)
committerBen Gras <ben@minix3.org>
Mon, 19 Jul 2010 18:20:14 +0000 (18:20 +0000)
servers/vm/alloc.c

index 019053526fab14089f547e929bc741407d627e87..a040750130d9eaf035e4d30c0f6d8b70f19ed68f 100644 (file)
@@ -421,6 +421,17 @@ PRIVATE PUBLIC phys_bytes alloc_pages(int pages, int memflags, phys_bytes *len)
        int finalnodes, finalpages;
        int largest;
 
+#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
+
        memstats(&firstnodes, &firstpages, &largest);
        sanitycheck();
        wantnodes = firstnodes;
@@ -435,17 +446,6 @@ 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);
@@ -921,8 +921,10 @@ struct memlist *alloc_mem_in_list(phys_bytes bytes, u32_t flags)
                        ml->phys = CLICK2ABS(mem);
                        ml->length = CLICK2ABS(gotpages);
                        ml->next = NULL;);
-               if(tail)
-                       tail->next = ml;
+               if(tail) {
+                       USE(tail,
+                               tail->next = ml;);
+               }
                tail = ml;
                if(!head)
                        head = ml;