linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* The interface of flush_cache_page
@ 2001-08-04  6:10 NIIBE Yutaka
  2001-08-04  9:48 ` David S. Miller
  2001-08-04 10:44 ` NIIBE Yutaka
  0 siblings, 2 replies; 3+ messages in thread
From: NIIBE Yutaka @ 2001-08-04  6:10 UTC (permalink / raw)
  To: linux-kernel

Currently, the interface is like this:

void flush_cache_page(struct vm_area_struct *vma, unsigned long address)

This doesn't work well for (virtuall indexed) physically tagged
architecture.

When it is called from vmscan.c:try_to_swap_out, as the PTE is cleared
to be zero, we have no way to know what phisical address to match.

How about adding argument: struct page *page?  With that, we have
information of physical memory.
-- 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: The interface of flush_cache_page
  2001-08-04  6:10 The interface of flush_cache_page NIIBE Yutaka
@ 2001-08-04  9:48 ` David S. Miller
  2001-08-04 10:44 ` NIIBE Yutaka
  1 sibling, 0 replies; 3+ messages in thread
From: David S. Miller @ 2001-08-04  9:48 UTC (permalink / raw)
  To: NIIBE Yutaka; +Cc: linux-kernel


NIIBE Yutaka writes:
 > When it is called from vmscan.c:try_to_swap_out, as the PTE is cleared
 > to be zero, we have no way to know what phisical address to match.

That is really an error, and it is only because the last time the
logic try_to_swap_out() logic got rearranges the cache flush got moved
lower down.

In fact, several architectures will take a fatal trap due to
this sequence.  On these systems the tlb must be able to translate the
virtual address given to it for the flush, and that translation must
be valid.

Thus, the code there should be:

	flush_cache_page(vma, address);
	pte = ptep_get_and_clear(page_table);
	flush_tlb_page(vma, address);

And the flush_cache_page() further down in that function then can be
removed.

Feel free to send this fix to Linus.  It is probably causing
HyperSparc sparc32 to fail to work at all once a swap happens,
if platforms using that chip work at all.

Later,
David S. Miller
davem@redhat.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: The interface of flush_cache_page
  2001-08-04  6:10 The interface of flush_cache_page NIIBE Yutaka
  2001-08-04  9:48 ` David S. Miller
@ 2001-08-04 10:44 ` NIIBE Yutaka
  1 sibling, 0 replies; 3+ messages in thread
From: NIIBE Yutaka @ 2001-08-04 10:44 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: David S. Miller, linux-kernel

Hello Linus, 

Attached is a patch to move the call of flush_cache_page before
clearing PTE in vmscan.c:try_to_swap_out.

Here, we want to flush cache entries written from user space.
But for some archtecture, we need valid PTE to flush, so, we need to
call flush_cache_page before ptep_get_and_clear.

At least, we need this for SuperH (which has virtually indexed
physically tagged cache).

--- v2.4.8-pre4/mm/vmscan.c	Sat Aug  4 15:37:55 2001
+++ linux/mm/vmscan.c	Sat Aug  4 19:27:07 2001
@@ -65,6 +65,7 @@ static void try_to_swap_out(struct mm_st
 	 * is needed on CPUs which update the accessed and dirty
 	 * bits in hardware.
 	 */
+	flush_cache_page(vma, address);
 	pte = ptep_get_and_clear(page_table);
 	flush_tlb_page(vma, address);
 
@@ -102,7 +103,6 @@ drop_pte:
 	 * Basically, this just makes it possible for us to do
 	 * some real work in the future in "refill_inactive()".
 	 */
-	flush_cache_page(vma, address);
 	if (!pte_dirty(pte))
 		goto drop_pte;
 
--------
 
David S. Miller wrote:
 > NIIBE Yutaka writes:
 >  > When it is called from vmscan.c:try_to_swap_out, as the PTE is cleared
 >  > to be zero, we have no way to know what phisical address to match.
 > 
 > That is really an error, and it is only because the last time the
 > logic try_to_swap_out() logic got rearranges the cache flush got moved
 > lower down.
 > 
 > In fact, several architectures will take a fatal trap due to
 > this sequence.  On these systems the tlb must be able to translate the
 > virtual address given to it for the flush, and that translation must
 > be valid.
 > 
 > Thus, the code there should be:
 > 
 > 	flush_cache_page(vma, address);
 > 	pte = ptep_get_and_clear(page_table);
 > 	flush_tlb_page(vma, address);
 > 
 > And the flush_cache_page() further down in that function then can be
 > removed.
 > 
 > Feel free to send this fix to Linus.  It is probably causing
 > HyperSparc sparc32 to fail to work at all once a swap happens,
 > if platforms using that chip work at all.
-- 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-08-04 10:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-04  6:10 The interface of flush_cache_page NIIBE Yutaka
2001-08-04  9:48 ` David S. Miller
2001-08-04 10:44 ` NIIBE Yutaka

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).