From: Eric Dumazet <eric.dumazet@gmail.com>
To: Alexander Duyck <alexander.h.duyck@intel.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net,
jeffrey.t.kirsher@intel.com, edumazet@google.com
Subject: Re: [v2 PATCH 1/4] tcp: Fix truesize accounting in tcp_try_coalesce
Date: Thu, 03 May 2012 09:48:54 +0200 [thread overview]
Message-ID: <1336031334.3503.23.camel@edumazet-glaptop> (raw)
In-Reply-To: <20120503071859.13636.30050.stgit@gitlad.jf.intel.com>
On Thu, 2012-05-03 at 00:18 -0700, Alexander Duyck wrote:
> This patch addresses several issues in the way we were tracking the
> truesize in tcp_try_coalesce.
>
> First it was using ksize which prevents us from having a 0 sized head frag
> and getting a usable result. To resolve that this patch uses the end
> pointer which is set based off either ksize, or the frag_size supplied in
> build_skb. This allows us to compute the original truesize of the entire
> buffer and remove that value leaving us with just what was added as pages.
>
> The second issue was the use of skb->len if there is a mergeable head frag.
> We should only need to remove the size of an data aligned sk_buff from our
> current skb->truesize to compute the delta for a buffer with a reused head.
> By using skb->len the value of truesize was being artificially reduced
> which means that head frags could use more memory than buffers using
> standard allocations.
>
> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> ---
>
> net/ipv4/tcp_input.c | 10 ++++------
> 1 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index c6f78e2..3cb273a 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -4565,12 +4565,10 @@ merge:
> if (skb_headlen(from) == 0 &&
> (skb_shinfo(to)->nr_frags +
> skb_shinfo(from)->nr_frags <= MAX_SKB_FRAGS)) {
> - WARN_ON_ONCE(from->head_frag);
> - delta = from->truesize - ksize(from->head) -
> - SKB_DATA_ALIGN(sizeof(struct sk_buff));
> -
> - WARN_ON_ONCE(delta < len);
> + delta = from->truesize -
> + SKB_TRUESIZE(skb_end_pointer(from) - from->head);
> copyfrags:
> + WARN_ON_ONCE(delta < len);
> memcpy(skb_shinfo(to)->frags + skb_shinfo(to)->nr_frags,
> skb_shinfo(from)->frags,
> skb_shinfo(from)->nr_frags * sizeof(skb_frag_t));
> @@ -4600,7 +4598,7 @@ copyfrags:
> skb_fill_page_desc(to, skb_shinfo(to)->nr_frags,
> page, offset, skb_headlen(from));
> *fragstolen = true;
> - delta = len; /* we dont know real truesize... */
> + delta = from->truesize - SKB_DATA_ALIGN(sizeof(struct sk_buff));
> goto copyfrags;
> }
> return false;
>
> --
Acked-by: Eric Dumazet <edumazet@google.com>
next prev parent reply other threads:[~2012-05-03 7:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-03 7:18 [v2 PATCH 0/4] Cleanup tcp_try_coalesce, fix module lockup on ixgbe Alexander Duyck
2012-05-03 7:18 ` [v2 PATCH 1/4] tcp: Fix truesize accounting in tcp_try_coalesce Alexander Duyck
2012-05-03 7:48 ` Eric Dumazet [this message]
2012-05-03 8:21 ` David Miller
2012-05-03 9:33 ` [PATCH net-next] net: Fix truesize accounting in skb_gro_receive() Eric Dumazet
2012-05-03 10:48 ` Alexander Duyck
2012-05-03 17:22 ` David Miller
2012-05-03 7:19 ` [v2 PATCH 2/4] tcp: Move code related to head frag in tcp_try_coalesce Alexander Duyck
2012-05-03 7:50 ` Eric Dumazet
2012-05-03 8:22 ` David Miller
2012-05-03 7:19 ` [v2 PATCH 3/4] tcp: move stats merge to the end of tcp_try_coalesce Alexander Duyck
2012-05-03 7:52 ` Eric Dumazet
2012-05-03 8:22 ` David Miller
2012-05-03 7:19 ` [v2 PATCH 4/4] ixgbe: Fix use after free on module remove Alexander Duyck
2012-05-03 8:22 ` David Miller
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=1336031334.3503.23.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=alexander.h.duyck@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jeffrey.t.kirsher@intel.com \
--cc=netdev@vger.kernel.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