[lkml]   [2010]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[tip:sched/urgent] printk: Fix wake_up_klogd() vs cpu hotplug
Commit-ID:  49f4138346b3cec2706adff02658fe27ceb1e46f
Author: Heiko Carstens <>
AuthorDate: Fri, 26 Nov 2010 13:42:47 +0100
Committer: Ingo Molnar <>
CommitDate: Fri, 26 Nov 2010 15:03:11 +0100

printk: Fix wake_up_klogd() vs cpu hotplug

wake_up_klogd() may get called from preemptible context but uses
__raw_get_cpu_var() to write to a per cpu variable. If it gets preempted
between getting the address and writing to it, the cpu in question could be
offline if the process gets scheduled back and hence writes to the per cpu data
of an offline cpu.

This buggy behaviour was introduced with fa33507a "printk: robustify
printk, fix #2" which was supposed to fix a "using smp_processor_id() in
preemptible" warning.

Let's use this_cpu_write() instead which disables preemption and makes sure
that the outlined scenario cannot happen.

Signed-off-by: Heiko Carstens <>
Acked-by: Eric Dumazet <>
Signed-off-by: Peter Zijlstra <>
LKML-Reference: <>
Signed-off-by: Ingo Molnar <>
kernel/printk.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/printk.c b/kernel/printk.c
index 9a2264f..cf7588e 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1088,7 +1088,7 @@ int printk_needs_cpu(int cpu)
void wake_up_klogd(void)
if (waitqueue_active(&log_wait))
- __raw_get_cpu_var(printk_pending) = 1;
+ this_cpu_write(printk_pending, 1);


 \ /
  Last update: 2010-11-26 16:05    [W:0.058 / U:0.320 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site