From: "David S. Miller" <davem@davemloft.net>
To: netdev@oss.sgi.com
Cc: herbert@gondor.apana.org.au, jheffner@psc.edu
Subject: [PATCH 1/9]: TCP: The Road to Super TSO
Date: Mon, 06 Jun 2005 21:16:17 -0700 (PDT) [thread overview]
Message-ID: <20050606.211617.92588086.davem@davemloft.net> (raw)
In-Reply-To: <20050606.210846.07641049.davem@davemloft.net>
[TCP]: Simplify SKB data portion allocation with NETIF_F_SG.
The ideal and most optimal layout for an SKB when doing
scatter-gather is to put all the headers at skb->data, and
all the user data in the page array.
This makes SKB splitting and combining extremely simple,
especially before a packet goes onto the wire the first
time.
So, when sk_stream_alloc_pskb() is given a zero size, make
sure there is no skb_tailroom(). This is achieved by applying
SKB_DATA_ALIGN() to the header length used here.
Next, make select_size() in TCP output segmentation use a
length of zero when NETIF_F_SG is true on the outgoing
interface.
Signed-off-by: David S. Miller <davem@davemloft.net>
28f78ef8dcc90a2a26499dab76678bd6813d7793 (from 3f5948fa2cbbda1261eec9a39ef3004b3caf73fb)
diff --git a/include/net/sock.h b/include/net/sock.h
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1130,13 +1130,16 @@ static inline void sk_stream_moderate_sn
static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk,
int size, int mem, int gfp)
{
- struct sk_buff *skb = alloc_skb(size + sk->sk_prot->max_header, gfp);
+ struct sk_buff *skb;
+ int hdr_len;
+ hdr_len = SKB_DATA_ALIGN(sk->sk_prot->max_header);
+ skb = alloc_skb(size + hdr_len, gfp);
if (skb) {
skb->truesize += mem;
if (sk->sk_forward_alloc >= (int)skb->truesize ||
sk_stream_mem_schedule(sk, skb->truesize, 0)) {
- skb_reserve(skb, sk->sk_prot->max_header);
+ skb_reserve(skb, hdr_len);
return skb;
}
__kfree_skb(skb);
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -775,13 +775,9 @@ static inline int select_size(struct soc
{
int tmp = tp->mss_cache_std;
- if (sk->sk_route_caps & NETIF_F_SG) {
- int pgbreak = SKB_MAX_HEAD(MAX_TCP_HEADER);
+ if (sk->sk_route_caps & NETIF_F_SG)
+ tmp = 0;
- if (tmp >= pgbreak &&
- tmp <= pgbreak + (MAX_SKB_FRAGS - 1) * PAGE_SIZE)
- tmp = pgbreak;
- }
return tmp;
}
@@ -891,11 +887,6 @@ new_segment:
tcp_mark_push(tp, skb);
goto new_segment;
} else if (page) {
- /* If page is cached, align
- * offset to L1 cache boundary
- */
- off = (off + L1_CACHE_BYTES - 1) &
- ~(L1_CACHE_BYTES - 1);
if (off == PAGE_SIZE) {
put_page(page);
TCP_PAGE(sk) = page = NULL;
next prev parent reply other threads:[~2005-06-07 4:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-07 4:08 [PATCH 0/9]: TCP: The Road to Super TSO David S. Miller
2005-06-07 4:16 ` David S. Miller [this message]
2005-06-07 4:17 ` [PATCH 2/9]: " David S. Miller
2005-06-07 4:17 ` [PATCH 3/9]: " David S. Miller
2005-06-07 4:18 ` [PATCH 4/9]: " David S. Miller
2005-06-07 4:19 ` [PATCH 5/9]: " David S. Miller
2005-06-07 4:20 ` [PATCH 6/9]: " David S. Miller
2005-06-07 4:21 ` [PATCH 7/9]: " David S. Miller
2005-06-07 4:22 ` [PATCH 8/9]: " David S. Miller
2005-06-07 4:23 ` [PATCH 9/9]: " David S. Miller
2005-06-07 4:56 ` [PATCH 0/9]: " Stephen Hemminger
2005-06-07 5:51 ` David S. Miller
2005-06-08 21:40 ` John Heffner
2005-06-08 21:49 ` David S. Miller
2005-06-08 22:10 ` Herbert Xu
2005-06-09 4:55 ` Leonid Grossman
2005-06-08 22:19 ` Leonid Grossman
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=20050606.211617.92588086.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=jheffner@psc.edu \
--cc=netdev@oss.sgi.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).