fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / include / asm-arm / tlb.h
1 /*
2  *  linux/include/asm-arm/tlb.h
3  *
4  *  Copyright (C) 2002 Russell King
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  *  Experimentation shows that on a StrongARM, it appears to be faster
11  *  to use the "invalidate whole tlb" rather than "invalidate single
12  *  tlb" for this.
13  *
14  *  This appears true for both the process fork+exit case, as well as
15  *  the munmap-large-area case.
16  */
17 #ifndef __ASMARM_TLB_H
18 #define __ASMARM_TLB_H
19
20 #include <asm/cacheflush.h>
21 #include <asm/tlbflush.h>
22
23 #ifndef CONFIG_MMU
24
25 #include <linux/pagemap.h>
26 #include <asm-generic/tlb.h>
27
28 #else /* !CONFIG_MMU */
29
30 #include <asm/pgalloc.h>
31 #include <linux/vs_memory.h>
32
33 /*
34  * TLB handling.  This allows us to remove pages from the page
35  * tables, and efficiently handle the TLB issues.
36  */
37 struct mmu_gather {
38         struct mm_struct        *mm;
39         unsigned int            fullmm;
40 };
41
42 DECLARE_PER_CPU(struct mmu_gather, mmu_gathers);
43
44 static inline struct mmu_gather *
45 tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush)
46 {
47         struct mmu_gather *tlb = &get_cpu_var(mmu_gathers);
48
49         tlb->mm = mm;
50         tlb->fullmm = full_mm_flush;
51
52         return tlb;
53 }
54
55 static inline void
56 tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
57 {
58         if (tlb->fullmm)
59                 flush_tlb_mm(tlb->mm);
60
61         /* keep the page table cache within bounds */
62         check_pgt_cache();
63
64         put_cpu_var(mmu_gathers);
65 }
66
67 #define tlb_remove_tlb_entry(tlb,ptep,address)  do { } while (0)
68
69 /*
70  * In the case of tlb vma handling, we can optimise these away in the
71  * case where we're doing a full MM flush.  When we're doing a munmap,
72  * the vmas are adjusted to only cover the region to be torn down.
73  */
74 static inline void
75 tlb_start_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)
76 {
77         if (!tlb->fullmm)
78                 flush_cache_range(vma, vma->vm_start, vma->vm_end);
79 }
80
81 static inline void
82 tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)
83 {
84         if (!tlb->fullmm)
85                 flush_tlb_range(vma, vma->vm_start, vma->vm_end);
86 }
87
88 #define tlb_remove_page(tlb,page)       free_page_and_swap_cache(page)
89 #define pte_free_tlb(tlb,ptep)          pte_free(ptep)
90 #define pmd_free_tlb(tlb,pmdp)          pmd_free(pmdp)
91
92 #define tlb_migrate_finish(mm)          do { } while (0)
93
94 #endif /* CONFIG_MMU */
95 #endif