aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/irq_work.c
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2012-11-15 11:34:21 -0500
committerFrederic Weisbecker <fweisbec@gmail.com>2012-11-17 13:31:03 -0500
commitc0e980a4bd7fc5c9b748f2f0209d2a48c0fdf0ab (patch)
tree39eda738087b5bda53b0cb06c9549656266a03c2 /kernel/irq_work.c
parent00b42959106a9ca1c2899e591ae4e9a83ad6af05 (diff)
irq_work: Flush work on CPU_DYING
In order not to offline a CPU with pending irq works, flush the queue from CPU_DYING. The notifier is called by stop_machine on the CPU that is going down. The code will not be called from irq context (so things like get_irq_regs() wont work) but I'm not sure what the requirements are for irq_work in that regard (Peter?). But irqs are disabled and the CPU is about to go offline. Might as well flush the work. Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@kernel.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Diffstat (limited to 'kernel/irq_work.c')
-rw-r--r--kernel/irq_work.c51
1 files changed, 45 insertions, 6 deletions
diff --git a/kernel/irq_work.c b/kernel/irq_work.c
index b3c113a14727..4ed17490f629 100644
--- a/kernel/irq_work.c
+++ b/kernel/irq_work.c
@@ -12,6 +12,8 @@
12#include <linux/percpu.h> 12#include <linux/percpu.h>
13#include <linux/hardirq.h> 13#include <linux/hardirq.h>
14#include <linux/irqflags.h> 14#include <linux/irqflags.h>
15#include <linux/cpu.h>
16#include <linux/notifier.h>
15#include <asm/processor.h> 17#include <asm/processor.h>
16 18
17/* 19/*
@@ -110,11 +112,7 @@ bool irq_work_needs_cpu(void)
110 return true; 112 return true;
111} 113}
112 114
113/* 115static void __irq_work_run(void)
114 * Run the irq_work entries on this cpu. Requires to be ran from hardirq
115 * context with local IRQs disabled.
116 */
117void irq_work_run(void)
118{ 116{
119 struct irq_work *work; 117 struct irq_work *work;
120 struct llist_head *this_list; 118 struct llist_head *this_list;
@@ -124,7 +122,6 @@ void irq_work_run(void)
124 if (llist_empty(this_list)) 122 if (llist_empty(this_list))
125 return; 123 return;
126 124
127 BUG_ON(!in_irq());
128 BUG_ON(!irqs_disabled()); 125 BUG_ON(!irqs_disabled());
129 126
130 llnode = llist_del_all(this_list); 127 llnode = llist_del_all(this_list);
@@ -149,6 +146,16 @@ void irq_work_run(void)
149 (void)cmpxchg(&work->flags, IRQ_WORK_BUSY, 0); 146 (void)cmpxchg(&work->flags, IRQ_WORK_BUSY, 0);
150 } 147 }
151} 148}
149
150/*
151 * Run the irq_work entries on this cpu. Requires to be ran from hardirq
152 * context with local IRQs disabled.
153 */
154void irq_work_run(void)
155{
156 BUG_ON(!in_irq());
157 __irq_work_run();
158}
152EXPORT_SYMBOL_GPL(irq_work_run); 159EXPORT_SYMBOL_GPL(irq_work_run);
153 160
154/* 161/*
@@ -163,3 +170,35 @@ void irq_work_sync(struct irq_work *work)
163 cpu_relax(); 170 cpu_relax();
164} 171}
165EXPORT_SYMBOL_GPL(irq_work_sync); 172EXPORT_SYMBOL_GPL(irq_work_sync);
173
174#ifdef CONFIG_HOTPLUG_CPU
175static int irq_work_cpu_notify(struct notifier_block *self,
176 unsigned long action, void *hcpu)
177{
178 long cpu = (long)hcpu;
179
180 switch (action) {
181 case CPU_DYING:
182 /* Called from stop_machine */
183 if (WARN_ON_ONCE(cpu != smp_processor_id()))
184 break;
185 __irq_work_run();
186 break;
187 default:
188 break;
189 }
190 return NOTIFY_OK;
191}
192
193static struct notifier_block cpu_notify;
194
195static __init int irq_work_init_cpu_notifier(void)
196{
197 cpu_notify.notifier_call = irq_work_cpu_notify;
198 cpu_notify.priority = 0;
199 register_cpu_notifier(&cpu_notify);
200 return 0;
201}
202device_initcall(irq_work_init_cpu_notifier);
203
204#endif /* CONFIG_HOTPLUG_CPU */