hc
2023-11-22 f743a7adbd6e230d66a6206fa115b59fec2d88eb
kernel/include/linux/highmem.h
....@@ -8,6 +8,7 @@
88 #include <linux/mm.h>
99 #include <linux/uaccess.h>
1010 #include <linux/hardirq.h>
11
+#include <linux/sched.h>
1112
1213 #include <asm/cacheflush.h>
1314
....@@ -66,7 +67,7 @@
6667
6768 static inline void *kmap_atomic(struct page *page)
6869 {
69
- preempt_disable();
70
+ preempt_disable_nort();
7071 pagefault_disable();
7172 return page_address(page);
7273 }
....@@ -75,7 +76,7 @@
7576 static inline void __kunmap_atomic(void *addr)
7677 {
7778 pagefault_enable();
78
- preempt_enable();
79
+ preempt_enable_nort();
7980 }
8081
8182 #define kmap_atomic_pfn(pfn) kmap_atomic(pfn_to_page(pfn))
....@@ -87,32 +88,51 @@
8788
8889 #if defined(CONFIG_HIGHMEM) || defined(CONFIG_X86_32)
8990
91
+#ifndef CONFIG_PREEMPT_RT_FULL
9092 DECLARE_PER_CPU(int, __kmap_atomic_idx);
93
+#endif
9194
9295 static inline int kmap_atomic_idx_push(void)
9396 {
97
+#ifndef CONFIG_PREEMPT_RT_FULL
9498 int idx = __this_cpu_inc_return(__kmap_atomic_idx) - 1;
9599
96
-#ifdef CONFIG_DEBUG_HIGHMEM
100
+# ifdef CONFIG_DEBUG_HIGHMEM
97101 WARN_ON_ONCE(in_irq() && !irqs_disabled());
98102 BUG_ON(idx >= KM_TYPE_NR);
99
-#endif
103
+# endif
100104 return idx;
105
+#else
106
+ current->kmap_idx++;
107
+ BUG_ON(current->kmap_idx > KM_TYPE_NR);
108
+ return current->kmap_idx - 1;
109
+#endif
101110 }
102111
103112 static inline int kmap_atomic_idx(void)
104113 {
114
+#ifndef CONFIG_PREEMPT_RT_FULL
105115 return __this_cpu_read(__kmap_atomic_idx) - 1;
116
+#else
117
+ return current->kmap_idx - 1;
118
+#endif
106119 }
107120
108121 static inline void kmap_atomic_idx_pop(void)
109122 {
110
-#ifdef CONFIG_DEBUG_HIGHMEM
123
+#ifndef CONFIG_PREEMPT_RT_FULL
124
+# ifdef CONFIG_DEBUG_HIGHMEM
111125 int idx = __this_cpu_dec_return(__kmap_atomic_idx);
112126
113127 BUG_ON(idx < 0);
114
-#else
128
+# else
115129 __this_cpu_dec(__kmap_atomic_idx);
130
+# endif
131
+#else
132
+ current->kmap_idx--;
133
+# ifdef CONFIG_DEBUG_HIGHMEM
134
+ BUG_ON(current->kmap_idx < 0);
135
+# endif
116136 #endif
117137 }
118138