]> Devi Nivas Git - cs3210-lab1.git/commitdiff
Skip missing page directories in deallocuvm
authorAustin Clements <amdragon@mit.edu>
Fri, 2 Sep 2011 01:29:09 +0000 (21:29 -0400)
committerAustin Clements <amdragon@mit.edu>
Fri, 2 Sep 2011 01:29:09 +0000 (21:29 -0400)
Previously, deallocuvm scanned from 0 to KERNBASE in one page
increments, which had a noticable effect on boot time.  Now it skips
over missing page directories.

vm.c

diff --git a/vm.c b/vm.c
index c717baf7457907591db98383df304e220c930edf..181b3763aae6ca6165970159b013697016d67f79 100644 (file)
--- a/vm.c
+++ b/vm.c
@@ -261,7 +261,9 @@ deallocuvm(pde_t *pgdir, uint oldsz, uint newsz)
   a = PGROUNDUP(newsz);
   for(; a  < oldsz; a += PGSIZE){
     pte = walkpgdir(pgdir, (char*)a, 0);
-    if(pte && (*pte & PTE_P) != 0){
+    if(!pte)
+      a += (NPTENTRIES - 1) * PGSIZE;
+    else if((*pte & PTE_P) != 0){
       pa = PTE_ADDR(*pte);
       if(pa == 0)
         panic("kfree");