Re: high prioritized threaded interrupt is delayed due to low priority softirq job

yosi yarchi
2022-11-17T07:14:23Z

Hi

I hope this mail will be more readable (prev mail lines had been cut):

my platform is:

1. SAM9X35 (8 CAN mailboxes),

2. Linux mscb 5.4.41-linux4sam-2020.04-rt24 #1 PREEMPT_RT Wed Nov 9
06:12:28 UTC 2022 armv5tejl GNU/Linux

3. CAN threaded interrupt (irq/30-can0-346) is configured to be highest
priority on system, and it is scheduled very quickly after CAN
irq_handler expires (irq_handler_entry: irq=30 name=can0), doing its job
(at91_irq).

my problem is that from time to time I get CAN RX overflow. problem
analysis is as the following (see trace below): after CAN threaded
interrupt completes its job (at91_irq_r), scheduler force it to run some
other low priority softirq jobs (softirq_entry: vec=1 [action=TIMER],
softirq_entry: vec=3 [action=NET_RX]). during the processing of those
jobs, new HW CAN irq_handler expires (irq_handler_entry: irq=30
name=can0), but scheduler schedule the at91_irq job at the end of job
queue, which is too late, and I get CAN rx overflow.

I've tried some solutions, no one worked out of the box:

1. disable all relevant irqs (timer, network) at CAN irq_handler
(irq_handler_entry: irq=30 name=can0), and enable them at the end of CAN
threaded interrupt job processing (at91_irq_r)

2. configure CAN job (at91_irq) to run inside the CAN irq_handler
(irq_handler_entry: irq=30 name=can0) by adding IRQF_NO_THREAD flag to
request_irq.

is there built-in solution for this problem at linux-rt?
if not, what could be good 'hacked' solutions for the problem?

with best regards
Yosi Yarchi

kernel trace:
-------------

<idle>-0   d..h1 1859: irq_handler_entry: irq=30 name=can0
<idle>-0   d..h1 1875: irq_handler_exit: irq=30 ret=handled
irq/30-can0-346 d.... 1972: at91_irq: (at91_irq+0x0/0xab0)
irq/30-can0-346 d...1 2090: at91_irq_r: (irq_forced_thread_fn+0x3c/0
<idle>-0   d..h1 2330: irq_handler_entry: irq=30 name=can0
<idle>-0   d..h1 2347: irq_handler_exit: irq=30 ret=handled
irq/30-can0-346 d.... 2438: at91_irq: (at91_irq+0x0/0xab0)
irq/30-can0-346 d...1 2553: at91_irq_r: (irq_forced_thread_fn+0x3c/0
<idle>-0   d..h1 2812: irq_handler_entry: irq=30 name=can0
<idle>-0   d..h1 2829: irq_handler_exit: irq=30 ret=handled
irq/30-can0-346 d.... 2923: at91_irq: (at91_irq+0x0/0xab0)
irq/30-can0-346 d...1 3040: at91_irq_r: (irq_forced_thread_fn+0x3c/0
<idle>-0   d..h1 3290: irq_handler_entry: irq=30 name=can0
<idle>-0   d..h1 3308: irq_handler_exit: irq=30 ret=handled
irq/30-can0-346 d.... 3400: at91_irq: (at91_irq+0x0/0xab0)
irq/30-can0-346 d...1 3514: at91_irq_r: (irq_forced_thread_fn+0x3c/0
<idle>-0   d..h1 3781: irq_handler_entry: irq=30 name=can0
<idle>-0   d..h1 3799: irq_handler_exit: irq=30 ret=handled
irq/30-can0-346 d..h. 3891: irq_handler_entry: irq=16 name=tc_clkevt
irq/30-can0-346 d..h. 3956: softirq_raise: vec=1 [action=TIMER]
irq/30-can0-346 d..h. 4006: irq_handler_exit: irq=16 ret=handled
irq/30-can0-346 d.... 4048: at91_irq: (at91_irq+0x0/0xab0)
irq/30-can0-346 d...1 4169: at91_irq_r: (irq_forced_thread_fn+0x3c/0
irq/30-can0-346 ..... 4207: softirq_entry: vec=1 [action=TIMER]
irq/30-can0-346 d..h1 4254: irq_handler_entry: irq=30 name=can0
irq/30-can0-346 d..h1 4267: irq_handler_exit: irq=30 ret=handled
irq/30-can0-346 d.... 4493: softirq_raise: vec=3 [action=NET_RX]
irq/30-can0-346 ..... 5282: softirq_exit: vec=1 [action=TIMER]
irq/30-can0-346 ..... 5306: softirq_entry: vec=3 [action=NET_RX]
irq/30-can0-346 d..h. 5607: irq_handler_entry: irq=16 name=tc_clkevt
irq/30-can0-346 d..h. 5673: irq_handler_entry: irq=17 name=at91_rtc
irq/30-can0-346 d..h. 5685: irq_handler_exit: irq=17 ret=handled
irq/30-can0-346 d..h. 5706: irq_handler_entry: irq=17 name=atmel_usa
irq/30-can0-346 d..h. 5713: irq_handler_exit: irq=17 ret=handled
irq/30-can0-346 d..h. 5754: irq_handler_exit: irq=16 ret=handled
irq/30-can0-346 d..h. 6008: irq_handler_entry: irq=29 name=eth0
irq/30-can0-346 d..h. 6027: irq_handler_exit: irq=29 ret=handled
irq/30-can0-346 ..... 6571: softirq_exit: vec=3 [action=NET_RX]
irq/30-can0-346 d.... 6626: at91_irq: (at91_irq+0x0/0xab0)
irq/30-can0-346 d.... 6788: at91_rx_overflow_err: (at91_irq+0x200/0x