bankfixed: adopt panic behaviour of other map types on swap bug
authorAlan Cox <alan@linux.intel.com>
Thu, 19 Feb 2015 23:20:53 +0000 (23:20 +0000)
committerAlan Cox <alan@linux.intel.com>
Thu, 19 Feb 2015 23:20:53 +0000 (23:20 +0000)
Kernel/bankfixed.c

index a38e909..c0f2445 100644 (file)
@@ -81,6 +81,7 @@ uint16_t pagemap_mem_used(void)
        return (pfmax - pfptr) * (MAP_SIZE >> 10);
 }
 
+#ifdef SWAPDEV
 /*
  *     Swap out the memory of a process to make room
  *     for something else
@@ -93,29 +94,24 @@ int swapout(ptptr p)
 
        swapproc = p;
 
-       if (page) {
-#ifdef DEBUG
-               kprintf("Swapping out %x (%d)\n", p, p->p_page);
-#endif
-               /* Are we out of swap ? */
-               map = swapmap_alloc();
-               if (map == 0)
-                       return ENOMEM;
-                flush_cache(p);
-               blk = map * SWAP_SIZE;
-               /* Write the app (and possibly the uarea etc..) to disk */
-               swapwrite(SWAPDEV, blk, SWAPTOP - SWAPBASE,
-                         SWAPBASE);
-               pagemap_free(p);
-               p->p_page = 0;
-               p->p_page2 = map;
+       if (!page)
+               panic("%x: process already swapped!\n", p);
 #ifdef DEBUG
-               kprintf("%x: swapout done %d\n", p, p->p_page);
+       kprintf("Swapping out %x (%d)\n", p, p->p_page);
 #endif
-       }
+       /* Are we out of swap ? */
+       map = swapmap_alloc();
+       if (map == 0)
+               return ENOMEM;
+       blk = map * SWAP_SIZE;
+       /* Write the app (and possibly the uarea etc..) to disk */
+       swapwrite(SWAPDEV, blk, SWAPTOP - SWAPBASE,
+                 SWAPBASE);
+       pagemap_free(p);
+       p->p_page = 0;
+       p->p_page2 = map;
 #ifdef DEBUG
-       else
-               kprintf("%x: process already swapped!\n", p);
+       kprintf("%x: swapout done %d\n", p, p->p_page);
 #endif
        return 0;
 }
@@ -147,3 +143,5 @@ void swapin(ptptr p)
 }
 
 #endif
+
+#endif