lkml.org 
[lkml]   [2007]   [Jun]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH RT] Only allow atomic safe consoles to print in atomic areas.
From
Date
Since PREEMPT_RT makes spin_locks schedule, and some consoles (namely
serial) use spin locks in the write method. This patch creates a new
console flag called CON_ATOMIC which is set by safe consoles that do not
grab spinlocks.

On PREEMPT_RT only safe consoles will write within non atomic operations
(and not in a oops).

Signed-off-by: Steven Rostedt

Index: linux-2.6-rt-test/arch/x86_64/kernel/early_printk.c
===================================================================
--- linux-2.6-rt-test.orig/arch/x86_64/kernel/early_printk.c
+++ linux-2.6-rt-test/arch/x86_64/kernel/early_printk.c
@@ -56,7 +56,7 @@ static void early_vga_write(struct conso
static struct console early_vga_console = {
.name = "earlyvga",
.write = early_vga_write,
- .flags = CON_PRINTBUFFER,
+ .flags = CON_PRINTBUFFER | CON_ATOMIC,
.index = -1,
};

@@ -152,7 +152,7 @@ static __init void early_serial_init(cha
static struct console early_serial_console = {
.name = "earlyser",
.write = early_serial_write,
- .flags = CON_PRINTBUFFER,
+ .flags = CON_PRINTBUFFER | CON_ATOMIC,
.index = -1,
};

@@ -193,7 +193,7 @@ static void simnow_write(struct console
static struct console simnow_console = {
.name = "simnow",
.write = simnow_write,
- .flags = CON_PRINTBUFFER,
+ .flags = CON_PRINTBUFFER | CON_ATOMIC,
.index = -1,
};

Index: linux-2.6-rt-test/drivers/char/vt.c
===================================================================
--- linux-2.6-rt-test.orig/drivers/char/vt.c
+++ linux-2.6-rt-test/drivers/char/vt.c
@@ -2317,7 +2317,7 @@ static struct console vt_console_driver
.write = vt_console_print,
.device = vt_console_device,
.unblank = unblank_screen,
- .flags = CON_PRINTBUFFER,
+ .flags = CON_PRINTBUFFER | CON_ATOMIC,
.index = -1,
};
#endif
Index: linux-2.6-rt-test/include/linux/console.h
===================================================================
--- linux-2.6-rt-test.orig/include/linux/console.h
+++ linux-2.6-rt-test/include/linux/console.h
@@ -92,6 +92,17 @@ void give_up_console(const struct consw
#define CON_ENABLED (4)
#define CON_BOOT (8)
#define CON_ANYTIME (16) /* Safe to call when cpu is offline */
+#define CON_ATOMIC (32) /* Safe to call in PREEMPT_RT atomic */
+
+#ifdef CONFIG_PREEMPT_RT
+# define console_atomic_safe(con) \
+ (((con)->flags & CON_ATOMIC) || \
+ (!in_atomic() && !irqs_disabled()) || \
+ (system_state != SYSTEM_RUNNING) || \
+ oops_in_progress)
+#else
+# define console_atomic_safe(con) (1)
+#endif

struct console
{
Index: linux-2.6-rt-test/kernel/printk.c
===================================================================
--- linux-2.6-rt-test.orig/kernel/printk.c
+++ linux-2.6-rt-test/kernel/printk.c
@@ -328,6 +328,7 @@ static void __call_console_drivers(unsig
touch_critical_timing();
for (con = console_drivers; con; con = con->next) {
if ((con->flags & CON_ENABLED) && con->write &&
+ console_atomic_safe(con) &&
(cpu_online(raw_smp_processor_id()) ||
(con->flags & CON_ANYTIME))) {
/*

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-06-19 20:55    [W:0.123 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site