]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/blob - rt-patches/0183-irqwork-Move-irq-safe-work-to-irq-context.patch
Fix memguard and related syscalls
[hercules2020/nv-tegra/linux-4.4.git] / rt-patches / 0183-irqwork-Move-irq-safe-work-to-irq-context.patch
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
5
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.
10
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
13 the timer softirq.
14
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
18 ---
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(-)
23
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) { }
30  #endif
31  
32 +#if defined(CONFIG_IRQ_WORK) && defined(CONFIG_PREEMPT_RT_FULL)
33 +void irq_work_tick_soft(void);
34 +#else
35 +static inline void irq_work_tick_soft(void) { }
36 +#endif
37 +
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)
44  
45         if (!llist_empty(raised) && !arch_irq_work_has_interrupt())
46                 irq_work_run_list(raised);
47 +
48 +       if (!IS_ENABLED(CONFIG_PREEMPT_RT_FULL))
49 +               irq_work_run_list(this_cpu_ptr(&lazy_list));
50 +}
51 +
52 +#if defined(CONFIG_IRQ_WORK) && defined(CONFIG_PREEMPT_RT_FULL)
53 +void irq_work_tick_soft(void)
54 +{
55         irq_work_run_list(this_cpu_ptr(&lazy_list));
56  }
57 +#endif
58  
59  /*
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)
66         scheduler_tick();
67         run_local_timers();
68         rcu_check_callbacks(user_tick);
69 -#if defined(CONFIG_IRQ_WORK) && !defined(CONFIG_PREEMPT_RT_FULL)
70 +#if defined(CONFIG_IRQ_WORK)
71         if (in_irq())
72                 irq_work_tick();
73  #endif
74 @@ -1498,9 +1498,7 @@ static void run_timer_softirq(struct softirq_action *h)
75  {
76         struct tvec_base *base = this_cpu_ptr(&tvec_bases);
77  
78 -#if defined(CONFIG_IRQ_WORK) && defined(CONFIG_PREEMPT_RT_FULL)
79 -       irq_work_tick();
80 -#endif
81 +       irq_work_tick_soft();
82  
83         if (time_after_eq(jiffies, base->timer_jiffies))
84                 __run_timers(base);
85 -- 
86 1.9.1
87