Re: minor patch for 2.1.103 swap

Bill Hawes (
Mon, 25 May 1998 09:03:30 -0400

Stephen C. Tweedie wrote:

> On Sat, 23 May 1998 10:09:26 -0400, Bill Hawes <> said:
> > In the free_page() routines there is a panic if a swap cache page has
> > a ref count of 1, but according to code and comments elsewhere this
> > shouldn't be a problem. Shrink_mmap has a test to remove pages from
> > the swap cache when count == 1, and a comment in vmscan.c states that
> > a page might occasionally be left in the swap cache after having other
> > references freed. Since these cases would all come through free_page()
> > with the count set to 1, there's no longer any reason to cause a
> > panic. (And possibly the warning should be removed as well at some
> > point.)
> The swap cache code is careful always to clear the swap cache bit on a
> page before doing the final __free_page(). If we get to __free_page()
> with the swap cache bit still set, then it is definitely an unexpected
> event. Yes, we can free swap cache pages with a reference count of
> one, but __free_page() should never see the bit set.

Hi Stephen,

I'm not concerned with the _final_ free_page, but rather the one that
takes the page count from 2 to 1. The test_and_atomic_dec will take the
count from 2 to 1, and then there's a test for PageSwapCache with count
== 1 leading to a panic. You have comments in vmscan indicating that
this may occur, and if it wasn't possible to have PageSwapCache with
count == 1, what would be the point in having shrink_mmap() check for

It's true that in the majority of cases the free_page_and_swap_cache
call will clear the swap cache flag before doing the free, but as long
as it's possible to have the swap cached page with count 1, doing a
panic isn't a good idea.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to