[PATCH 2/3] printk: Remove per-cpu printk flags

From: Jan Kara
Date: Wed Feb 06 2013 - 13:15:30 EST


There's no need to have printk flags percpu. Just make a single variable
operated by atomic operations from it. It also has an advantage that any
cpu can do the printing / wakeup work.

Signed-off-by: Jan Kara <jack@xxxxxxx>
---
kernel/printk.c | 28 ++++++++++++----------------
1 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/kernel/printk.c b/kernel/printk.c
index ed630fa..2fe917d 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1986,28 +1986,24 @@ int is_console_locked(void)
return console_locked;
}

-/*
- * Delayed printk version, for scheduler-internal messages:
- */
-#define PRINTK_BUF_SIZE 512
+#define PRINTK_PENDING_WAKEUP 1
+#define PRINTK_PENDING_OUTPUT 2

-#define PRINTK_PENDING_WAKEUP 0x01
-#define PRINTK_PENDING_OUTPUT 0x02
-
-static DEFINE_PER_CPU(int, printk_pending);
+static unsigned long printk_pending;

void printk_tick(void)
{
- if (__this_cpu_read(printk_pending)) {
- int pending = __this_cpu_xchg(printk_pending, 0);
- if (pending & PRINTK_PENDING_OUTPUT) {
+ if (printk_pending) {
+ unsigned long pending = xchg(&printk_pending, 0);
+
+ if (test_bit(PRINTK_PENDING_OUTPUT, &pending)) {
if (console_trylock())
console_unlock();
else
/* Try again later */
- __this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT);
+ set_bit(PRINTK_PENDING_OUTPUT, &printk_pending);
}
- if (pending & PRINTK_PENDING_WAKEUP)
+ if (test_bit(PRINTK_PENDING_WAKEUP, &pending))
wake_up_interruptible(&log_wait);
}
}
@@ -2016,13 +2012,13 @@ int printk_needs_cpu(int cpu)
{
if (cpu_is_offline(cpu))
printk_tick();
- return __this_cpu_read(printk_pending);
+ return printk_pending;
}

void wake_up_klogd(void)
{
if (waitqueue_active(&log_wait))
- this_cpu_or(printk_pending, PRINTK_PENDING_WAKEUP);
+ set_bit(PRINTK_PENDING_WAKEUP, &printk_pending);
}

static void console_cont_flush(char *text, size_t size)
@@ -2497,7 +2493,7 @@ int printk_sched(const char *fmt, ...)
r = vprintk_emit(0, -2, NULL, 0, fmt, args);
va_end(args);

- __this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT);
+ set_bit(PRINTK_PENDING_OUTPUT, &printk_pending);

return r;
}
--
1.7.1

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