mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: Breno Leitao <leitao@debian.org>, Jakub Kicinski <kuba@kernel.org>
Cc: Johannes Berg <johannes@sipsolutions.net>,
	Mike Galbraith <efault@gmx.de>,
	paulmck@kernel.org, LKML <linux-kernel@vger.kernel.org>,
	netdev@vger.kernel.org, boqun.feng@gmail.com
Subject: Re: netconsole: HARDIRQ-safe -> HARDIRQ-unsafe lock order warning
Date: Fri, 15 Aug 2025 21:02:27 +0100	[thread overview]
Message-ID: <3dd73125-7f9b-405c-b5cd-0ab172014d00@gmail.com> (raw)
In-Reply-To: <isnqkmh36mnzm5ic5ipymltzljkxx3oxapez5asp24tivwtar2@4mx56cvxtrnh>

On 8/15/25 18:29, Breno Leitao wrote:
> On Fri, Aug 15, 2025 at 09:42:17AM -0700, Jakub Kicinski wrote:
>> On Fri, 15 Aug 2025 11:44:45 +0100 Pavel Begunkov wrote:
>>> On 8/15/25 01:23, Jakub Kicinski wrote:
>>
>> I suspect disabling netconsole over WiFi may be the most sensible way out.
> 
> I believe we might be facing a similar issue with virtio-net.
> Specifically, any network adapter where TX is not safe to use in IRQ
> context encounters this problem.
> 
> If we want to keep netconsole enabled on all TX paths, a possible
> solution is to defer the transmission work when netconsole is called
> inside an IRQ.
> 
> The idea is that netconsole first checks if it is running in an IRQ
> context using in_irq(). If so, it queues the skb without transmitting it
> immediately and schedules deferred work to handle the transmission
> later.
> 
> A rough implementation could be:
> 
> static void send_udp(struct netconsole_target *nt, const char *msg, int len) {
> 
> 	/* get the SKB that is already populated, with all the headers
> 	 * and ready to be sent
> 	 */
> 	struct sk_buff = netpoll_get_skb(&nt->np, msg, len);
> 
> 	if (in_irq()) {

It's not just irq handlers but any context that has irqs disabled, and
since it's nested under irq-safe console_owner it'd need to always be
deferred or somehow moved out of the console_owner critical section.
Maybe there is printk lock trickery I don't understand, however.

> 		skb_queue_tail(&np->delayed_queue, skb);
> 		schedule_delayed_work(flush_delayed_queue, 0);
> 		return;
> 	}
> 
> 	return __netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
> }
> 
> This approach does not require additional memory or extra data copying,
> since copying from the printk buffer to the skb must be performed
> regardless.
> 
> The main drawback is a slight delay for messages sent from within an IRQ
> context, though I believe such cases are infrequent.
> 
> We could potentially also perform the flush from softirq context, which
> would help reduce this latency further.

-- 
Pavel Begunkov


  parent reply	other threads:[~2025-08-15 20:01 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13  4:14 Mike Galbraith
2025-08-14 10:16 ` Breno Leitao
2025-08-14 15:45   ` Pavel Begunkov
2025-08-15  0:23   ` Jakub Kicinski
2025-08-15 10:44     ` Pavel Begunkov
2025-08-15 16:42       ` Jakub Kicinski
2025-08-15 17:29         ` Breno Leitao
2025-08-15 17:33           ` Jakub Kicinski
2025-08-18 12:23             ` Breno Leitao
2025-08-15 19:10           ` Calvin Owens
2025-08-16  9:19             ` Mike Galbraith
2025-08-15 20:02           ` Pavel Begunkov [this message]
2025-08-18 12:10             ` Breno Leitao
2025-08-19 17:27               ` Breno Leitao
2025-08-20 12:31                 ` Mike Galbraith
2025-08-20 17:36                   ` Breno Leitao
2025-08-21  3:37                     ` Mike Galbraith
2025-08-21  3:51                       ` Mike Galbraith
2025-08-21 17:35                         ` Breno Leitao
2025-08-22  3:54                           ` Mike Galbraith
2025-08-26 12:43                             ` Breno Leitao
2025-08-26 13:56                               ` Mike Galbraith
2025-09-05 12:48                               ` John Ogness
2025-09-06  2:32                                 ` Mike Galbraith
2025-09-08 13:30                                   ` John Ogness
2025-09-08 15:18                                     ` Mike Galbraith
2025-09-08 20:27                                 ` Calvin Owens
2025-09-09 15:49                                   ` Mike Galbraith
2025-09-10 15:51                                   ` Petr Mladek
2025-09-09 12:50                                 ` Breno Leitao
2025-09-10 12:22                                   ` John Ogness
2025-09-10 15:12                                     ` Petr Mladek
2025-09-10 18:26                                       ` Breno Leitao
2025-09-30 13:57                                         ` Calvin Owens
2025-09-30 14:23                                           ` John Ogness
2025-09-30 14:30                                             ` Sebastian Siewior
2025-09-30 17:35                                               ` Mike Galbraith
2025-10-01  6:00                                                 ` Mike Galbraith
2025-09-11 13:03                                       ` John Ogness
2025-09-10 18:23                                     ` Breno Leitao
2025-09-11 13:13                                       ` John Ogness
2025-08-21 10:06                       ` Mike Galbraith
2025-08-21 13:12                         ` Mike Galbraith
2025-08-15 17:37         ` Calvin Owens
2025-08-26 14:10         ` Johannes Berg
2025-08-15 12:45     ` Mike Galbraith

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=3dd73125-7f9b-405c-b5cd-0ab172014d00@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=efault@gmx.de \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=paulmck@kernel.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

all inboxes | Powered by JetHome®