From: David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
To: johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org
Cc: tomasw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [RFC v2] mac80211: assign needed_headroom/tailroom for netdevs
Date: Mon, 05 May 2008 16:03:28 -0700 (PDT) [thread overview]
Message-ID: <20080505.160328.203996832.davem@davemloft.net> (raw)
In-Reply-To: <1210000923.8245.26.camel-YfaajirXv214zXjbi5bjpg@public.gmane.org>
From: Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
Date: Mon, 05 May 2008 17:22:03 +0200
>
> > I've did some measurement of the TX path on an embedded system (2.6.23 kernel)
> > When bridging packets from an ethernet device to wireless there is
> > loss of 12% in the CPU utilization and equivalent throughput reduction
> > in data packets that are checked and expanded in
> > ieee80211_subif_start_xmit function.
>
> Yeah, I figured.
I think we can handle this without clones or copies.
First, the skb_header_cloned() patch I posted in another reply will
get rid of copying due to clones. I've included it below for
completeness.
The next problem is to make sure there is enough space available. And
all that's needed is some help from the bridging layer and some hooks
into netdev_alloc_skb().
On bridge transmit, it knows the input and output devices, and the
requirements of LL header space on the transmit side.
If the transmit requirements are not met for the received packet, we
can tag the difference into the input netdev.
Using that information we can allocate extra space in
netdev_alloc_skb(), and do an skb_reserve().
The only requirement is that the ethernet driver serving input packets
uses netdev_alloc_skb(). The most important drivers already do, and
those which do not are trivially converted.
The following along with Johannes's needed_header et al. patch should
take care of the overhead.
If this proves to be a working solution, we can do something similar
for IPv4 and IPv6 forwarding. At that point, we should make this
"adjust input device extra space" a helper function that all of
these spots can call.
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 7c1d446..6c06fba 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -600,6 +600,7 @@ struct net_device
* Cache line mostly used on receive path (including eth_type_trans())
*/
unsigned long last_rx; /* Time of last Rx */
+ unsigned int rx_alloc_extra;
/* Interface address info used in eth_type_trans() */
unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address, (before bcast
because most packets are unicast) */
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index bdd7c35..d2b2272 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -42,6 +42,22 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
if (nf_bridge_maybe_copy_header(skb))
kfree_skb(skb);
else {
+ unsigned int headroom = skb_headroom(skb);
+ unsigned int hh_len = LL_RESERVED_SPACE(skb->dev);
+
+ if (headroom < hh_len) {
+ struct net_device *in_dev;
+ unsigned int extra;
+
+ in_dev = __dev_get_by_index(dev_net(skb->dev),
+ skb->iif);
+ BUG_ON(!in_dev);
+
+ extra = hh_len - headroom;
+ if (extra >= in_dex->rx_alloc_extra)
+ in_dev->rx_alloc_extra = extra;
+ }
+
skb_push(skb, ETH_HLEN);
dev_queue_xmit(skb);
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 5c459f2..74a2515 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -255,11 +255,12 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
unsigned int length, gfp_t gfp_mask)
{
int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1;
+ unsigned int extra = dev->rx_alloc_extra + NET_SKB_PAD;
struct sk_buff *skb;
- skb = __alloc_skb(length + NET_SKB_PAD, gfp_mask, 0, node);
+ skb = __alloc_skb(length + extra, gfp_mask, 0, node);
if (likely(skb)) {
- skb_reserve(skb, NET_SKB_PAD);
+ skb_reserve(skb, extra);
skb->dev = dev;
}
return skb;
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index f35eaea..86f0e36 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1562,13 +1562,13 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
* be cloned. This could happen, e.g., with Linux bridge code passing
* us broadcast frames. */
- if (head_need > 0 || skb_cloned(skb)) {
+ if (head_need > 0 || skb_header_cloned(skb)) {
#if 0
printk(KERN_DEBUG "%s: need to reallocate buffer for %d bytes "
"of headroom\n", dev->name, head_need);
#endif
- if (skb_cloned(skb))
+ if (skb_header_cloned(skb))
I802_DEBUG_INC(local->tx_expand_skb_head_cloned);
else
I802_DEBUG_INC(local->tx_expand_skb_head);
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2008-05-05 23:03 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-04 21:24 [RFC] mac80211: assign needed_headroom/tailroom for netdevs Johannes Berg
[not found] ` <1209936253.7304.10.camel-YfaajirXv214zXjbi5bjpg@public.gmane.org>
2008-05-04 21:31 ` Johannes Berg
2008-05-04 21:32 ` [RFC v2] " Johannes Berg
[not found] ` <1209936745.7304.16.camel-YfaajirXv214zXjbi5bjpg@public.gmane.org>
2008-05-05 0:30 ` David Miller
[not found] ` <20080504.173051.133197507.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2008-05-05 7:22 ` Johannes Berg
[not found] ` <1209972139.3655.9.camel-YfaajirXv214zXjbi5bjpg@public.gmane.org>
2008-05-05 14:27 ` Tomas Winkler
[not found] ` <1ba2fa240805050727r2060b0b4x3a9b3240647b66b1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-05-05 15:22 ` Johannes Berg
[not found] ` <1210000923.8245.26.camel-YfaajirXv214zXjbi5bjpg@public.gmane.org>
2008-05-05 17:15 ` Tomas Winkler
2008-05-05 17:57 ` Johannes Berg
2008-05-05 18:58 ` David Miller
[not found] ` <20080505.115855.137964071.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2008-05-05 19:05 ` Johannes Berg
2008-05-05 19:50 ` David Miller
2008-05-05 19:57 ` Johannes Berg
2008-05-05 20:02 ` David Miller
2008-05-05 20:10 ` Johannes Berg
[not found] ` <1210018214.4181.27.camel-YfaajirXv214zXjbi5bjpg@public.gmane.org>
2008-05-05 20:44 ` David Miller
2008-05-05 20:57 ` Johannes Berg
[not found] ` <1210021066.4181.41.camel-YfaajirXv214zXjbi5bjpg@public.gmane.org>
2008-05-05 21:01 ` David Miller
2008-05-05 22:37 ` David Miller
2008-05-05 22:44 ` Johannes Berg
[not found] ` <1210027447.8012.15.camel-YfaajirXv214zXjbi5bjpg@public.gmane.org>
2008-05-05 23:14 ` David Miller
[not found] ` <20080505.161458.46071527.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2008-05-05 23:23 ` Johannes Berg
[not found] ` <1210029835.8012.30.camel-YfaajirXv214zXjbi5bjpg@public.gmane.org>
2008-05-05 23:39 ` David Miller
[not found] ` <20080505.163916.239187195.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2008-05-06 0:01 ` Johannes Berg
[not found] ` <1210032076.8012.49.camel-YfaajirXv214zXjbi5bjpg@public.gmane.org>
2008-05-06 0:08 ` David Miller
[not found] ` <20080505.170805.127854312.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2008-05-06 11:13 ` Johannes Berg
2008-05-06 1:32 ` Herbert Xu
2008-05-13 5:01 ` David Miller
2008-05-05 23:03 ` David Miller [this message]
[not found] ` <20080505.160328.203996832.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2008-05-05 23:17 ` Johannes Berg
[not found] ` <1210029435.8012.25.camel-YfaajirXv214zXjbi5bjpg@public.gmane.org>
2008-05-05 23:24 ` David Miller
[not found] ` <20080505.162424.176435653.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2008-05-05 23:30 ` Johannes Berg
2008-05-05 23:36 ` Johannes Berg
[not found] ` <1210030591.8012.41.camel-YfaajirXv214zXjbi5bjpg@public.gmane.org>
2008-05-05 23:40 ` David Miller
2008-05-13 3:52 ` David Miller
[not found] ` <20080512.205224.12536510.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2008-05-13 9:01 ` Johannes Berg
[not found] ` <1210669273.3646.51.camel-YfaajirXv214zXjbi5bjpg@public.gmane.org>
2008-05-13 9:45 ` David Miller
2008-05-13 10:07 ` Johannes Berg
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=20080505.160328.203996832.davem@davemloft.net \
--to=davem-ft/pcqaiutieiz0/mpfg9q@public.gmane.org \
--cc=johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org \
--cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=tomasw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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;
as well as URLs for NNTP newsgroup(s).