diff options
-rw-r--r-- | include/linux/highmem.h | 46 | ||||
-rw-r--r-- | mm/highmem.c | 6 |
2 files changed, 30 insertions, 22 deletions
diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 8a85ec109a3a..102f76be90da 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h | |||
@@ -37,27 +37,6 @@ extern unsigned long totalhigh_pages; | |||
37 | 37 | ||
38 | void kmap_flush_unused(void); | 38 | void kmap_flush_unused(void); |
39 | 39 | ||
40 | DECLARE_PER_CPU(int, __kmap_atomic_idx); | ||
41 | |||
42 | static inline int kmap_atomic_idx_push(void) | ||
43 | { | ||
44 | int idx = __get_cpu_var(__kmap_atomic_idx)++; | ||
45 | #ifdef CONFIG_DEBUG_HIGHMEM | ||
46 | WARN_ON_ONCE(in_irq() && !irqs_disabled()); | ||
47 | BUG_ON(idx > KM_TYPE_NR); | ||
48 | #endif | ||
49 | return idx; | ||
50 | } | ||
51 | |||
52 | static inline int kmap_atomic_idx_pop(void) | ||
53 | { | ||
54 | int idx = --__get_cpu_var(__kmap_atomic_idx); | ||
55 | #ifdef CONFIG_DEBUG_HIGHMEM | ||
56 | BUG_ON(idx < 0); | ||
57 | #endif | ||
58 | return idx; | ||
59 | } | ||
60 | |||
61 | #else /* CONFIG_HIGHMEM */ | 40 | #else /* CONFIG_HIGHMEM */ |
62 | 41 | ||
63 | static inline unsigned int nr_free_highpages(void) { return 0; } | 42 | static inline unsigned int nr_free_highpages(void) { return 0; } |
@@ -95,6 +74,31 @@ static inline void __kunmap_atomic(void *addr) | |||
95 | 74 | ||
96 | #endif /* CONFIG_HIGHMEM */ | 75 | #endif /* CONFIG_HIGHMEM */ |
97 | 76 | ||
77 | #if defined(CONFIG_HIGHMEM) || defined(CONFIG_X86_32) | ||
78 | |||
79 | DECLARE_PER_CPU(int, __kmap_atomic_idx); | ||
80 | |||
81 | static inline int kmap_atomic_idx_push(void) | ||
82 | { | ||
83 | int idx = __get_cpu_var(__kmap_atomic_idx)++; | ||
84 | #ifdef CONFIG_DEBUG_HIGHMEM | ||
85 | WARN_ON_ONCE(in_irq() && !irqs_disabled()); | ||
86 | BUG_ON(idx > KM_TYPE_NR); | ||
87 | #endif | ||
88 | return idx; | ||
89 | } | ||
90 | |||
91 | static inline int kmap_atomic_idx_pop(void) | ||
92 | { | ||
93 | int idx = --__get_cpu_var(__kmap_atomic_idx); | ||
94 | #ifdef CONFIG_DEBUG_HIGHMEM | ||
95 | BUG_ON(idx < 0); | ||
96 | #endif | ||
97 | return idx; | ||
98 | } | ||
99 | |||
100 | #endif | ||
101 | |||
98 | /* | 102 | /* |
99 | * Make both: kmap_atomic(page, idx) and kmap_atomic(page) work. | 103 | * Make both: kmap_atomic(page, idx) and kmap_atomic(page) work. |
100 | */ | 104 | */ |
diff --git a/mm/highmem.c b/mm/highmem.c index 781e754a75ac..693394daa2ed 100644 --- a/mm/highmem.c +++ b/mm/highmem.c | |||
@@ -29,6 +29,11 @@ | |||
29 | #include <linux/kgdb.h> | 29 | #include <linux/kgdb.h> |
30 | #include <asm/tlbflush.h> | 30 | #include <asm/tlbflush.h> |
31 | 31 | ||
32 | |||
33 | #if defined(CONFIG_HIGHMEM) || defined(CONFIG_X86_32) | ||
34 | DEFINE_PER_CPU(int, __kmap_atomic_idx); | ||
35 | #endif | ||
36 | |||
32 | /* | 37 | /* |
33 | * Virtual_count is not a pure "count". | 38 | * Virtual_count is not a pure "count". |
34 | * 0 means that it is not mapped, and has not been mapped | 39 | * 0 means that it is not mapped, and has not been mapped |
@@ -43,7 +48,6 @@ unsigned long totalhigh_pages __read_mostly; | |||
43 | EXPORT_SYMBOL(totalhigh_pages); | 48 | EXPORT_SYMBOL(totalhigh_pages); |
44 | 49 | ||
45 | 50 | ||
46 | DEFINE_PER_CPU(int, __kmap_atomic_idx); | ||
47 | EXPORT_PER_CPU_SYMBOL(__kmap_atomic_idx); | 51 | EXPORT_PER_CPU_SYMBOL(__kmap_atomic_idx); |
48 | 52 | ||
49 | unsigned int nr_free_highpages (void) | 53 | unsigned int nr_free_highpages (void) |