summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPetr Mladek <pmladek@suse.com>2021-06-29 10:53:17 +0300
committerPetr Mladek <pmladek@suse.com>2021-06-29 10:53:17 +0300
commit94f2be50badfa88e96033e77621c6711d58f84d3 (patch)
treee12cd00f1cc461bbf9054e2ffb763739c158d267 /include
parentd8c032145fccfead0c3f733e7b6aaa4e81f9d326 (diff)
parent3342aa8e6b4f6e3f1521e9b4cf5cfe50dbc37774 (diff)
downloadlinux-94f2be50badfa88e96033e77621c6711d58f84d3.tar.xz
Merge branch 'printk-rework' into for-linus
Diffstat (limited to 'include')
-rw-r--r--include/linux/printk.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/linux/printk.h b/include/linux/printk.h
index fe7eb2351610..1790a5521fd9 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -282,6 +282,47 @@ static inline void printk_safe_flush_on_panic(void)
}
#endif
+#ifdef CONFIG_SMP
+extern int __printk_cpu_trylock(void);
+extern void __printk_wait_on_cpu_lock(void);
+extern void __printk_cpu_unlock(void);
+
+/**
+ * printk_cpu_lock_irqsave() - Acquire the printk cpu-reentrant spinning
+ * lock and disable interrupts.
+ * @flags: Stack-allocated storage for saving local interrupt state,
+ * to be passed to printk_cpu_unlock_irqrestore().
+ *
+ * If the lock is owned by another CPU, spin until it becomes available.
+ * Interrupts are restored while spinning.
+ */
+#define printk_cpu_lock_irqsave(flags) \
+ for (;;) { \
+ local_irq_save(flags); \
+ if (__printk_cpu_trylock()) \
+ break; \
+ local_irq_restore(flags); \
+ __printk_wait_on_cpu_lock(); \
+ }
+
+/**
+ * printk_cpu_unlock_irqrestore() - Release the printk cpu-reentrant spinning
+ * lock and restore interrupts.
+ * @flags: Caller's saved interrupt state, from printk_cpu_lock_irqsave().
+ */
+#define printk_cpu_unlock_irqrestore(flags) \
+ do { \
+ __printk_cpu_unlock(); \
+ local_irq_restore(flags); \
+ } while (0) \
+
+#else
+
+#define printk_cpu_lock_irqsave(flags) ((void)flags)
+#define printk_cpu_unlock_irqrestore(flags) ((void)flags)
+
+#endif /* CONFIG_SMP */
+
extern int kptr_restrict;
/**