From: Ben Gras Date: Mon, 19 Jul 2010 18:20:14 +0000 (+0000) Subject: vm: restore sanity checks in NONCONTIGUOUS case. X-Git-Tag: v3.1.8~188 X-Git-Url: http://zhaoyanbai.com/repos/rndc-confgen.html?a=commitdiff_plain;h=16d0609fad8292624fa9cd9b3f715ef0962cc94b;p=minix.git vm: restore sanity checks in NONCONTIGUOUS case. --- diff --git a/servers/vm/alloc.c b/servers/vm/alloc.c index 019053526..a04075013 100644 --- a/servers/vm/alloc.c +++ b/servers/vm/alloc.c @@ -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;