--- /dev/null
+From 76a33061b9323b7fdb220ae5fa116c10833ec22e Mon Sep 17 00:00:00 2001
+From: Frederic Weisbecker <fweisbec@gmail.com>
+Date: Sat, 16 Aug 2014 18:37:19 +0200
+Subject: irq_work: Force raised irq work to run on irq work interrupt
+
+From: Frederic Weisbecker <fweisbec@gmail.com>
+
+commit 76a33061b9323b7fdb220ae5fa116c10833ec22e upstream.
+
+The nohz full kick, which restarts the tick when any resource depend
+on it, can't be executed anywhere given the operation it does on timers.
+If it is called from the scheduler or timers code, chances are that
+we run into a deadlock.
+
+This is why we run the nohz full kick from an irq work. That way we make
+sure that the kick runs on a virgin context.
+
+However if that's the case when irq work runs in its own dedicated
+self-ipi, things are different for the big bunch of archs that don't
+support the self triggered way. In order to support them, irq works are
+also handled by the timer interrupt as fallback.
+
+Now when irq works run on the timer interrupt, the context isn't blank.
+More precisely, they can run in the context of the hrtimer that runs the
+tick. But the nohz kick cancels and restarts this hrtimer and cancelling
+an hrtimer from itself isn't allowed. This is why we run in an endless
+loop:
+
+ Kernel panic - not syncing: Watchdog detected hard LOCKUP on cpu 2
+ CPU: 2 PID: 7538 Comm: kworker/u8:8 Not tainted 3.16.0+ #34
+ Workqueue: btrfs-endio-write normal_work_helper [btrfs]
+ ffff880244c06c88 000000001b486fe1 ffff880244c06bf0 ffffffff8a7f1e37
+ ffffffff8ac52a18 ffff880244c06c78 ffffffff8a7ef928 0000000000000010
+ ffff880244c06c88 ffff880244c06c20 000000001b486fe1 0000000000000000
+ Call Trace:
+ <NMI[<ffffffff8a7f1e37>] dump_stack+0x4e/0x7a
+ [<ffffffff8a7ef928>] panic+0xd4/0x207
+ [<ffffffff8a1450e8>] watchdog_overflow_callback+0x118/0x120
+ [<ffffffff8a186b0e>] __perf_event_overflow+0xae/0x350
+ [<ffffffff8a184f80>] ? perf_event_task_disable+0xa0/0xa0
+ [<ffffffff8a01a4cf>] ? x86_perf_event_set_period+0xbf/0x150
+ [<ffffffff8a187934>] perf_event_overflow+0x14/0x20
+ [<ffffffff8a020386>] intel_pmu_handle_irq+0x206/0x410
+ [<ffffffff8a01937b>] perf_event_nmi_handler+0x2b/0x50
+ [<ffffffff8a007b72>] nmi_handle+0xd2/0x390
+ [<ffffffff8a007aa5>] ? nmi_handle+0x5/0x390
+ [<ffffffff8a0cb7f8>] ? match_held_lock+0x8/0x1b0
+ [<ffffffff8a008062>] default_do_nmi+0x72/0x1c0
+ [<ffffffff8a008268>] do_nmi+0xb8/0x100
+ [<ffffffff8a7ff66a>] end_repeat_nmi+0x1e/0x2e
+ [<ffffffff8a0cb7f8>] ? match_held_lock+0x8/0x1b0
+ [<ffffffff8a0cb7f8>] ? match_held_lock+0x8/0x1b0
+ [<ffffffff8a0cb7f8>] ? match_held_lock+0x8/0x1b0
+ <<EOE><IRQ[<ffffffff8a0ccd2f>] lock_acquired+0xaf/0x450
+ [<ffffffff8a0f74c5>] ? lock_hrtimer_base.isra.20+0x25/0x50
+ [<ffffffff8a7fc678>] _raw_spin_lock_irqsave+0x78/0x90
+ [<ffffffff8a0f74c5>] ? lock_hrtimer_base.isra.20+0x25/0x50
+ [<ffffffff8a0f74c5>] lock_hrtimer_base.isra.20+0x25/0x50
+ [<ffffffff8a0f7723>] hrtimer_try_to_cancel+0x33/0x1e0
+ [<ffffffff8a0f78ea>] hrtimer_cancel+0x1a/0x30
+ [<ffffffff8a109237>] tick_nohz_restart+0x17/0x90
+ [<ffffffff8a10a213>] __tick_nohz_full_check+0xc3/0x100
+ [<ffffffff8a10a25e>] nohz_full_kick_work_func+0xe/0x10
+ [<ffffffff8a17c884>] irq_work_run_list+0x44/0x70
+ [<ffffffff8a17c8da>] irq_work_run+0x2a/0x50
+ [<ffffffff8a0f700b>] update_process_times+0x5b/0x70
+ [<ffffffff8a109005>] tick_sched_handle.isra.21+0x25/0x60
+ [<ffffffff8a109b81>] tick_sched_timer+0x41/0x60
+ [<ffffffff8a0f7aa2>] __run_hrtimer+0x72/0x470
+ [<ffffffff8a109b40>] ? tick_sched_do_timer+0xb0/0xb0
+ [<ffffffff8a0f8707>] hrtimer_interrupt+0x117/0x270
+ [<ffffffff8a034357>] local_apic_timer_interrupt+0x37/0x60
+ [<ffffffff8a80010f>] smp_apic_timer_interrupt+0x3f/0x50
+ [<ffffffff8a7fe52f>] apic_timer_interrupt+0x6f/0x80
+
+To fix this we force non-lazy irq works to run on irq work self-IPIs
+when available. That ability of the arch to trigger irq work self IPIs
+is available with arch_irq_work_has_interrupt().
+
+Reported-by: Catalin Iacob <iacobcatalin@gmail.com>
+Reported-by: Dave Jones <davej@redhat.com>
+Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Cc: Ingo Molnar <mingo@kernel.org>
+Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ include/linux/irq_work.h | 1 +
+ kernel/irq_work.c | 15 +++++++++++++--
+ kernel/time/timer.c | 2 +-
+ 3 files changed, 15 insertions(+), 3 deletions(-)
+
+--- a/include/linux/irq_work.h
++++ b/include/linux/irq_work.h
+@@ -39,6 +39,7 @@ bool irq_work_queue_on(struct irq_work *
+ #endif
+
+ void irq_work_run(void);
++void irq_work_tick(void);
+ void irq_work_sync(struct irq_work *work);
+
+ #ifdef CONFIG_IRQ_WORK
+--- a/kernel/irq_work.c
++++ b/kernel/irq_work.c
+@@ -115,8 +115,10 @@ bool irq_work_needs_cpu(void)
+
+ raised = &__get_cpu_var(raised_list);
+ lazy = &__get_cpu_var(lazy_list);
+- if (llist_empty(raised) && llist_empty(lazy))
+- return false;
++
++ if (llist_empty(raised) || arch_irq_work_has_interrupt())
++ if (llist_empty(lazy))
++ return false;
+
+ /* All work should have been flushed before going offline */
+ WARN_ON_ONCE(cpu_is_offline(smp_processor_id()));
+@@ -171,6 +173,15 @@ void irq_work_run(void)
+ }
+ EXPORT_SYMBOL_GPL(irq_work_run);
+
++void irq_work_tick(void)
++{
++ struct llist_head *raised = &__get_cpu_var(raised_list);
++
++ if (!llist_empty(raised) && !arch_irq_work_has_interrupt())
++ irq_work_run_list(raised);
++ irq_work_run_list(&__get_cpu_var(lazy_list));
++}
++
+ /*
+ * Synchronize against the irq_work @entry, ensures the entry is not
+ * currently in use.
+--- a/kernel/time/timer.c
++++ b/kernel/time/timer.c
+@@ -1385,7 +1385,7 @@ void update_process_times(int user_tick)
+ rcu_check_callbacks(cpu, user_tick);
+ #ifdef CONFIG_IRQ_WORK
+ if (in_irq())
+- irq_work_run();
++ irq_work_tick();
+ #endif
+ scheduler_tick();
+ run_posix_cpu_timers(p);
--- /dev/null
+From c5c38ef3d70377dc504a6a3f611a3ec814bc757b Mon Sep 17 00:00:00 2001
+From: Peter Zijlstra <peterz@infradead.org>
+Date: Sat, 6 Sep 2014 15:43:02 +0200
+Subject: irq_work: Introduce arch_irq_work_has_interrupt()
+
+From: Peter Zijlstra <peterz@infradead.org>
+
+commit c5c38ef3d70377dc504a6a3f611a3ec814bc757b upstream.
+
+The nohz full code needs irq work to trigger its own interrupt so that
+the subsystem can work even when the tick is stopped.
+
+Lets introduce arch_irq_work_has_interrupt() that archs can override to
+tell about their support for this ability.
+
+Signed-off-by: Peter Zijlstra <peterz@infradead.org>
+Cc: Ingo Molnar <mingo@kernel.org>
+Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/alpha/include/asm/Kbuild | 1 +
+ arch/arc/include/asm/Kbuild | 1 +
+ arch/arm/include/asm/Kbuild | 1 +
+ arch/arm64/include/asm/Kbuild | 3 ++-
+ arch/avr32/include/asm/Kbuild | 1 +
+ arch/blackfin/include/asm/Kbuild | 1 +
+ arch/c6x/include/asm/Kbuild | 1 +
+ arch/cris/include/asm/Kbuild | 1 +
+ arch/frv/include/asm/Kbuild | 1 +
+ arch/hexagon/include/asm/Kbuild | 1 +
+ arch/ia64/include/asm/Kbuild | 1 +
+ arch/m32r/include/asm/Kbuild | 1 +
+ arch/m68k/include/asm/Kbuild | 1 +
+ arch/metag/include/asm/Kbuild | 1 +
+ arch/microblaze/include/asm/Kbuild | 1 +
+ arch/mips/include/asm/Kbuild | 1 +
+ arch/mn10300/include/asm/Kbuild | 1 +
+ arch/openrisc/include/asm/Kbuild | 1 +
+ arch/parisc/include/asm/Kbuild | 1 +
+ arch/powerpc/include/asm/Kbuild | 1 +
+ arch/s390/include/asm/Kbuild | 1 +
+ arch/score/include/asm/Kbuild | 1 +
+ arch/sh/include/asm/Kbuild | 1 +
+ arch/sparc/include/asm/Kbuild | 1 +
+ arch/tile/include/asm/Kbuild | 1 +
+ arch/um/include/asm/Kbuild | 1 +
+ arch/unicore32/include/asm/Kbuild | 1 +
+ arch/x86/include/asm/Kbuild | 1 +
+ arch/xtensa/include/asm/Kbuild | 1 +
+ include/asm-generic/irq_work.h | 10 ++++++++++
+ include/linux/irq_work.h | 2 ++
+ 31 files changed, 42 insertions(+), 1 deletion(-)
+
+--- a/arch/alpha/include/asm/Kbuild
++++ b/arch/alpha/include/asm/Kbuild
+@@ -4,6 +4,7 @@ generic-y += clkdev.h
+ generic-y += cputime.h
+ generic-y += exec.h
+ generic-y += hash.h
++generic-y += irq_work.h
+ generic-y += mcs_spinlock.h
+ generic-y += preempt.h
+ generic-y += scatterlist.h
+--- a/arch/arc/include/asm/Kbuild
++++ b/arch/arc/include/asm/Kbuild
+@@ -18,6 +18,7 @@ generic-y += ioctl.h
+ generic-y += ioctls.h
+ generic-y += ipcbuf.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += kmap_types.h
+ generic-y += kvm_para.h
+ generic-y += local.h
+--- a/arch/arm/include/asm/Kbuild
++++ b/arch/arm/include/asm/Kbuild
+@@ -11,6 +11,7 @@ generic-y += hash.h
+ generic-y += ioctl.h
+ generic-y += ipcbuf.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += kdebug.h
+ generic-y += local.h
+ generic-y += local64.h
+--- a/arch/arm64/include/asm/Kbuild
++++ b/arch/arm64/include/asm/Kbuild
+@@ -9,8 +9,8 @@ generic-y += current.h
+ generic-y += delay.h
+ generic-y += div64.h
+ generic-y += dma.h
+-generic-y += emergency-restart.h
+ generic-y += early_ioremap.h
++generic-y += emergency-restart.h
+ generic-y += errno.h
+ generic-y += ftrace.h
+ generic-y += hash.h
+@@ -19,6 +19,7 @@ generic-y += ioctl.h
+ generic-y += ioctls.h
+ generic-y += ipcbuf.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += kdebug.h
+ generic-y += kmap_types.h
+ generic-y += kvm_para.h
+--- a/arch/avr32/include/asm/Kbuild
++++ b/arch/avr32/include/asm/Kbuild
+@@ -9,6 +9,7 @@ generic-y += exec.h
+ generic-y += futex.h
+ generic-y += hash.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += local.h
+ generic-y += local64.h
+ generic-y += mcs_spinlock.h
+--- a/arch/blackfin/include/asm/Kbuild
++++ b/arch/blackfin/include/asm/Kbuild
+@@ -15,6 +15,7 @@ generic-y += hw_irq.h
+ generic-y += ioctl.h
+ generic-y += ipcbuf.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += kdebug.h
+ generic-y += kmap_types.h
+ generic-y += kvm_para.h
+--- a/arch/c6x/include/asm/Kbuild
++++ b/arch/c6x/include/asm/Kbuild
+@@ -22,6 +22,7 @@ generic-y += ioctl.h
+ generic-y += ioctls.h
+ generic-y += ipcbuf.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += kdebug.h
+ generic-y += kmap_types.h
+ generic-y += local.h
+--- a/arch/cris/include/asm/Kbuild
++++ b/arch/cris/include/asm/Kbuild
+@@ -8,6 +8,7 @@ generic-y += clkdev.h
+ generic-y += cputime.h
+ generic-y += exec.h
+ generic-y += hash.h
++generic-y += irq_work.h
+ generic-y += kvm_para.h
+ generic-y += linkage.h
+ generic-y += mcs_spinlock.h
+--- a/arch/frv/include/asm/Kbuild
++++ b/arch/frv/include/asm/Kbuild
+@@ -3,6 +3,7 @@ generic-y += clkdev.h
+ generic-y += cputime.h
+ generic-y += exec.h
+ generic-y += hash.h
++generic-y += irq_work.h
+ generic-y += mcs_spinlock.h
+ generic-y += preempt.h
+ generic-y += scatterlist.h
+--- a/arch/hexagon/include/asm/Kbuild
++++ b/arch/hexagon/include/asm/Kbuild
+@@ -23,6 +23,7 @@ generic-y += ioctls.h
+ generic-y += iomap.h
+ generic-y += ipcbuf.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += kdebug.h
+ generic-y += kmap_types.h
+ generic-y += local.h
+--- a/arch/ia64/include/asm/Kbuild
++++ b/arch/ia64/include/asm/Kbuild
+@@ -2,6 +2,7 @@
+ generic-y += clkdev.h
+ generic-y += exec.h
+ generic-y += hash.h
++generic-y += irq_work.h
+ generic-y += kvm_para.h
+ generic-y += mcs_spinlock.h
+ generic-y += preempt.h
+--- a/arch/m32r/include/asm/Kbuild
++++ b/arch/m32r/include/asm/Kbuild
+@@ -3,6 +3,7 @@ generic-y += clkdev.h
+ generic-y += cputime.h
+ generic-y += exec.h
+ generic-y += hash.h
++generic-y += irq_work.h
+ generic-y += mcs_spinlock.h
+ generic-y += module.h
+ generic-y += preempt.h
+--- a/arch/m68k/include/asm/Kbuild
++++ b/arch/m68k/include/asm/Kbuild
+@@ -11,6 +11,7 @@ generic-y += hw_irq.h
+ generic-y += ioctl.h
+ generic-y += ipcbuf.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += kdebug.h
+ generic-y += kmap_types.h
+ generic-y += kvm_para.h
+--- a/arch/metag/include/asm/Kbuild
++++ b/arch/metag/include/asm/Kbuild
+@@ -19,6 +19,7 @@ generic-y += ioctl.h
+ generic-y += ioctls.h
+ generic-y += ipcbuf.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += kdebug.h
+ generic-y += kmap_types.h
+ generic-y += kvm_para.h
+--- a/arch/microblaze/include/asm/Kbuild
++++ b/arch/microblaze/include/asm/Kbuild
+@@ -5,6 +5,7 @@ generic-y += cputime.h
+ generic-y += device.h
+ generic-y += exec.h
+ generic-y += hash.h
++generic-y += irq_work.h
+ generic-y += mcs_spinlock.h
+ generic-y += preempt.h
+ generic-y += scatterlist.h
+--- a/arch/mips/include/asm/Kbuild
++++ b/arch/mips/include/asm/Kbuild
+@@ -3,6 +3,7 @@ generic-y += cputime.h
+ generic-y += current.h
+ generic-y += emergency-restart.h
+ generic-y += hash.h
++generic-y += irq_work.h
+ generic-y += local64.h
+ generic-y += mcs_spinlock.h
+ generic-y += mutex.h
+--- a/arch/mn10300/include/asm/Kbuild
++++ b/arch/mn10300/include/asm/Kbuild
+@@ -4,6 +4,7 @@ generic-y += clkdev.h
+ generic-y += cputime.h
+ generic-y += exec.h
+ generic-y += hash.h
++generic-y += irq_work.h
+ generic-y += mcs_spinlock.h
+ generic-y += preempt.h
+ generic-y += scatterlist.h
+--- a/arch/openrisc/include/asm/Kbuild
++++ b/arch/openrisc/include/asm/Kbuild
+@@ -31,6 +31,7 @@ generic-y += ioctl.h
+ generic-y += ioctls.h
+ generic-y += ipcbuf.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += kdebug.h
+ generic-y += kmap_types.h
+ generic-y += kvm_para.h
+--- a/arch/parisc/include/asm/Kbuild
++++ b/arch/parisc/include/asm/Kbuild
+@@ -10,6 +10,7 @@ generic-y += exec.h
+ generic-y += hash.h
+ generic-y += hw_irq.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += kdebug.h
+ generic-y += kvm_para.h
+ generic-y += local.h
+--- a/arch/powerpc/include/asm/Kbuild
++++ b/arch/powerpc/include/asm/Kbuild
+@@ -1,6 +1,7 @@
+
+ generic-y += clkdev.h
+ generic-y += hash.h
++generic-y += irq_work.h
+ generic-y += mcs_spinlock.h
+ generic-y += preempt.h
+ generic-y += rwsem.h
+--- a/arch/s390/include/asm/Kbuild
++++ b/arch/s390/include/asm/Kbuild
+@@ -2,6 +2,7 @@
+
+ generic-y += clkdev.h
+ generic-y += hash.h
++generic-y += irq_work.h
+ generic-y += mcs_spinlock.h
+ generic-y += preempt.h
+ generic-y += scatterlist.h
+--- a/arch/score/include/asm/Kbuild
++++ b/arch/score/include/asm/Kbuild
+@@ -6,6 +6,7 @@ generic-y += barrier.h
+ generic-y += clkdev.h
+ generic-y += cputime.h
+ generic-y += hash.h
++generic-y += irq_work.h
+ generic-y += mcs_spinlock.h
+ generic-y += preempt.h
+ generic-y += scatterlist.h
+--- a/arch/sh/include/asm/Kbuild
++++ b/arch/sh/include/asm/Kbuild
+@@ -12,6 +12,7 @@ generic-y += hash.h
+ generic-y += ioctl.h
+ generic-y += ipcbuf.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += kvm_para.h
+ generic-y += local.h
+ generic-y += local64.h
+--- a/arch/sparc/include/asm/Kbuild
++++ b/arch/sparc/include/asm/Kbuild
+@@ -8,6 +8,7 @@ generic-y += emergency-restart.h
+ generic-y += exec.h
+ generic-y += hash.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += linkage.h
+ generic-y += local.h
+ generic-y += local64.h
+--- a/arch/tile/include/asm/Kbuild
++++ b/arch/tile/include/asm/Kbuild
+@@ -17,6 +17,7 @@ generic-y += ioctl.h
+ generic-y += ioctls.h
+ generic-y += ipcbuf.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += local.h
+ generic-y += local64.h
+ generic-y += mcs_spinlock.h
+--- a/arch/um/include/asm/Kbuild
++++ b/arch/um/include/asm/Kbuild
+@@ -14,6 +14,7 @@ generic-y += hash.h
+ generic-y += hw_irq.h
+ generic-y += io.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += kdebug.h
+ generic-y += mcs_spinlock.h
+ generic-y += mutex.h
+--- a/arch/unicore32/include/asm/Kbuild
++++ b/arch/unicore32/include/asm/Kbuild
+@@ -22,6 +22,7 @@ generic-y += ioctl.h
+ generic-y += ioctls.h
+ generic-y += ipcbuf.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += kdebug.h
+ generic-y += kmap_types.h
+ generic-y += local.h
+--- a/arch/x86/include/asm/Kbuild
++++ b/arch/x86/include/asm/Kbuild
+@@ -7,5 +7,6 @@ genhdr-y += unistd_x32.h
+ generic-y += clkdev.h
+ generic-y += cputime.h
+ generic-y += early_ioremap.h
++generic-y += irq_work.h
+ generic-y += mcs_spinlock.h
+ generic-y += scatterlist.h
+--- a/arch/xtensa/include/asm/Kbuild
++++ b/arch/xtensa/include/asm/Kbuild
+@@ -12,6 +12,7 @@ generic-y += hardirq.h
+ generic-y += hash.h
+ generic-y += ioctl.h
+ generic-y += irq_regs.h
++generic-y += irq_work.h
+ generic-y += kdebug.h
+ generic-y += kmap_types.h
+ generic-y += kvm_para.h
+--- /dev/null
++++ b/include/asm-generic/irq_work.h
+@@ -0,0 +1,10 @@
++#ifndef __ASM_IRQ_WORK_H
++#define __ASM_IRQ_WORK_H
++
++static inline bool arch_irq_work_has_interrupt(void)
++{
++ return false;
++}
++
++#endif /* __ASM_IRQ_WORK_H */
++
+--- a/include/linux/irq_work.h
++++ b/include/linux/irq_work.h
+@@ -42,6 +42,8 @@ void irq_work_run(void);
+ void irq_work_sync(struct irq_work *work);
+
+ #ifdef CONFIG_IRQ_WORK
++#include <asm/irq_work.h>
++
+ bool irq_work_needs_cpu(void);
+ #else
+ static inline bool irq_work_needs_cpu(void) { return false; }