From 68b02e658468fa932f6f993454c910817aae8579 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 19 Feb 2015 23:20:53 +0000 Subject: [PATCH] bankfixed: adopt panic behaviour of other map types on swap bug --- Kernel/bankfixed.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/Kernel/bankfixed.c b/Kernel/bankfixed.c index a38e909e..c0f2445b 100644 --- a/Kernel/bankfixed.c +++ b/Kernel/bankfixed.c @@ -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 -- 2.34.1