aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/softirq.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/softirq.c')
-rw-r--r--kernel/softirq.c54
1 files changed, 45 insertions, 9 deletions
diff --git a/kernel/softirq.c b/kernel/softirq.c
index b24988353458..eb0acf44b063 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -213,14 +213,52 @@ EXPORT_SYMBOL(local_bh_enable_ip);
213#define MAX_SOFTIRQ_TIME msecs_to_jiffies(2) 213#define MAX_SOFTIRQ_TIME msecs_to_jiffies(2)
214#define MAX_SOFTIRQ_RESTART 10 214#define MAX_SOFTIRQ_RESTART 10
215 215
216#ifdef CONFIG_TRACE_IRQFLAGS
217/*
218 * Convoluted means of passing __do_softirq() a message through the various
219 * architecture execute_on_stack() bits.
220 *
221 * When we run softirqs from irq_exit() and thus on the hardirq stack we need
222 * to keep the lockdep irq context tracking as tight as possible in order to
223 * not miss-qualify lock contexts and miss possible deadlocks.
224 */
225static DEFINE_PER_CPU(int, softirq_from_hardirq);
226
227static inline void lockdep_softirq_from_hardirq(void)
228{
229 this_cpu_write(softirq_from_hardirq, 1);
230}
231
232static inline void lockdep_softirq_start(void)
233{
234 if (this_cpu_read(softirq_from_hardirq))
235 trace_hardirq_exit();
236 lockdep_softirq_enter();
237}
238
239static inline void lockdep_softirq_end(void)
240{
241 lockdep_softirq_exit();
242 if (this_cpu_read(softirq_from_hardirq)) {
243 this_cpu_write(softirq_from_hardirq, 0);
244 trace_hardirq_enter();
245 }
246}
247
248#else
249static inline void lockdep_softirq_from_hardirq(void) { }
250static inline void lockdep_softirq_start(void) { }
251static inline void lockdep_softirq_end(void) { }
252#endif
253
216asmlinkage void __do_softirq(void) 254asmlinkage void __do_softirq(void)
217{ 255{
218 struct softirq_action *h;
219 __u32 pending;
220 unsigned long end = jiffies + MAX_SOFTIRQ_TIME; 256 unsigned long end = jiffies + MAX_SOFTIRQ_TIME;
221 int cpu;
222 unsigned long old_flags = current->flags; 257 unsigned long old_flags = current->flags;
223 int max_restart = MAX_SOFTIRQ_RESTART; 258 int max_restart = MAX_SOFTIRQ_RESTART;
259 struct softirq_action *h;
260 __u32 pending;
261 int cpu;
224 262
225 /* 263 /*
226 * Mask out PF_MEMALLOC s current task context is borrowed for the 264 * Mask out PF_MEMALLOC s current task context is borrowed for the
@@ -233,7 +271,7 @@ asmlinkage void __do_softirq(void)
233 account_irq_enter_time(current); 271 account_irq_enter_time(current);
234 272
235 __local_bh_disable(_RET_IP_, SOFTIRQ_OFFSET); 273 __local_bh_disable(_RET_IP_, SOFTIRQ_OFFSET);
236 lockdep_softirq_enter(); 274 lockdep_softirq_start();
237 275
238 cpu = smp_processor_id(); 276 cpu = smp_processor_id();
239restart: 277restart:
@@ -280,16 +318,13 @@ restart:
280 wakeup_softirqd(); 318 wakeup_softirqd();
281 } 319 }
282 320
283 lockdep_softirq_exit(); 321 lockdep_softirq_end();
284
285 account_irq_exit_time(current); 322 account_irq_exit_time(current);
286 __local_bh_enable(SOFTIRQ_OFFSET); 323 __local_bh_enable(SOFTIRQ_OFFSET);
287 WARN_ON_ONCE(in_interrupt()); 324 WARN_ON_ONCE(in_interrupt());
288 tsk_restore_flags(current, old_flags, PF_MEMALLOC); 325 tsk_restore_flags(current, old_flags, PF_MEMALLOC);
289} 326}
290 327
291
292
293asmlinkage void do_softirq(void) 328asmlinkage void do_softirq(void)
294{ 329{
295 __u32 pending; 330 __u32 pending;
@@ -332,6 +367,7 @@ void irq_enter(void)
332static inline void invoke_softirq(void) 367static inline void invoke_softirq(void)
333{ 368{
334 if (!force_irqthreads) { 369 if (!force_irqthreads) {
370 lockdep_softirq_from_hardirq();
335#ifdef CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK 371#ifdef CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK
336 /* 372 /*
337 * We can safely execute softirq on the current stack if 373 * We can safely execute softirq on the current stack if
@@ -377,13 +413,13 @@ void irq_exit(void)
377#endif 413#endif
378 414
379 account_irq_exit_time(current); 415 account_irq_exit_time(current);
380 trace_hardirq_exit();
381 preempt_count_sub(HARDIRQ_OFFSET); 416 preempt_count_sub(HARDIRQ_OFFSET);
382 if (!in_interrupt() && local_softirq_pending()) 417 if (!in_interrupt() && local_softirq_pending())
383 invoke_softirq(); 418 invoke_softirq();
384 419
385 tick_irq_exit(); 420 tick_irq_exit();
386 rcu_irq_exit(); 421 rcu_irq_exit();
422 trace_hardirq_exit(); /* must be last! */
387} 423}
388 424
389/* 425/*