Subject: Re: pre12 VM doubts and patch
From: Hugh Dickins <[email-masked]>
To: Andrea Arcangeli <[email-masked]>
Cc: Linus Torvalds <[email-masked]>, Marcelo Tosatti <[email-masked]>, [email-masked]
Date: Wed, 19 Sep 2001 20:42:39 +0100 (BST)

On Wed, 19 Sep 2001, Hugh Dickins wrote:
> 
> thank you.  A few doubts: in the first case I've appended a patch; for
> the rest you may prefer to make your own patch, or ask me for patch,
> or reject my doubts.

Please add another:

6. Why has swap_writepage lost its check for stale entries?  If your
   other changes have somehow made that too rare a case to bother
   about, please remove the comment above swap_writepage instead.

Hugh

--- 2.4.10-pre12/mm/swap_state.c	Wed Sep 19 14:05:54 2001
+++ linux/mm/swap_state.c	Mon Sep 17 06:30:26 2001
@@ -23,6 +23,17 @@
  */
 static int swap_writepage(struct page *page)
 {
+	/* One for the page cache, one for this user, one for page->buffers */
+	if (page_count(page) > 2 + !!page->buffers)
+		goto in_use;
+	if (swap_count(page) > 1)
+		goto in_use;
+
+	delete_from_swap_cache_nolock(page);
+	UnlockPage(page);
+	return 0;
+
+in_use:
 	rw_swap_page(WRITE, page);
 	return 0;
 }