aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/printk.c
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2010-11-26 07:42:47 -0500
committerIngo Molnar <mingo@elte.hu>2010-11-26 09:03:11 -0500
commit49f4138346b3cec2706adff02658fe27ceb1e46f (patch)
tree20259bf8196685766e8b4d3ae761102a0f635913 /kernel/printk.c
parentd5ad140bc1505a98c0f040937125bfcbb508078f (diff)
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 <heiko.carstens@de.ibm.com> Acked-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <20101126124247.GC7023@osiris.boeblingen.de.ibm.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/printk.c')
-rw-r--r--kernel/printk.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/printk.c b/kernel/printk.c
index 9a2264fc42ca..cf7588e93f6f 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1088,7 +1088,7 @@ int printk_needs_cpu(int cpu)
1088void wake_up_klogd(void) 1088void wake_up_klogd(void)
1089{ 1089{
1090 if (waitqueue_active(&log_wait)) 1090 if (waitqueue_active(&log_wait))
1091 __raw_get_cpu_var(printk_pending) = 1; 1091 this_cpu_write(printk_pending, 1);
1092} 1092}
1093 1093
1094/** 1094/**