Re: PG_swap_entry bug in recent kernels

Andrea Arcangeli
2000-04-04T16:50:07Z

On Tue, 4 Apr 2000, Rik van Riel wrote:

>You might want to have read _where_ Ben's patch applies.
>
>void __delete_from_swap_cache(struct page *page)
>{
> swp_entry_t entry;
>
> entry.val = page->index;
>
>#ifdef SWAP_CACHE_INFO
> swap_cache_del_total++;
>#endif
> remove_from_swap_cache(page);
> swap_free(entry);
>+ clear_bit(PG_swap_entry, &page->flags);
>}
>
>When we remove a page from the swap cache, it seems fair to me
>that we _really_ remove it from the swap cache.

Are you sure you didn't mistaken PG_swap_entry for PG_swap_cache?

We're here talking about PG_swap_entry. The only object of that bit is to
remains set on anonymous pages that aren't in the swap cache, so next time
we'll re-add them to the swap cache we'll try to swap out them in the same
swap entry as the page were before.

>If __delete_from_swap_cache() is called from a wrong code path,
>that's something that should be fixed, of course (but that's
>orthogonal to this).

__delete_from_swap_cache is called by delete_from_swap_cache_nolock that
is called by do_swap_page that does the swapin.

>To quote from memory.c::do_swap_page() :
>
> if (write_access && !is_page_shared(page)) {
> delete_from_swap_cache_nolock(page);
> UnlockPage(page);
>
>If you think this is a bug, please fix it here...

The above quoted code is correct.

Andrea