From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Wei Fang <wei.fang@nxp.com>
Cc: Jianpeng Chang <jianpeng.chang.cn@windriver.com>,
"imx@lists.linux.dev" <imx@lists.linux.dev>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
Clark Wang <xiaoning.wang@nxp.com>,
"andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
"davem@davemloft.net" <davem@davemloft.net>,
"edumazet@google.com" <edumazet@google.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
Alexandru Marginean <alexandru.marginean@nxp.com>
Subject: Re: [v3 PATCH net] net: enetc: fix the deadlock of enetc_mdio_lock
Date: Fri, 10 Oct 2025 14:08:12 +0300 [thread overview]
Message-ID: <20251010110812.3edrut6puoao36b3@skbuf> (raw)
In-Reply-To: <20251010105138.j2mqxy6ejiroszsy@skbuf>
On Fri, Oct 10, 2025 at 01:51:38PM +0300, Vladimir Oltean wrote:
> On Fri, Oct 10, 2025 at 12:31:37PM +0300, Wei Fang wrote:
> > > After applying the workaround for err050089, the LS1028A platform
> > > experiences RCU stalls on RT kernel. This issue is caused by the
> > > recursive acquisition of the read lock enetc_mdio_lock. Here list some
> > > of the call stacks identified under the enetc_poll path that may lead to
> > > a deadlock:
> > >
> > > enetc_poll
> > > -> enetc_lock_mdio
> > > -> enetc_clean_rx_ring OR napi_complete_done
> > > -> napi_gro_receive
> > > -> enetc_start_xmit
> > > -> enetc_lock_mdio
> > > -> enetc_map_tx_buffs
> > > -> enetc_unlock_mdio
> > > -> enetc_unlock_mdio
> > >
> > > After enetc_poll acquires the read lock, a higher-priority writer attempts
> > > to acquire the lock, causing preemption. The writer detects that a
> > > read lock is already held and is scheduled out. However, readers under
> > > enetc_poll cannot acquire the read lock again because a writer is already
> > > waiting, leading to a thread hang.
> > >
> > > Currently, the deadlock is avoided by adjusting enetc_lock_mdio to prevent
> > > recursive lock acquisition.
> > >
> > > Fixes: 6d36ecdbc441 ("net: enetc: take the MDIO lock only once per NAPI poll
> > > cycle")
> > > Signed-off-by: Jianpeng Chang <jianpeng.chang.cn@windriver.com>
> >
> > Acked-by: Wei Fang <wei.fang@nxp.com>
> >
> > Hi Vladimir,
> >
> > Do you have any comments? This patch will cause the regression of performance
> > degradation, but the RCU stalls are more severe.
> >
>
> I'm fine with the change in principle. It's my fault because I didn't
> understand how rwlock writer starvation prevention is implemented, I
> thought there would be no problem with reentrant readers.
>
> But I wonder if xdp_do_flush() shouldn't also be outside the enetc_lock_mdio()
> section. Flushing XDP buffs with XDP_REDIRECT action might lead to
> enetc_xdp_xmit() being called, which also takes the lock...
And I think the same concern exists for the xdp_do_redirect() calls.
Most of the time it will be fine, but when the batch fills up it will be
auto-flushed by bq_enqueue():
if (unlikely(bq->count == DEV_MAP_BULK_SIZE))
bq_xmit_all(bq, 0);
next prev parent reply other threads:[~2025-10-10 11:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-09 1:32 [v3 PATCH net] net: enetc: fix the deadlock of enetc_mdio_lock Jianpeng Chang
2025-10-10 9:31 ` Wei Fang
2025-10-10 10:51 ` Vladimir Oltean
2025-10-10 11:08 ` Vladimir Oltean [this message]
2025-10-14 3:06 ` Jianpeng Chang
2025-10-14 3:24 ` Wei Fang
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=20251010110812.3edrut6puoao36b3@skbuf \
--to=vladimir.oltean@nxp.com \
--cc=alexandru.marginean@nxp.com \
--cc=andrew+netdev@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=imx@lists.linux.dev \
--cc=jianpeng.chang.cn@windriver.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=wei.fang@nxp.com \
--cc=xiaoning.wang@nxp.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