Re: free_page_and_swap_cache sleeps (so sleep also zap_page_range)

Andrea Arcangeli (andrea@suse.de)
Tue, 29 Jun 1999 18:41:11 +0200 (CEST)


On Tue, 29 Jun 1999, Andrea Arcangeli wrote:

>The trivial fix is to not release the pagecache from zap_page_range (and
>left this task only to shrink_mmap). I am not convinced if that's what we
>want though...

Thinking only a bit more we can do something better with this other
simpler approch: "go ahead only if you don't need to sleep".

(patch untested)

Index: linux/mm/swap_state.c
===================================================================
RCS file: /var/cvs/linux/mm/swap_state.c,v
retrieving revision 1.1.1.8
diff -u -r1.1.1.8 swap_state.c
--- linux/mm/swap_state.c 1999/06/28 15:10:10 1.1.1.8
+++ linux/mm/swap_state.c 1999/06/29 16:37:04
@@ -265,14 +265,13 @@
/*
* If we are the only user, then free up the swap cache.
*/
- lock_page(page);
- if (PageSwapCache(page) && !is_page_shared(page)) {
+ if (!TryLockPage(page) && PageSwapCache(page) && !is_page_shared(page)) {
long entry = page->offset;
remove_from_swap_cache(page);
swap_free(entry);
page_cache_release(page);
+ UnlockPage(page);
}
- UnlockPage(page);

__free_page(page);
}

Andrea

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/