linux-um archives
 help / color / mirror / Atom feed
From: Hajime Tazaki <thehajime@gmail.com>
To: linux-um@lists.infradead.org
Cc: Hajime Tazaki <thehajime@gmail.com>
Subject: [PATCH] um: vector: disable BH while resetting stats
Date: Wed, 21 Oct 2026 09:04:29 +0900	[thread overview]
Message-ID: <20261021000429.3284929-1-thehajime@gmail.com> (raw)

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/0x22

Fixes: 612a8c8e0b43 ("um: vector: Replace locks guarding queue depth with atomics")
Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
Assisted-by: LLM

---
diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index e902e78c5ff6..9da13281c9e2 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -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);
 
 }
 


                 reply	other threads:[~2026-10-21  0:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261021000429.3284929-1-thehajime@gmail.com \
    --to=thehajime@gmail.com \
    --cc=linux-um@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox