um: vector: disable BH while resetting stats
PATCH 1/1 um: vector: disable BH while resetting stats
vector_reset_stats() is called from vector_net_open() in process context, while its queue locks are also taken from vector_poll() in NAPI context. Taking these locks with bottom halves enabled makes them appear softirq-unsafe to lockdep.
This commit fixes the inconsistent lock state warning by disabling bottom halves while resetting the vector statistics.
The warning was:
------------[ cut here ]------------
================================
WARNING: inconsistent lock state
7.3.0-rc4-g537b66d8fe2e-dirty #8 Not tainted
--------------------------------
inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.
ifconfig/32 [HC0[0]:SC1[1]:HE1:SE0] takes:
00000000686b2db0 (&result->head_lock){+.?.}-{2:2}, at: vector_poll+0x71/0x2ea
{SOFTIRQ-ON-W} state was registered at:
save_stack_trace+0x2e/0x30
stack_trace_save+0x38/0x3d
save_trace+0xab/0x277
mark_lock+0x143/0x45b
__lock_acquire+0x71b/0x15a8
lock_acquire+0x21e/0x293
_raw_spin_lock+0x44/0x5b
vector_net_open+0x39c/0x4bd
__dev_open+0x139/0x1a3
__dev_change_flags+0xe5/0x18d
netif_change_flags+0x30/0x75
dev_change_flags+0x3b/0x66
devinet_ioctl+0x3ca/0x679
inet_ioctl+0x13d/0x1dc
sock_ioctl+0x317/0x3b0
sys_ioctl+0x52b/0x786
handle_syscall+0x79/0xa2
userspace+0x610/0x6a3
fork_handler+0x58/0x5c
irq event stamp: 1942
hardirqs last enabled at (1942): [<00000000605ebbf3>] net_rx_action+0x136/0x343
hardirqs last disabled at (1941): [<00000000605ebba7>] net_rx_action+0xea/0x343
softirqs last enabled at (1938): [<00000000605f3879>] dev_set_rx_mode+0x3b/0x3f
softirqs last disabled at (1939): [<00000000607041f5>] __do_softirq+0x16/0x18 other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(&result->head_lock);
<Interrupt>
lock(&result->head_lock);
*** DEADLOCK ***
locks held by ifconfig/32: 1, last CPU#0:
#0: 0000000060aba238 (rtnl_mutex){+.+.}-{3:3}, at: rtnl_lock+0x20/0x22Fixes 612a8c8e0b43 ("um: vector: Replace locks guarding queue depth with atomics")
Signed-off-by Hajime Tazaki <[email protected]>
Assisted-by LLM
---
arch/um/drivers/vector_kern.c +4 -4
@@ -112,7 +112,7 @@ static void vector_reset_stats(struct vector_private *vp)*/ if (vp->rx_queue) -spin_lock (&vp->rx_queue->head_lock); +spin_lock_bh (&vp->rx_queue->head_lock); vp->estats.rx_queue_max =0 ; vp->estats.rx_queue_running_average =0 ;
@@ -121,7 +121,7 @@ static void vector_reset_stats(struct vector_private *vp) vp->estats.sg_linearized =0 ;if (vp->rx_queue) -spin_unlock (&vp->rx_queue->head_lock); +spin_unlock_bh (&vp->rx_queue->head_lock);/* TX stats are modified with TX head_lock held
@@ -129,7 +129,7 @@ static void vector_reset_stats(struct vector_private *vp)*/ if (vp->tx_queue) -spin_lock (&vp->tx_queue->head_lock); +spin_lock_bh (&vp->tx_queue->head_lock); vp->estats.tx_timeout_count =0 ; vp->estats.tx_restart_queue =0 ;
@@ -140,7 +140,7 @@ static void vector_reset_stats(struct vector_private *vp) vp->estats.tx_queue_running_average =0 ;if (vp->tx_queue) -spin_unlock (&vp->tx_queue->head_lock); +spin_unlock_bh (&vp->tx_queue->head_lock); }