Page MenuHomeFreeBSD

D57782.diff
No OneTemporary

D57782.diff

diff --git a/sys/compat/linuxkpi/common/include/linux/hardirq.h b/sys/compat/linuxkpi/common/include/linux/hardirq.h
--- a/sys/compat/linuxkpi/common/include/linux/hardirq.h
+++ b/sys/compat/linuxkpi/common/include/linux/hardirq.h
@@ -49,4 +49,26 @@
*/
#define synchronize_hardirq(irq) _intr_drain((irq))
+/*
+ * irqs_disabled - returns true if the caller should not sleep
+ *
+ * On Linux, irqs_disabled() reflects hardware IRQ masking (EFLAGS.IF on x86).
+ * FreeBSD does not disable hardware IRQs for linuxkpi spinlocks; instead:
+ *
+ * - spin_lock() calls local_bh_disable() -> sched_pin() -> td_pinned++
+ * td_pinned > 0 therefore means a linuxkpi spinlock is held, which is
+ * the context where Linux irqs_disabled() would have returned true.
+ *
+ * - td_critnest > 0 indicates a critical section (critical_enter() or
+ * an MTX_SPIN mutex), where sleeping is equally forbidden.
+ *
+ * Together these cover the cases where callers must spin with cpu_relax()
+ * rather than sleeping.
+ */
+static inline bool
+irqs_disabled(void)
+{
+ return (curthread->td_pinned > 0 || curthread->td_critnest > 0);
+}
+
#endif /* _LINUXKPI_LINUX_HARDIRQ_H_ */

File Metadata

Mime Type
text/plain
Expires
Wed, Jul 22, 11:08 PM (7 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34291478
Default Alt Text
D57782.diff (1 KB)

Event Timeline