[PATCH] Cache alias issues for swapped page

From: NIIBE Yutaka (gniibe@chroot.org)
Date: Fri Sep 08 2000 - 21:39:54 EST


For SH-4 (with virtually indexed, physically tagged cache), we have
problems with swap.

I think that there're bugs in do_swap_page and try_to_swap_out.
I've read "Documentation/cachetlb.txt" and I know that now is
the transition to newer interface, but we need a fix at the moment
with old interface.

(1) Flush is needed at do_swap_page

With current implementation, cache is flushed when it is swapped in
synchronously. When it is swapped in asynchronously
(swapfile.c:try_to_unuse, memory.c:swapin_readahead), there's no
flushing which causes alias.

(2) Flush is needed at try_to_swap

When swap out, flushing is needed for physical tag too.

Here's a patch to indicate the issues.

diff -ruN linux-2.4.0-test8-pre6/mm/memory.c linux/mm/memory.c
--- linux-2.4.0-test8-pre6/mm/memory.c Thu Sep 7 09:56:19 2000
+++ linux/mm/memory.c Mon Sep 4 15:25:17 2000
@@ -1068,9 +1068,6 @@
                 unlock_kernel();
                 if (!page)
                         return -1;
-
- flush_page_to_ram(page);
- flush_icache_page(vma, page);
         }
 
         mm->rss++;
@@ -1093,6 +1090,8 @@
         } else
                 UnlockPage(page);
 
+ flush_page_to_ram(page);
+ flush_icache_page(vma, page);
         set_pte(page_table, pte);
         /* No need to invalidate - it was non-present before */
         update_mmu_cache(vma, address, pte);
diff -ruN linux-2.4.0-test8-pre6/mm/vmscan.c linux/mm/vmscan.c
--- linux-2.4.0-test8-pre6/mm/vmscan.c Thu Sep 7 09:56:19 2000
+++ linux/mm/vmscan.c Mon Sep 4 15:25:18 2000
@@ -138,6 +138,7 @@
          *
          * That would get rid of a lot of problems.
          */
+ flush_page_to_ram(page);
         flush_cache_page(vma, address);
         if (vma->vm_ops && (swapout = vma->vm_ops->swapout)) {
                 int error;

-- 
-
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 : Fri Sep 15 2000 - 21:00:11 EST