Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F163309548
D57782.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D57782.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D57782: linuxkpi: implement irqs_disabled
Attached
Detach File
Event Timeline
Log In to Comment