aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugh Dickins <hugh@veritas.com>2005-10-29 21:16:01 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-30 00:40:37 -0400
commit15a23ffa2fc91cebdac44d4aee994f59d5c28dc0 (patch)
tree5006935b29246c1ae07a7abc6a384f6b547293ce
parent7be7a546994f1222b2312fd348da14e16b6b7b42 (diff)
[PATCH] mm: tlb_gather_mmu get_cpu_var
tlb_gather_mmu dates from before kernel preemption was allowed, and uses smp_processor_id or __get_cpu_var to find its per-cpu mmu_gather. That works because it's currently only called after getting page_table_lock, which is not dropped until after the matching tlb_finish_mmu. But don't rely on that, it will soon change: now disable preemption internally by proper get_cpu_var in tlb_gather_mmu, put_cpu_var in tlb_finish_mmu. Signed-off-by: Hugh Dickins <hugh@veritas.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--include/asm-arm/tlb.h5
-rw-r--r--include/asm-arm26/tlb.h7
-rw-r--r--include/asm-generic/tlb.h10
-rw-r--r--include/asm-ia64/tlb.h6
-rw-r--r--include/asm-sparc64/tlb.h4
5 files changed, 19 insertions, 13 deletions
diff --git a/include/asm-arm/tlb.h b/include/asm-arm/tlb.h
index 9bb325c54645..da41df20928f 100644
--- a/include/asm-arm/tlb.h
+++ b/include/asm-arm/tlb.h
@@ -39,8 +39,7 @@ DECLARE_PER_CPU(struct mmu_gather, mmu_gathers);
39static inline struct mmu_gather * 39static inline struct mmu_gather *
40tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush) 40tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush)
41{ 41{
42 int cpu = smp_processor_id(); 42 struct mmu_gather *tlb = &get_cpu_var(mmu_gathers);
43 struct mmu_gather *tlb = &per_cpu(mmu_gathers, cpu);
44 43
45 tlb->mm = mm; 44 tlb->mm = mm;
46 tlb->freed = 0; 45 tlb->freed = 0;
@@ -65,6 +64,8 @@ tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
65 64
66 /* keep the page table cache within bounds */ 65 /* keep the page table cache within bounds */
67 check_pgt_cache(); 66 check_pgt_cache();
67
68 put_cpu_var(mmu_gathers);
68} 69}
69 70
70static inline unsigned int tlb_is_full_mm(struct mmu_gather *tlb) 71static inline unsigned int tlb_is_full_mm(struct mmu_gather *tlb)
diff --git a/include/asm-arm26/tlb.h b/include/asm-arm26/tlb.h
index 1316352a58f3..8486b00a6799 100644
--- a/include/asm-arm26/tlb.h
+++ b/include/asm-arm26/tlb.h
@@ -17,13 +17,12 @@ struct mmu_gather {
17 unsigned int avoided_flushes; 17 unsigned int avoided_flushes;
18}; 18};
19 19
20extern struct mmu_gather mmu_gathers[NR_CPUS]; 20DECLARE_PER_CPU(struct mmu_gather, mmu_gathers);
21 21
22static inline struct mmu_gather * 22static inline struct mmu_gather *
23tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush) 23tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush)
24{ 24{
25 int cpu = smp_processor_id(); 25 struct mmu_gather *tlb = &get_cpu_var(mmu_gathers);
26 struct mmu_gather *tlb = &mmu_gathers[cpu];
27 26
28 tlb->mm = mm; 27 tlb->mm = mm;
29 tlb->freed = 0; 28 tlb->freed = 0;
@@ -52,6 +51,8 @@ tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
52 51
53 /* keep the page table cache within bounds */ 52 /* keep the page table cache within bounds */
54 check_pgt_cache(); 53 check_pgt_cache();
54
55 put_cpu_var(mmu_gathers);
55} 56}
56 57
57 58
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index 7d0298347ee7..c8232622c8d9 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -35,9 +35,7 @@
35#endif 35#endif
36 36
37/* struct mmu_gather is an opaque type used by the mm code for passing around 37/* struct mmu_gather is an opaque type used by the mm code for passing around
38 * any data needed by arch specific code for tlb_remove_page. This structure 38 * any data needed by arch specific code for tlb_remove_page.
39 * can be per-CPU or per-MM as the page table lock is held for the duration of
40 * TLB shootdown.
41 */ 39 */
42struct mmu_gather { 40struct mmu_gather {
43 struct mm_struct *mm; 41 struct mm_struct *mm;
@@ -57,7 +55,7 @@ DECLARE_PER_CPU(struct mmu_gather, mmu_gathers);
57static inline struct mmu_gather * 55static inline struct mmu_gather *
58tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush) 56tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush)
59{ 57{
60 struct mmu_gather *tlb = &per_cpu(mmu_gathers, smp_processor_id()); 58 struct mmu_gather *tlb = &get_cpu_var(mmu_gathers);
61 59
62 tlb->mm = mm; 60 tlb->mm = mm;
63 61
@@ -85,7 +83,7 @@ tlb_flush_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
85 83
86/* tlb_finish_mmu 84/* tlb_finish_mmu
87 * Called at the end of the shootdown operation to free up any resources 85 * Called at the end of the shootdown operation to free up any resources
88 * that were required. The page table lock is still held at this point. 86 * that were required.
89 */ 87 */
90static inline void 88static inline void
91tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end) 89tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
@@ -101,6 +99,8 @@ tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
101 99
102 /* keep the page table cache within bounds */ 100 /* keep the page table cache within bounds */
103 check_pgt_cache(); 101 check_pgt_cache();
102
103 put_cpu_var(mmu_gathers);
104} 104}
105 105
106static inline unsigned int 106static inline unsigned int
diff --git a/include/asm-ia64/tlb.h b/include/asm-ia64/tlb.h
index 3a9a6d1be75c..1b82299d7c1e 100644
--- a/include/asm-ia64/tlb.h
+++ b/include/asm-ia64/tlb.h
@@ -129,7 +129,7 @@ ia64_tlb_flush_mmu (struct mmu_gather *tlb, unsigned long start, unsigned long e
129static inline struct mmu_gather * 129static inline struct mmu_gather *
130tlb_gather_mmu (struct mm_struct *mm, unsigned int full_mm_flush) 130tlb_gather_mmu (struct mm_struct *mm, unsigned int full_mm_flush)
131{ 131{
132 struct mmu_gather *tlb = &__get_cpu_var(mmu_gathers); 132 struct mmu_gather *tlb = &get_cpu_var(mmu_gathers);
133 133
134 tlb->mm = mm; 134 tlb->mm = mm;
135 /* 135 /*
@@ -154,7 +154,7 @@ tlb_gather_mmu (struct mm_struct *mm, unsigned int full_mm_flush)
154 154
155/* 155/*
156 * Called at the end of the shootdown operation to free up any resources that were 156 * Called at the end of the shootdown operation to free up any resources that were
157 * collected. The page table lock is still held at this point. 157 * collected.
158 */ 158 */
159static inline void 159static inline void
160tlb_finish_mmu (struct mmu_gather *tlb, unsigned long start, unsigned long end) 160tlb_finish_mmu (struct mmu_gather *tlb, unsigned long start, unsigned long end)
@@ -174,6 +174,8 @@ tlb_finish_mmu (struct mmu_gather *tlb, unsigned long start, unsigned long end)
174 174
175 /* keep the page table cache within bounds */ 175 /* keep the page table cache within bounds */
176 check_pgt_cache(); 176 check_pgt_cache();
177
178 put_cpu_var(mmu_gathers);
177} 179}
178 180
179static inline unsigned int 181static inline unsigned int
diff --git a/include/asm-sparc64/tlb.h b/include/asm-sparc64/tlb.h
index 9baf57db01d2..169309bdbf82 100644
--- a/include/asm-sparc64/tlb.h
+++ b/include/asm-sparc64/tlb.h
@@ -44,7 +44,7 @@ extern void flush_tlb_pending(void);
44 44
45static inline struct mmu_gather *tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush) 45static inline struct mmu_gather *tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush)
46{ 46{
47 struct mmu_gather *mp = &__get_cpu_var(mmu_gathers); 47 struct mmu_gather *mp = &get_cpu_var(mmu_gathers);
48 48
49 BUG_ON(mp->tlb_nr); 49 BUG_ON(mp->tlb_nr);
50 50
@@ -97,6 +97,8 @@ static inline void tlb_finish_mmu(struct mmu_gather *mp, unsigned long start, un
97 97
98 /* keep the page table cache within bounds */ 98 /* keep the page table cache within bounds */
99 check_pgt_cache(); 99 check_pgt_cache();
100
101 put_cpu_var(mmu_gathers);
100} 102}
101 103
102static inline unsigned int tlb_is_full_mm(struct mmu_gather *mp) 104static inline unsigned int tlb_is_full_mm(struct mmu_gather *mp)