• Andrew Morton's avatar
    [PATCH] s390: tlb flush optimization. · 9177d562
    Andrew Morton authored
    From: Martin Schwidefsky <schwidefsky@de.ibm.com>
    
    On the s/390 architecture we still have the issue with tlb flushing and the
    ipte instruction.  We can optimize the tlb flushing a lot with some minor
    interface changes between the arch backend and the memory management core. 
    In the end the whole thing is about the Invalidate Page Table Entry (ipte)
    instruction.  The instruction sets the invalid bit in the pte and removes the
    tlb for the page on all cpus for the virtual to physical mapping of the page
    in a particular address space.  The nice thing is that only the tlb for this
    page gets removed, all the other tlbs stay valid.  The reason we can't use
    ipte to implement flush_tlb_page() is one of the requirements of the
    instruction: the pte that should get flushed needs to be *valid*.
    
    I'd like to add the following four functions to the mm interface:
    
      * ptep_establish: Establish a new mapping. This sets a pte entry to a
        page table and flushes the tlb of the old entry on all cpus if it
        exists. This is more or less what establish_pte in mm/memory.c does
        right now but without the update_mmu_cache call.
    
      * ptep_test_and_clear_and_flush_young. Do what ptep_test_and_clear_young
        does and flush the tlb.
    
      * ptep_test_and_clear_and_flush_dirty. Do what ptep_test_and_clear_dirty
        does and flush the tlb.
    
      * ptep_get_and_clear_and_flush: Do what ptep_get_and_clear does and
        flush the tlb.
    
    The s/390 specific functions in include/pgtable.h define their own optimized
    version of these four functions by use of the ipte.
    
    I avoid the definition of these function for every architecture I added them
    to include/asm-generic/pgtable.h.  Since i386/x86 and others don't include
    this header yet and define their own version of the functions found there I
    #ifdef'd all functions in include/asm-generic/pgtable.h to be able to pick
    the ones that are needed for each architecture (see patch for details).
    
    With the new functions in place it is easy to do the optimization, e.g.  the
    sequence
    
             ptep_get_and_clear(ptep);
             flush_tlb_page(vma, address);
    
    gets replace by
    
             ptep_get_and_clear_and_flush(vma, address, ptep);
    
    The old sequence still works but it is suboptimal on s/390.
    9177d562
rmap.c 13.4 KB