9 #include <linux/pagemap.h>
12 #include <asm/pgalloc.h>
13 #include <asm/tlbflush.h>
16 * TLB handling. This allows us to remove pages from the page
17 * tables, and efficiently handle the TLB issues.
22 unsigned long start, end;
25 DECLARE_PER_CPU(struct mmu_gather, mmu_gathers);
27 static inline void init_tlb_gather(struct mmu_gather *tlb)
29 tlb->start = TASK_SIZE;
38 static inline struct mmu_gather *
39 tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush)
41 struct mmu_gather *tlb = &get_cpu_var(mmu_gathers);
44 tlb->fullmm = full_mm_flush;
52 tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
55 flush_tlb_mm(tlb->mm);
57 /* keep the page table cache within bounds */
60 put_cpu_var(mmu_gathers);
64 tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep, unsigned long address)
66 if (tlb->start > address)
68 if (tlb->end < address + PAGE_SIZE)
69 tlb->end = address + PAGE_SIZE;
73 * In the case of tlb vma handling, we can optimise these away in the
74 * case where we're doing a full MM flush. When we're doing a munmap,
75 * the vmas are adjusted to only cover the region to be torn down.
78 tlb_start_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)
81 flush_cache_range(vma, vma->vm_start, vma->vm_end);
85 tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)
87 if (!tlb->fullmm && tlb->end) {
88 flush_tlb_range(vma, tlb->start, tlb->end);
93 #define tlb_remove_page(tlb,page) free_page_and_swap_cache(page)
94 #define pte_free_tlb(tlb, ptep) pte_free((tlb)->mm, ptep)
95 #define pmd_free_tlb(tlb, pmdp) pmd_free((tlb)->mm, pmdp)
96 #define pud_free_tlb(tlb, pudp) pud_free((tlb)->mm, pudp)
98 #define tlb_migrate_finish(mm) do { } while (0)
100 #else /* CONFIG_MMU */
102 #define tlb_start_vma(tlb, vma) do { } while (0)
103 #define tlb_end_vma(tlb, vma) do { } while (0)
104 #define __tlb_remove_tlb_entry(tlb, pte, address) do { } while (0)
105 #define tlb_flush(tlb) do { } while (0)
107 #include <asm-generic/tlb.h>
109 #endif /* CONFIG_MMU */
110 #endif /* __ASSEMBLY__ */
111 #endif /* __ASM_SH_TLB_H */