1 From bb74635ad455695063bb89d40207dffcd2742dcd Mon Sep 17 00:00:00 2001
2 From: Thomas Gleixner <tglx@linutronix.de>
3 Date: Sun, 15 Nov 2015 18:40:17 +0100
4 Subject: [PATCH 183/366] irqwork: Move irq safe work to irq context
6 On architectures where arch_irq_work_has_interrupt() returns false, we
7 end up running the irq safe work from the softirq context. That
8 results in a potential deadlock in the scheduler irq work which
9 expects that function to be called with interrupts disabled.
11 Split the irq_work_tick() function into a hard and soft variant. Call
12 the hard variant from the tick interrupt and add the soft variant to
15 Reported-and-tested-by: Yanjiang Jin <yanjiang.jin@windriver.com>
16 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
17 Cc: stable-rt@vger.kernel.org
19 include/linux/irq_work.h | 6 ++++++
20 kernel/irq_work.c | 9 +++++++++
21 kernel/time/timer.c | 6 ++----
22 3 files changed, 17 insertions(+), 4 deletions(-)
24 diff --git a/include/linux/irq_work.h b/include/linux/irq_work.h
25 index 0e427a9..2543aab 100644
26 --- a/include/linux/irq_work.h
27 +++ b/include/linux/irq_work.h
28 @@ -52,4 +52,10 @@ static inline bool irq_work_needs_cpu(void) { return false; }
29 static inline void irq_work_run(void) { }
32 +#if defined(CONFIG_IRQ_WORK) && defined(CONFIG_PREEMPT_RT_FULL)
33 +void irq_work_tick_soft(void);
35 +static inline void irq_work_tick_soft(void) { }
38 #endif /* _LINUX_IRQ_WORK_H */
39 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
40 index 0ddaf1e..2899ba0 100644
41 --- a/kernel/irq_work.c
42 +++ b/kernel/irq_work.c
43 @@ -200,8 +200,17 @@ void irq_work_tick(void)
45 if (!llist_empty(raised) && !arch_irq_work_has_interrupt())
46 irq_work_run_list(raised);
48 + if (!IS_ENABLED(CONFIG_PREEMPT_RT_FULL))
49 + irq_work_run_list(this_cpu_ptr(&lazy_list));
52 +#if defined(CONFIG_IRQ_WORK) && defined(CONFIG_PREEMPT_RT_FULL)
53 +void irq_work_tick_soft(void)
55 irq_work_run_list(this_cpu_ptr(&lazy_list));
60 * Synchronize against the irq_work @entry, ensures the entry is not
61 diff --git a/kernel/time/timer.c b/kernel/time/timer.c
62 index acfd69b..c3314fc 100644
63 --- a/kernel/time/timer.c
64 +++ b/kernel/time/timer.c
65 @@ -1484,7 +1484,7 @@ void update_process_times(int user_tick)
68 rcu_check_callbacks(user_tick);
69 -#if defined(CONFIG_IRQ_WORK) && !defined(CONFIG_PREEMPT_RT_FULL)
70 +#if defined(CONFIG_IRQ_WORK)
74 @@ -1498,9 +1498,7 @@ static void run_timer_softirq(struct softirq_action *h)
76 struct tvec_base *base = this_cpu_ptr(&tvec_bases);
78 -#if defined(CONFIG_IRQ_WORK) && defined(CONFIG_PREEMPT_RT_FULL)
81 + irq_work_tick_soft();
83 if (time_after_eq(jiffies, base->timer_jiffies))