@@ -19,6 +19,24 @@ static inline void local_bh_disable(void)
__local_bh_disable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET);
}
+/*
+ * local_bh_disable() protects against both preemption and soft interrupts
+ * on !RT kernels.
+ *
+ * On RT kernels local_bh_disable() is not sufficient because it only
+ * serializes soft interrupt related sections via a local lock, but stays
+ * preemptible. Disabling preemption is the right choice here as bottom
+ * half processing is always in thread context on RT kernels so it
+ * implicitly prevents bottom half processing as well.
+ */
+static inline void preempt_disable_bh(void)
+{
+ if (IS_ENABLED(CONFIG_PREEMPT_RT))
+ preempt_disable();
+ else
+ local_bh_disable();
+}
+
extern void _local_bh_enable(void);
extern void __local_bh_enable_ip(unsigned long ip, unsigned int cnt);
@@ -32,6 +50,14 @@ static inline void local_bh_enable(void)
__local_bh_enable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET);
}
+static inline void preempt_enable_bh(void)
+{
+ if (IS_ENABLED(CONFIG_PREEMPT_RT))
+ preempt_enable();
+ else
+ local_bh_enable();
+}
+
#ifdef CONFIG_PREEMPT_RT
extern bool local_bh_blocked(void);
#else
As pointed out by commit: cba08c5dc6dc ("x86/fpu: Make kernel FPU protection RT friendly") local_bh_disable() is not sufficient under CONFIG_PREEMPT_RT for FPU manipulation. This also affects at least arm64, so package the preemption / softirq enablement handling into a pair of helpers. Signed-off-by: Valentin Schneider <valentin.schneider@arm.com> --- include/linux/bottom_half.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)