netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: John Ogness <john.ogness@linutronix.de>,
	Petr Mladek <pmladek@suse.com>, Breno Leitao <leitao@debian.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	gregkh@linuxfoundation.org, mst@redhat.com, jasowang@redhat.com,
	xuanzhuo@linux.alibaba.com, kuba@kernel.org,
	virtualization@lists.linux.dev, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, vschneid@redhat.com,
	axboe@kernel.dk, Heng Qi <hengqi@linux.alibaba.com>
Subject: Re: 6.12-rc1: Lockdep regression bissected (virtio-net/console/scheduler)
Date: Wed, 9 Oct 2024 16:44:24 +0100	[thread overview]
Message-ID: <f88adb83-618b-4be3-8357-0aabcf3a2db8@gmail.com> (raw)
In-Reply-To: <8434l6sjwz.fsf@jogness.linutronix.de>

On 10/8/24 16:18, John Ogness wrote:
> On 2024-10-04, Petr Mladek <pmladek@suse.com> wrote:
>> On Fri 2024-10-04 02:08:52, Breno Leitao wrote:
>>> 	 =====================================================
>>> 	 WARNING: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected
>>> 	 6.12.0-rc1-kbuilder-virtme-00033-gd4ac164bde7a #50 Not tainted
>>> 	 -----------------------------------------------------
>>> 	 swapper/0/1 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire:
>>> 	 ff1100010a260518 (_xmit_ETHER#2){+.-.}-{2:2}, at: virtnet_poll_tx (./include/linux/netdevice.h:4361 drivers/net/virtio_net.c:2969)
>>>
>>> 	and this task is already holding:
>>> 	 ffffffff86f2b5b8 (target_list_lock){....}-{2:2}, at: write_ext_msg (drivers/net/netconsole.c:?)
>>> 	 which would create a new lock dependency:
>>> 	  (target_list_lock){....}-{2:2} -> (_xmit_ETHER#2){+.-.}-{2:2}
>>>
>>> 	but this new dependency connects a HARDIRQ-irq-safe lock:
>>> 	  (console_owner){-...}-{0:0}
> 
> ...
> 
>>> 	to a HARDIRQ-irq-unsafe lock:
>>> 	  (_xmit_ETHER#2){+.-.}-{2:2}
> 
> ...
> 
>>> 	other info that might help us debug this:
>>>
>>> 	 Chain exists of:
>>> 	console_owner --> target_list_lock --> _xmit_ETHER#2
>>>
>>> 	  Possible interrupt unsafe locking scenario:
>>>
>>> 		CPU0                    CPU1
>>> 		----                    ----
>>> 	   lock(_xmit_ETHER#2);
>>> 					local_irq_disable();
>>> 					lock(console_owner);
>>> 					lock(target_list_lock);
>>> 	   <Interrupt>
>>> 	     lock(console_owner);
> 
> I can trigger this lockdep splat on v6.11 as well.
> 
> It only requires a printk() call within any interrupt handler, sometime
> after the netconsole is initialized and has had at least one run from
> softirq context.
> 
>> My understanding is that the fix is to always take "_xmit_ETHER#2"
>> lock with interrupts disabled.
> 
> That seems to be one possible solution. But maybe there is reasoning why
> that should not be done. (??) Right now it is clearly a spinlock that is

It's expensive, and it's a hot path if I understand correctly which
lock that is. And, IIRC the driver might spend there some time, it's
always nicer to keep irqs enabled if possible.

> being taken from both interrupt and softirq contexts and does not
> disable interrupts.

It rather seems the xmit lock is bh protected, but printk is a one
off case taking it with irqs disabled. I wonder if the printk side
could help with that, e.g. offloading sending from hardirq to softirq?

> I will check if there is some previous kernel release where this problem
> does not exist.

-- 
Pavel Begunkov

  reply	other threads:[~2024-10-09 15:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-03 14:51 6.12-rc1: Lockdep regression bissected (virtio-net/console/scheduler) Breno Leitao
2024-10-03 15:06 ` Breno Leitao
2024-10-03 15:32 ` Peter Zijlstra
2024-10-03 15:41   ` Breno Leitao
2024-10-04  9:08     ` Breno Leitao
2024-10-04 10:49       ` Petr Mladek
2024-10-08 15:18         ` John Ogness
2024-10-09 15:44           ` Pavel Begunkov [this message]
2024-10-09 17:29             ` Breno Leitao

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=f88adb83-618b-4be3-8357-0aabcf3a2db8@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=gregkh@linuxfoundation.org \
    --cc=hengqi@linux.alibaba.com \
    --cc=jasowang@redhat.com \
    --cc=john.ogness@linutronix.de \
    --cc=kuba@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=virtualization@lists.linux.dev \
    --cc=vschneid@redhat.com \
    --cc=xuanzhuo@linux.alibaba.com \
    /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;
as well as URLs for NNTP newsgroup(s).