From: Pavel Machek <pavel@ucw.cz>
To: Lino Sanfilippo <LinoSanfilippo@gmx.de>
Cc: Giuseppe CAVALLARO <peppe.cavallaro@st.com>,
alexandre.torgue@st.com, David Miller <davem@davemloft.net>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC] Re: Re: stmmac ethernet in kernel 4.9-rc6: coalescing related pauses.
Date: Wed, 7 Dec 2016 13:31:40 +0100 [thread overview]
Message-ID: <20161207123140.GA8785@amd> (raw)
In-Reply-To: <trinity-11729d3e-ae5e-4850-a1bf-b83a1d0a864c-1480687521037@3capp-gmx-bs55>
[-- Attachment #1: Type: text/plain, Size: 4485 bytes --]
On Fri 2016-12-02 15:05:21, Lino Sanfilippo wrote:
> Hi,
>
>
> >
> > There's nothing that protect stmmac_poll() from running concurently
> > with stmmac_dma_interrupt(), right?
> >
>
> could it be that there is also another issue concerned locking?:
> The tx completion handler takes the xmit_lock in case that the
> netif_queue is stopped. This is AFAICS unnecessary, since both
> xmit and completion handler are already synchronized by the private
> tx lock. But it is IMHO also dangerous:
>
> In the xmit handler we have the locking order
> 1. xmit_lock
> 2. private tx lock
>
> while in the completion handler its the reverse:
>
> 1. private tx lock
> 2. xmit lock.
>
> Do I miss something?
No, it seems you are right. Something like this?
Hmm. And can priv->tx_lock be removed, as we already rely on
netif_tx_lock?
(I copied the "lock already held" annotations from forcedeth. I hope
they are right....)
Best regards,
Pavel
commit a6f21255dfc11fcadc5062dfd0c5f3d77ca4f634
Author: Pavel <pavel@ucw.cz>
Date: Wed Dec 7 13:29:15 2016 +0100
Reported-by: Lino Sanfilippo <LinoSanfilippo@gmx.de>
The tx completion handler takes the xmit_lock in case that the
netif_queue is stopped. This is AFAICS unnecessary, since both
xmit and completion handler are already synchronized by the private
tx lock. But it is IMHO also dangerous:
In the xmit handler we have the locking order
1. xmit_lock
2. private tx lock
while in the completion handler its the reverse:
1. private tx lock
2. xmit lock.
Signed-off-by: Pavel Machek <pavel@denx.de>
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 982c952..5df9bb3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1380,14 +1380,9 @@ static void stmmac_tx_clean(struct stmmac_priv *priv)
if (unlikely(netif_queue_stopped(priv->dev) &&
stmmac_tx_avail(priv) > STMMAC_TX_THRESH)) {
- netif_tx_lock(priv->dev);
- if (netif_queue_stopped(priv->dev) &&
- stmmac_tx_avail(priv) > STMMAC_TX_THRESH) {
- netif_dbg(priv, tx_done, priv->dev,
- "%s: restart transmit\n", __func__);
- netif_wake_queue(priv->dev);
- }
- netif_tx_unlock(priv->dev);
+ netif_dbg(priv, tx_done, priv->dev,
+ "%s: restart transmit\n", __func__);
+ netif_wake_queue(priv->dev);
}
if ((priv->eee_enabled) && (!priv->tx_path_in_lpi_mode)) {
@@ -1630,7 +1625,9 @@ static void stmmac_tx_timer(unsigned long data)
{
struct stmmac_priv *priv = (struct stmmac_priv *)data;
+ netif_tx_lock_bh(priv->dev);
stmmac_tx_clean(priv);
+ netif_tx_unlock_bh(priv->dev);
}
/**
@@ -1994,7 +1991,8 @@ static void stmmac_tso_allocator(struct stmmac_priv *priv, unsigned int des,
* --------
*
* mss is fixed when enable tso, so w/o programming the TDES3 ctx field.
- */
+ *
+ * Called with netif_tx_lock held. */
static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
{
u32 pay_len, mss;
@@ -2174,6 +2172,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
* Description : this is the tx entry point of the driver.
* It programs the chain or the ring and supports oversized frames
* and SG feature.
+ * Called with netif_tx_lock held.
*/
static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
{
@@ -2684,7 +2683,9 @@ static int stmmac_poll(struct napi_struct *napi, int budget)
int work_done = 0;
priv->xstats.napi_poll++;
+ netif_tx_lock_bh(priv->dev);
stmmac_tx_clean(priv);
+ netif_tx_unlock_bh(priv->dev);
work_done = stmmac_rx(priv, budget);
if (work_done < budget) {
@@ -2701,6 +2702,7 @@ static int stmmac_poll(struct napi_struct *napi, int budget)
* complete within a reasonable time. The driver will mark the error in the
* netdev structure and arrange for the device to be reset to a sane state
* in order to transmit a new packet.
+ * Called with netif_tx_lock held.
*/
static void stmmac_tx_timeout(struct net_device *dev)
{
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
next prev parent reply other threads:[~2016-12-07 12:31 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-23 10:51 stmmac ethernet in kernel 4.4: coalescing related pauses? Pavel Machek
2016-11-24 8:55 ` stmmac ethernet in kernel 4.9-rc6: coalescing related pauses Pavel Machek
2016-11-24 10:29 ` Pavel Machek
2016-11-24 10:36 ` Pavel Machek
2016-11-24 10:46 ` [PATCH] stmmac ethernet: unify locking Pavel Machek
2016-11-24 11:05 ` [PATCH] stmmac ethernet: remove cut & paste code Pavel Machek
2016-11-24 20:05 ` Joe Perches
2016-11-24 21:44 ` Pavel Machek
2016-11-24 22:27 ` Joe Perches
2016-11-28 11:50 ` Pavel Machek
2016-11-28 14:24 ` Joe Perches
2016-11-28 14:35 ` Pavel Machek
2016-11-28 16:03 ` Joe Perches
2016-11-24 16:04 ` stmmac ethernet in kernel 4.9-rc6: coalescing related pauses David Miller
2016-11-24 21:25 ` Pavel Machek
2016-12-02 8:24 ` Giuseppe CAVALLARO
2016-12-02 8:41 ` Giuseppe CAVALLARO
2016-12-02 8:45 ` Pavel Machek
2016-12-02 9:43 ` Giuseppe CAVALLARO
2016-12-02 12:32 ` Pavel Machek
2016-12-02 13:51 ` Giuseppe CAVALLARO
2016-12-02 14:26 ` Alexandre Torgue
2016-12-02 15:19 ` Giuseppe CAVALLARO
2016-12-05 12:14 ` Pavel Machek
2016-12-05 12:01 ` Pavel Machek
2016-12-05 10:15 ` Pavel Machek
2016-12-05 11:40 ` Lino Sanfilippo
2016-12-05 22:02 ` Pavel Machek
2016-12-05 22:37 ` Lino Sanfilippo
2016-12-05 22:40 ` Pavel Machek
2016-12-05 22:54 ` Lino Sanfilippo
2016-12-05 23:11 ` Lino Sanfilippo
2016-12-02 14:05 ` Aw: " Lino Sanfilippo
2016-12-07 12:31 ` Pavel Machek [this message]
2016-12-07 13:18 ` [RFC] " Lino Sanfilippo
2016-12-05 11:56 ` Pavel Machek
2016-11-28 11:55 ` [PATCH] stmmac: fix comments, make debug output consistent Pavel Machek
2016-11-30 0:53 ` David Miller
2016-11-28 12:13 ` stmmac ethernet in kernel 4.9-rc6: coalescing related pauses Pavel Machek
2016-11-28 12:17 ` [PATCH] stmmac: reduce code duplication getting basic descriptors Pavel Machek
2016-11-28 15:25 ` kbuild test robot
2016-12-02 14:09 ` Alexandre Torgue
2016-11-30 11:44 ` [PATCH] stmmac: simplify flag assignment Pavel Machek
2016-12-01 20:23 ` David Miller
2016-12-01 22:48 ` stmmac: turn coalescing / NAPI off in stmmac Pavel Machek
2016-12-02 8:39 ` Giuseppe CAVALLARO
2016-12-02 10:42 ` Pavel Machek
2016-12-02 15:31 ` Giuseppe CAVALLARO
2016-12-05 11:45 ` Pavel Machek
2016-12-02 8:27 ` [PATCH] stmmac: simplify flag assignment Giuseppe CAVALLARO
2016-12-01 10:32 ` [PATCH] stmmac: cleanup documenation, make it match reality Pavel Machek
2016-12-03 20:07 ` David Miller
2016-12-05 12:27 ` [PATCH] stmmac: disable tx coalescing Pavel Machek
2016-12-11 19:07 ` Pavel Machek
2016-12-11 19:31 ` David Miller
2016-12-11 19:57 ` Pavel Machek
2016-11-28 13:07 ` stmmac ethernet in kernel 4.4: coalescing related pauses? Lino Sanfilippo
2016-11-28 14:54 ` David Miller
2016-11-28 15:31 ` Eric Dumazet
2016-11-28 15:57 ` Lino Sanfilippo
2016-11-28 16:30 ` David Miller
2016-11-28 17:01 ` Lino Sanfilippo
2016-11-30 10:28 ` Pavel Machek
2016-11-28 15:33 ` Lino Sanfilippo
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=20161207123140.GA8785@amd \
--to=pavel@ucw.cz \
--cc=LinoSanfilippo@gmx.de \
--cc=alexandre.torgue@st.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peppe.cavallaro@st.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).