hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/x86/include/asm/preempt.h
....@@ -8,6 +8,9 @@
88
99 DECLARE_PER_CPU(int, __preempt_count);
1010
11
+/* We use the MSB mostly because its available */
12
+#define PREEMPT_NEED_RESCHED 0x80000000
13
+
1114 /*
1215 * We use the PREEMPT_NEED_RESCHED bit as an inverted NEED_RESCHED such
1316 * that a decrement hitting 0 means we can and should reschedule.
....@@ -40,7 +43,7 @@
4043 #define init_task_preempt_count(p) do { } while (0)
4144
4245 #define init_idle_preempt_count(p, cpu) do { \
43
- per_cpu(__preempt_count, (cpu)) = PREEMPT_ENABLED; \
46
+ per_cpu(__preempt_count, (cpu)) = PREEMPT_DISABLED; \
4447 } while (0)
4548
4649 /*
....@@ -88,7 +91,7 @@
8891 */
8992 static __always_inline bool ____preempt_count_dec_and_test(void)
9093 {
91
- GEN_UNARY_RMWcc("decl", __preempt_count, __percpu_arg(0), e);
94
+ return GEN_UNARY_RMWcc("decl", __preempt_count, e, __percpu_arg([var]));
9295 }
9396
9497 static __always_inline bool __preempt_count_dec_and_test(void)
....@@ -113,7 +116,6 @@
113116 {
114117 #ifdef CONFIG_PREEMPT_LAZY
115118 u32 tmp;
116
-
117119 tmp = raw_cpu_read_4(__preempt_count);
118120 if (tmp == preempt_offset)
119121 return true;
....@@ -122,6 +124,7 @@
122124 tmp &= ~PREEMPT_NEED_RESCHED;
123125 if (tmp != preempt_offset)
124126 return false;
127
+ /* XXX PREEMPT_LOCK_OFFSET */
125128 if (current_thread_info()->preempt_lazy_count)
126129 return false;
127130 return test_thread_flag(TIF_NEED_RESCHED_LAZY);
....@@ -130,15 +133,18 @@
130133 #endif
131134 }
132135
133
-#ifdef CONFIG_PREEMPT
134
- extern asmlinkage void ___preempt_schedule(void);
136
+#ifdef CONFIG_PREEMPTION
137
+#ifdef CONFIG_PREEMPT_RT
138
+ extern void preempt_schedule_lock(void);
139
+#endif
140
+ extern asmlinkage void preempt_schedule_thunk(void);
135141 # define __preempt_schedule() \
136
- asm volatile ("call ___preempt_schedule" : ASM_CALL_CONSTRAINT)
142
+ asm volatile ("call preempt_schedule_thunk" : ASM_CALL_CONSTRAINT)
137143
138144 extern asmlinkage void preempt_schedule(void);
139
- extern asmlinkage void ___preempt_schedule_notrace(void);
145
+ extern asmlinkage void preempt_schedule_notrace_thunk(void);
140146 # define __preempt_schedule_notrace() \
141
- asm volatile ("call ___preempt_schedule_notrace" : ASM_CALL_CONSTRAINT)
147
+ asm volatile ("call preempt_schedule_notrace_thunk" : ASM_CALL_CONSTRAINT)
142148
143149 extern asmlinkage void preempt_schedule_notrace(void);
144150 #endif