From: Vladimir Oltean <olteanv@gmail.com>
To: f.fainelli@gmail.com, vivien.didelot@gmail.com, andrew@lunn.ch,
davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Vladimir Oltean <olteanv@gmail.com>
Subject: [PATCH net-next 1/2] net: dsa: Remove deferred_xmit from dsa_skb_cb
Date: Fri, 27 Dec 2019 03:42:07 +0200 [thread overview]
Message-ID: <20191227014208.7189-2-olteanv@gmail.com> (raw)
In-Reply-To: <20191227014208.7189-1-olteanv@gmail.com>
The introduction of the deferred xmit mechanism in DSA has made the
hotpath slightly more inefficient for everybody, since
DSA_SKB_CB(skb)->deferred_xmit needed to be initialized to false for
every transmitted frame, in order to figure out whether the driver
requested deferral or not. That was necessary to avoid kfree_skb from
freeing the skb.
But actually we can just remove that variable in the skb->cb and
counteract the effect of kfree_skb with skb_get, much to the same
effect. The advantage, of course, being that anybody who doesn't use
deferred xmit doesn't need to do any extra operation in the hotpath.
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
---
include/net/dsa.h | 1 -
net/dsa/slave.c | 12 ++++++------
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 6767dc3f66c0..5d510a4da5d0 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -88,7 +88,6 @@ struct dsa_device_ops {
struct dsa_skb_cb {
struct sk_buff *clone;
- bool deferred_xmit;
};
struct __dsa_skb_cb {
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 78ffc87dc25e..9f7e47dcdc20 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -518,7 +518,6 @@ static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
s->tx_bytes += skb->len;
u64_stats_update_end(&s->syncp);
- DSA_SKB_CB(skb)->deferred_xmit = false;
DSA_SKB_CB(skb)->clone = NULL;
/* Identify PTP protocol packets, clone them, and pass them to the
@@ -531,8 +530,7 @@ static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
*/
nskb = p->xmit(skb, dev);
if (!nskb) {
- if (!DSA_SKB_CB(skb)->deferred_xmit)
- kfree_skb(skb);
+ kfree_skb(skb);
return NETDEV_TX_OK;
}
@@ -543,10 +541,12 @@ void *dsa_defer_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct dsa_port *dp = dsa_slave_to_port(dev);
- DSA_SKB_CB(skb)->deferred_xmit = true;
-
- skb_queue_tail(&dp->xmit_queue, skb);
+ /* Increase refcount so the kfree_skb in dsa_slave_xmit
+ * won't really free the packet.
+ */
+ skb_queue_tail(&dp->xmit_queue, skb_get(skb));
schedule_work(&dp->xmit_work);
+
return NULL;
}
EXPORT_SYMBOL_GPL(dsa_defer_xmit);
--
2.17.1
next prev parent reply other threads:[~2019-12-27 1:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-27 1:42 [PATCH net-next 0/2] Improvements to the DSA deferred xmit Vladimir Oltean
2019-12-27 1:42 ` Vladimir Oltean [this message]
2019-12-27 1:42 ` [PATCH net-next 2/2] net: dsa: Create a kernel thread for each port's deferred xmit work Vladimir Oltean
2020-01-02 21:49 ` [PATCH net-next 0/2] Improvements to the DSA deferred xmit David Miller
2020-01-02 22:47 ` Vladimir Oltean
2020-01-03 20:10 ` Florian Fainelli
2020-01-04 2:44 ` Richard Cochran
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=20191227014208.7189-2-olteanv@gmail.com \
--to=olteanv@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@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 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).