From: Breno Leitao <leitao@debian.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
Petr Mladek <pmladek@suse.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
John Ogness <john.ogness@linutronix.de>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Vlad Poenaru <vlad.wing@gmail.com>,
Thomas Gleixner <tglx@kernel.org>,
netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
Frederic Weisbecker <frederic@kernel.org>,
Ingo Molnar <mingo@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
K Prateek Nayak <kprateek.nayak@amd.com>
Subject: Re: [PATCH net] netpoll: run NAPI poll in softirq context to avoid rq->lock self-deadlock
Date: Thu, 18 Jun 2026 07:57:33 -0700 [thread overview]
Message-ID: <ajQFMS4ucT-mybhi@gmail.com> (raw)
In-Reply-To: <20260617132127.645534d1@kernel.org>
On Wed, Jun 17, 2026 at 01:21:27PM -0700, Jakub Kicinski wrote:
> On Wed, 17 Jun 2026 07:56:50 -0700 Breno Leitao wrote:
> > As far as I can tell, there isn't a network driver today whose transmit
> > path is completely lockless, so, even if we make netpoll lockless.
> >
> > It's unlikely any NIC will ever achieve this, given that NIC TX
> > fundamentally relies on a shared DMA ring and doorbell register, which
> > inherently cannot be made lockless.
>
> The lock which protects the queue is maintained by the stack,
> and we trylock it. Maybe I lost the thread but if you're saying
> that writes to netconsole are impossible from arbitrary context,
> that is _not_ true, AFAIU. We can queue a packet and kick off
> the transfer on well-behaved drivers.
>
> Main problem is the opportunistic freeing up of the queue space.
> If we could avoid that in atomic context I think we'd be good.
Thanks for the clarification, this is quite valuable.
Let me verify my understanding: if we switched to __raise_softirq_irqoff()
in dev_kfree_skb_irq_reason(), the issue would be resolved since we'd
avoid waking ksoftirqd and therefore wouldn't touch the runqueue lock in this
code path.
However, while that would eliminate the nested lock problem, it could
increase memory pressure by delaying SKB garbage collection, which may
not be acceptable.
Naive question: What if we deferred SKB cleanup only during netpoll operations?
Such as tracking in_netpoll per cpu:
struct softnet_data {
....
+ bool in_netpoll;
}
and then choosing between __raise_softirq_irqoff() and raise_softirq_irqoff()?
@@ -3456,7 +3456,13 @@ void dev_kfree_skb_irq_reason(struct sk_buff *skb, enum skb_drop_reason reason)
local_irq_save(flags);
skb->next = __this_cpu_read(softnet_data.completion_queue);
__this_cpu_write(softnet_data.completion_queue, skb);
- raise_softirq_irqoff(NET_TX_SOFTIRQ);
+ if (__this_cpu_read(softnet_data.in_netpoll))
+ __raise_softirq_irqoff(NET_TX_SOFTIRQ);
+ else
+ raise_softirq_irqoff(NET_TX_SOFTIRQ);
local_irq_restore(flags);
}
Is it too hacky!?
Thanks,
--breno
next prev parent reply other threads:[~2026-06-18 14:58 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 18:36 [PATCH net] netpoll: run NAPI poll in softirq context to avoid rq->lock self-deadlock Vlad Poenaru
2026-06-11 18:36 ` sashiko-bot
2026-06-12 2:11 ` Jakub Kicinski
2026-06-15 13:56 ` Sebastian Andrzej Siewior
2026-06-16 10:35 ` Sebastian Andrzej Siewior
2026-06-16 15:11 ` Jakub Kicinski
2026-06-16 15:31 ` Sebastian Andrzej Siewior
2026-06-17 10:12 ` Petr Mladek
2026-06-17 11:15 ` Peter Zijlstra
2026-06-17 11:59 ` Petr Mladek
2026-06-17 12:12 ` John Ogness
2026-06-18 8:51 ` Sebastian Andrzej Siewior
2026-06-16 16:32 ` Breno Leitao
2026-06-17 7:42 ` John Ogness
2026-06-16 17:02 ` Peter Zijlstra
2026-06-16 21:17 ` Jakub Kicinski
2026-06-17 10:37 ` Petr Mladek
2026-06-17 11:19 ` Peter Zijlstra
2026-06-17 12:13 ` Petr Mladek
2026-06-17 14:56 ` Breno Leitao
2026-06-17 17:07 ` John Ogness
2026-06-17 20:21 ` Jakub Kicinski
2026-06-18 14:57 ` Breno Leitao [this message]
2026-06-18 11:15 ` Sebastian Andrzej Siewior
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=ajQFMS4ucT-mybhi@gmail.com \
--to=leitao@debian.org \
--cc=bigeasy@linutronix.de \
--cc=clrkwllms@kernel.org \
--cc=davem@davemloft.net \
--cc=dietmar.eggemann@arm.com \
--cc=edumazet@google.com \
--cc=frederic@kernel.org \
--cc=horms@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=kprateek.nayak@amd.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=stable@vger.kernel.org \
--cc=tglx@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vlad.wing@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.