From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Date: 2022-02-16 17:50:53
I missed the obvious case where netif_ix() is invoked from hard-IRQ
context.
Disabling bottom halves is only needed in process context. This ensures
that the code remains on the current CPU and that the soft-interrupts
are processed at local_bh_enable() time.
In hard- and soft-interrupt context this is already the case and the
soft-interrupts will be processed once the context is left (at irq-exit
time).
Disable bottom halves if neither hard-interrupts nor soft-interrupts are
disabled. Update the kernel-doc, mention that interrupts must be enabled
if invoked from process context.
Fixes: baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
Marek, does this work for you?
net/core/dev.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
From: Marek Szyprowski <m.szyprowski@samsung.com> Date: 2022-02-17 06:35:42
Hi Andrzej,
On 16.02.2022 18:50, Sebastian Andrzej Siewior wrote:
I missed the obvious case where netif_ix() is invoked from hard-IRQ
context.
Disabling bottom halves is only needed in process context. This ensures
that the code remains on the current CPU and that the soft-interrupts
are processed at local_bh_enable() time.
In hard- and soft-interrupt context this is already the case and the
soft-interrupts will be processed once the context is left (at irq-exit
time).
Disable bottom halves if neither hard-interrupts nor soft-interrupts are
disabled. Update the kernel-doc, mention that interrupts must be enabled
if invoked from process context.
Fixes: baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
Marek, does this work for you?
Yes, this fixed the issue. Thanks!
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
From: Marek Szyprowski <m.szyprowski@samsung.com> Date: 2022-02-17 14:09:06
Hi All,
On 17.02.2022 07:35, Marek Szyprowski wrote:
Hi Andrzej,
On 16.02.2022 18:50, Sebastian Andrzej Siewior wrote:
quoted
I missed the obvious case where netif_ix() is invoked from hard-IRQ
context.
Disabling bottom halves is only needed in process context. This ensures
that the code remains on the current CPU and that the soft-interrupts
are processed at local_bh_enable() time.
In hard- and soft-interrupt context this is already the case and the
soft-interrupts will be processed once the context is left (at irq-exit
time).
Disable bottom halves if neither hard-interrupts nor soft-interrupts are
disabled. Update the kernel-doc, mention that interrupts must be enabled
if invoked from process context.
Fixes: baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked
in any context.")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
Marek, does this work for you?
Yes, this fixed the issue. Thanks!
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
I've just noticed that there is one more issue left to fix (the $subject
patch is already applied) - this one comes from threaded irq (if I got
the stack trace right):
------------[ cut here ]------------
WARNING: CPU: 0 PID: 147 at kernel/softirq.c:363
__local_bh_enable_ip+0xa8/0x1c0
Modules linked in: cpufreq_powersave cpufreq_conservative brcmfmac
brcmutil cfg80211 s3fwrn5_i2c s3fwrn5 nci crct10dif_ce exynos_gsc nfc
s5p_jpeg hci_uart btqca s
5p_mfc v4l2_mem2mem btbcm bluetooth videobuf2_dma_contig
videobuf2_memops ecdh_generic videobuf2_v4l2 panfrost drm_shmem_helper
ecc videobuf2_common gpu_sched rfkill videodev mc ip_tables x_tab
les ipv6
CPU: 0 PID: 147 Comm: irq/150-dwc3 Not tainted 5.17.0-rc4-next-20220217+
#4557
Hardware name: Samsung TM2E board (DT)
pstate: 400000c5 (nZcv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : __local_bh_enable_ip+0xa8/0x1c0
lr : netif_rx+0xa4/0x2c0
...
Call trace:
__local_bh_enable_ip+0xa8/0x1c0
netif_rx+0xa4/0x2c0
rx_complete+0x214/0x250
usb_gadget_giveback_request+0x58/0x170
dwc3_gadget_giveback+0xe4/0x200
dwc3_gadget_endpoint_trbs_complete+0x100/0x388
dwc3_thread_interrupt+0x46c/0xe20
irq_thread_fn+0x28/0x98
irq_thread+0x184/0x238
kthread+0x100/0x120
ret_from_fork+0x10/0x20
irq event stamp: 645
hardirqs last enabled at (643): [<ffff8000080c93b8>]
finish_task_switch+0x98/0x288
hardirqs last disabled at (644): [<ffff8000090a6e34>]
_raw_spin_lock_irqsave+0xb4/0x148
softirqs last enabled at (252): [<ffff800008010488>] _stext+0x488/0x5cc
softirqs last disabled at (645): [<ffff800008ed71b0>] netif_rx+0x188/0x2c0
---[ end trace 0000000000000000 ]---
* congestion control or by the protocol layers.
* The network buffer is passed via the backlog NAPI device.
Modern NIC
* driver should use NAPI and GRO.
- * This function can used from any context.
+ * This function can used from interrupt and from process
context. The
+ * caller from process context must not disable interrupts before
invoking
+ * this function.
*
* return values:
* NET_RX_SUCCESS (no congestion)
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Date: 2022-02-17 14:22:00
On 2022-02-17 15:08:55 [+0100], Marek Szyprowski wrote:
Hi All,
Hi,
I've just noticed that there is one more issue left to fix (the $subject
patch is already applied) - this one comes from threaded irq (if I got
the stack trace right):
This is not `threadirqs' on the command line, right?
Sebastian
From: Marek Szyprowski <m.szyprowski@samsung.com> Date: 2022-02-17 14:44:18
On 17.02.2022 15:21, Sebastian Andrzej Siewior wrote:
On 2022-02-17 15:08:55 [+0100], Marek Szyprowski wrote:
quoted
I've just noticed that there is one more issue left to fix (the $subject
patch is already applied) - this one comes from threaded irq (if I got
the stack trace right):
This is not `threadirqs' on the command line, right?
I don't have 'threadirqs' in the kernel cmdline for that board.
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Date: 2022-02-18 09:34:54
On 2022-02-17 15:08:55 [+0100], Marek Szyprowski wrote:
Hi All,
Hi,
quoted
quoted
Marek, does this work for you?
Yes, this fixed the issue. Thanks!
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
I've just noticed that there is one more issue left to fix (the $subject
patch is already applied) - this one comes from threaded irq (if I got
the stack trace right):
netif_rx() did only set the matching softirq bit and not more. Based on
that I don't see why NOHZ shouldn't complain about a pending softirq
once the CPU goes idle. Therefore I think the change I made is good
since it uncovered that.
------------[ cut here ]------------
WARNING: CPU: 0 PID: 147 at kernel/softirq.c:363
__local_bh_enable_ip+0xa8/0x1c0
So dwc3_thread_interrupt() disables interrupts here. Felipe dropped it
and then added it back in
e5f68b4a3e7b0 ("Revert "usb: dwc3: gadget: remove unnecessary _irqsave()"")
I would suggest to revert it (the above commit) and fixing the lockdep
splat in the gadget driver and other. I don't see the g_ether warning
Felipe mentioned. It might come from f_ncm (since it uses a timer) or
something else in the network stack (that uses a timeout timer).
But not now.
As much as I hate it, I suggest:
In the long run I would drop that irqsave (along with bh_disable() since
netif_rx() covers that) and make sure the there is no lockdep warning
popping up.
Marek, could you please give it a try?
Sebastian
From: Marek Szyprowski <m.szyprowski@samsung.com> Date: 2022-02-18 10:02:47
Hi,
On 18.02.2022 10:34, Sebastian Andrzej Siewior wrote:
quoted hunk
On 2022-02-17 15:08:55 [+0100], Marek Szyprowski wrote:
quoted
quoted
quoted
Marek, does this work for you?
Yes, this fixed the issue. Thanks!
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
I've just noticed that there is one more issue left to fix (the $subject
patch is already applied) - this one comes from threaded irq (if I got
the stack trace right):
netif_rx() did only set the matching softirq bit and not more. Based on
that I don't see why NOHZ shouldn't complain about a pending softirq
once the CPU goes idle. Therefore I think the change I made is good
since it uncovered that.
quoted
------------[ cut here ]------------
WARNING: CPU: 0 PID: 147 at kernel/softirq.c:363
__local_bh_enable_ip+0xa8/0x1c0
So dwc3_thread_interrupt() disables interrupts here. Felipe dropped it
and then added it back in
e5f68b4a3e7b0 ("Revert "usb: dwc3: gadget: remove unnecessary _irqsave()"")
I would suggest to revert it (the above commit) and fixing the lockdep
splat in the gadget driver and other. I don't see the g_ether warning
Felipe mentioned. It might come from f_ncm (since it uses a timer) or
something else in the network stack (that uses a timeout timer).
But not now.
As much as I hate it, I suggest:
In the long run I would drop that irqsave (along with bh_disable() since
netif_rx() covers that) and make sure the there is no lockdep warning
popping up.
Marek, could you please give it a try?
Hi Sebastian,
On Wed, 16 Feb 2022, Sebastian Andrzej Siewior wrote:
I missed the obvious case where netif_ix() is invoked from hard-IRQ
context.
Disabling bottom halves is only needed in process context. This ensures
that the code remains on the current CPU and that the soft-interrupts
are processed at local_bh_enable() time.
In hard- and soft-interrupt context this is already the case and the
soft-interrupts will be processed once the context is left (at irq-exit
time).
Disable bottom halves if neither hard-interrupts nor soft-interrupts are
disabled. Update the kernel-doc, mention that interrupts must be enabled
if invoked from process context.
Fixes: baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Thanks, this fixes the issue on rbtx4927[1].
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
[1] https://lore.kernel.org/all/alpine.DEB.2.22.394.2202221622570.372449@ramsan.of.borg/
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
From: Sebastian Andrzej Siewior <hidden> Date: 2022-02-23 08:05:53
On 2022-02-16 18:50:46 [+0100], Sebastian Andrzej Siewior wrote:
I missed the obvious case where netif_ix() is invoked from hard-IRQ
context.
Disabling bottom halves is only needed in process context. This ensures
that the code remains on the current CPU and that the soft-interrupts
are processed at local_bh_enable() time.
In hard- and soft-interrupt context this is already the case and the
soft-interrupts will be processed once the context is left (at irq-exit
time).
Disable bottom halves if neither hard-interrupts nor soft-interrupts are
disabled. Update the kernel-doc, mention that interrupts must be enabled
if invoked from process context.
Fixes: baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
This patch is marked as "Changes Requested" in patchwork. Could someone
please explain?
The USB/dwc3 fallout reported by Marek was addressed in
usb: dwc3: gadget: Let the interrupt handler disable bottom halves.
https://lore.kernel.org/r/Yg/YPejVQH3KkRVd@linutronix.de
and is not a shortcoming in this patch but a problem in dwc3 that was
just noticed.
Sebastian
From: Jakub Kicinski <kuba@kernel.org> Date: 2022-02-23 15:55:25
On Wed, 23 Feb 2022 09:05:43 +0100 Sebastian Andrzej Siewior wrote:
On 2022-02-16 18:50:46 [+0100], Sebastian Andrzej Siewior wrote:
quoted
I missed the obvious case where netif_ix() is invoked from hard-IRQ
context.
Disabling bottom halves is only needed in process context. This ensures
that the code remains on the current CPU and that the soft-interrupts
are processed at local_bh_enable() time.
In hard- and soft-interrupt context this is already the case and the
soft-interrupts will be processed once the context is left (at irq-exit
time).
Disable bottom halves if neither hard-interrupts nor soft-interrupts are
disabled. Update the kernel-doc, mention that interrupts must be enabled
if invoked from process context.
Fixes: baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
This patch is marked as "Changes Requested" in patchwork. Could someone
please explain?
The USB/dwc3 fallout reported by Marek was addressed in
usb: dwc3: gadget: Let the interrupt handler disable bottom halves.
https://lore.kernel.org/r/Yg/YPejVQH3KkRVd@linutronix.de
and is not a shortcoming in this patch but a problem in dwc3 that was
just noticed.