Re: [Patch] shmem_unuse race fix

From: Christoph Rohland (cr@sap.com)
Date: Thu Dec 28 2000 - 07:02:07 EST


Linus Torvalds <torvalds@transmeta.com> writes:

> On 27 Dec 2000, Christoph Rohland wrote:
> Woul dyou mind testing this alternate fix instead:

Does not work, but is the right direction I think.

First we need the following patch since otherwise we use a swap entry
without having the count increased:

--- 4-13-4/mm/vmscan.c Fri Dec 22 10:05:38 2000
+++ m4-13-4/mm/vmscan.c Thu Dec 28 11:57:57 2000
@@ -93,8 +93,8 @@
                entry.val = page->index;
                if (pte_dirty(pte))
                        SetPageDirty(page);
-set_swap_pte:
                swap_duplicate(entry);
+set_swap_pte:
                set_pte(page_table, swp_entry_to_pte(entry));
 drop_pte:
                UnlockPage(page);
@@ -185,7 +185,7 @@
         * we have the swap cache set up to associate the
         * page with that swap entry.
         */
- entry = get_swap_page();
+ entry = __get_swap_page(2);
        if (!entry.val)
                goto out_unlock_restore; /* No swap space left */

Second there look at this in handle_pte_fault:

                /*
                 * If it truly wasn't present, we know that kswapd
                 * and the PTE updates will not touch it later. So
                 * drop the lock.
                 */
                spin_unlock(&mm->page_table_lock);
                if (pte_none(entry))
                        return do_no_page(mm, vma, address, write_access, pte);
                return do_swap_page(mm, vma, address, pte, pte_to_swp_entry(entry), write_access);

The comment is wrong. try_to_unuse will touch it. This stumbles over a
bad swap entry after try_to_unuse complaining about an undead swap
entry.

If I retry in try_to_unuse it goes into an infinite loop since it
deadlocks with this.

Ideas?
        Christoph

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



This archive was generated by hypermail 2b29 : Sun Dec 31 2000 - 21:00:10 EST