Re: [PATCH] flush_cache_page while pte valid

From: Russell King (
Date: Mon Nov 11 2002 - 19:37:43 EST

On Mon, Nov 11, 2002 at 10:20:30PM +0100, Manfred Spraul wrote:
> > /* Nuke the page table entry. */
> >+ flush_cache_page(vma, address);
> > pte = ptep_get_and_clear(ptep);
> > flush_tlb_page(vma, address);
> >- flush_cache_page(vma, address);
> >
> Is it correct that this are 3 arch hooks that must appear back to back?
> What about one hook with all parameters?
> pte = ptep_get_and_clear_and_flush(ptep, vma, address);
> The current implementation just asks for such errors.

Its actually a very simple rule. The sequence must be:

- flush cache for area
- change pte entries in area
- flush tlb for area

Anything else is just buggy, and may very well be racy. Think about the
race when you flush the tlb entry before changing the pte.

Rather than creating a new interface that's only useful for 10% of the
cases, I'd prefer to keep the rule personally. The smaller the number
of functions each with their own particular set of behaviours doing
almost the same job, the less chance of getting the wrong function.
And, IMHO, the easier it is to audit the code.

grep -4 ptep_get_and_clear mm/*.c


"Is this the right function here?"

PS, I see one place where "ptep_get_and_clear_and_flush" would be useful
out of 6 uses.

Russell King (                The developer of ARM Linux

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to More majordomo info at Please read the FAQ at

This archive was generated by hypermail 2b29 : Fri Nov 15 2002 - 22:00:24 EST