patch-2.4.22 linux-2.4.22/mm/swapfile.c
Next file: linux-2.4.22/mm/vmalloc.c
Previous file: linux-2.4.22/mm/shmem.c
Back to the patch index
Back to the overall index
- Lines: 60
- Date:
2003-08-25 04:44:44.000000000 -0700
- Orig file:
linux-2.4.21/mm/swapfile.c
- Orig date:
2003-06-13 07:51:39.000000000 -0700
diff -urN linux-2.4.21/mm/swapfile.c linux-2.4.22/mm/swapfile.c
@@ -521,6 +521,7 @@
int i = 0;
int retval = 0;
int reset_overflow = 0;
+ int shmem;
/*
* When searching mms for an entry, a good strategy is to
@@ -599,11 +600,12 @@
* Whenever we reach init_mm, there's no address space
* to search, but use it as a reminder to search shmem.
*/
+ shmem = 0;
swcount = *swap_map;
if (swcount > 1) {
flush_page_to_ram(page);
if (start_mm == &init_mm)
- shmem_unuse(entry, page);
+ shmem = shmem_unuse(entry, page);
else
unuse_process(start_mm, entry, page);
}
@@ -620,7 +622,9 @@
swcount = *swap_map;
if (mm == &init_mm) {
set_start_mm = 1;
- shmem_unuse(entry, page);
+ spin_unlock(&mmlist_lock);
+ shmem = shmem_unuse(entry, page);
+ spin_lock(&mmlist_lock);
} else
unuse_process(mm, entry, page);
if (set_start_mm && *swap_map < swcount) {
@@ -669,14 +673,23 @@
* read from disk into another page. Splitting into two
* pages would be incorrect if swap supported "shared
* private" pages, but they are handled by tmpfs files.
- * Note shmem_unuse already deleted its from swap cache.
+ *
+ * Note shmem_unuse already deleted swappage from cache,
+ * unless corresponding filepage found already in cache:
+ * in which case it left swappage in cache, lowered its
+ * swap count to pass quickly through the loops above,
+ * and now we must reincrement count to try again later.
*/
if ((*swap_map > 1) && PageDirty(page) && PageSwapCache(page)) {
rw_swap_page(WRITE, page);
lock_page(page);
}
- if (PageSwapCache(page))
- delete_from_swap_cache(page);
+ if (PageSwapCache(page)) {
+ if (shmem)
+ swap_duplicate(entry);
+ else
+ delete_from_swap_cache(page);
+ }
/*
* So we could skip searching mms once swap count went
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)