linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: Marcelo Tosatti <marcelo@conectiva.com.br>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>, linux-kernel@vger.kernel.org
Subject: [PATCH] swap 2/4 unsafe SwapCache check
Date: Wed, 12 Jun 2002 04:05:31 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.21.0206120403280.1036-100000@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.21.0206120359270.1036-100000@localhost.localdomain>

Recent testing has shown that the BUG() check in try_to_unuse is unsafe.
delete_from_swap_cache does final swap_free just after removing page
from swap cache, and add_to_swap_cache does swap_duplicate just before
putting page into swap cache, therefore swapin_readahead may resurrect
a dying swap entry and assign a new page to it.  That's fine, there's
no need to change this ordering; but it does mean that try_to_unuse's
page may have left the swap cache yet its swap_map count still be set.
That BUG() has done good service for swapoff sanity, but now abandon it.

--- 2.4.19-pre10/mm/swapfile.c	Tue Jun  4 13:54:20 2002
+++ linux/mm/swapfile.c	Tue Jun 11 19:02:30 2002
@@ -671,10 +671,7 @@
 		 * private" pages, but they are handled by tmpfs files.
 		 * Note shmem_unuse already deleted its from swap cache.
 		 */
-		swcount = *swap_map;
-		if ((swcount > 0) != PageSwapCache(page))
-			BUG();
-		if ((swcount > 1) && PageDirty(page)) {
+		if ((*swap_map > 1) && PageDirty(page) && PageSwapCache(page)) {
 			rw_swap_page(WRITE, page);
 			lock_page(page);
 		}


  reply	other threads:[~2002-06-12  3:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.LNX.4.21.0206120343290.1036-100000@localhost.localdomain>
2002-06-12  2:51 ` [PATCH] tmpfs 1/4 symlink unwind Hugh Dickins
2002-06-12  2:54   ` [PATCH] tmpfs 2/4 mknod times Hugh Dickins
2002-06-12  2:56   ` [PATCH] tmpfs 3/4 partial truncate Hugh Dickins
2002-06-12  2:58   ` [PATCH] tmpfs 4/4 swapoff tweaks Hugh Dickins
2002-06-12  3:03 ` [PATCH] swap 1/4 swapon memleak Hugh Dickins
2002-06-12  3:05   ` Hugh Dickins [this message]
2002-06-12  3:08   ` [PATCH] swap 3/4 unsafe Dirty check Hugh Dickins
2002-06-12  3:11   ` [PATCH] swap 4/4 redundant SwapCache checks Hugh Dickins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.21.0206120403280.1036-100000@localhost.localdomain \
    --to=hugh@veritas.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).