vserver 2.0 rc7
[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 #include <asm/pgalloc.h>
23 #include <linux/vs_memory.h>
24
25 /*
26  * TLB handling.  This allows us to remove pages from the page
27  * tables, and efficiently handle the TLB issues.
28  */
29 struct mmu_gather {
30         struct mm_struct        *mm;
31         unsigned int            freed;
32         unsigned int            fullmm;
33
34         unsigned int            flushes;
35         unsigned int            avoided_flushes;
36 };
37
38 DECLARE_PER_CPU(struct mmu_gather, mmu_gathers);
39
40 static inline struct mmu_gather *
41 tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush)
42 {
43         int cpu = smp_processor_id();
44         struct mmu_gather *tlb = &per_cpu(mmu_gathers, cpu);
45
46         tlb->mm = mm;
47         tlb->freed = 0;
48         tlb->fullmm = full_mm_flush;
49
50         return tlb;
51 }
52
53 static inline void
54 tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
55 {
56         struct mm_struct *mm = tlb->mm;
57         unsigned long freed = tlb->freed;
58         int rss = get_mm_counter(mm, rss);
59
60         if (rss < freed)
61                 freed = rss;
62         add_mm_counter(mm, rss, -freed);
63
64         if (tlb->fullmm)
65                 flush_tlb_mm(mm);
66
67         /* keep the page table cache within bounds */
68         check_pgt_cache();
69 }
70
71 static inline unsigned int tlb_is_full_mm(struct mmu_gather *tlb)
72 {
73         return tlb->fullmm;
74 }
75
76 #define tlb_remove_tlb_entry(tlb,ptep,address)  do { } while (0)
77
78 /*
79  * In the case of tlb vma handling, we can optimise these away in the
80  * case where we're doing a full MM flush.  When we're doing a munmap,
81  * the vmas are adjusted to only cover the region to be torn down.
82  */
83 static inline void
84 tlb_start_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)
85 {
86         if (!tlb->fullmm)
87                 flush_cache_range(vma, vma->vm_start, vma->vm_end);
88 }
89
90 static inline void
91 tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)
92 {
93         if (!tlb->fullmm)
94                 flush_tlb_range(vma, vma->vm_start, vma->vm_end);
95 }
96
97 #define tlb_remove_page(tlb,page)       free_page_and_swap_cache(page)
98 #define pte_free_tlb(tlb,ptep)          pte_free(ptep)
99 #define pmd_free_tlb(tlb,pmdp)          pmd_free(pmdp)
100
101 #define tlb_migrate_finish(mm)          do { } while (0)
102
103 #endif