All of lore.kernel.org
 help / color / mirror / Atom feed
From: "David S. Miller" <davem@davemloft.net>
To: Anton Blanchard <anton@samba.org>
Cc: netdev@oss.sgi.com, herbert@gondor.apana.org.au
Subject: Re: [DEBUG]: sk_forward_alloc assertion failures
Date: Thu, 13 Jan 2005 20:19:14 -0800	[thread overview]
Message-ID: <20050113201914.46b7c4a2.davem@davemloft.net> (raw)
In-Reply-To: <20050114012504.GF6309@krispykreme.ozlabs.ibm.com>

On Fri, 14 Jan 2005 12:25:04 +1100
Anton Blanchard <anton@samba.org> wrote:

> Excellent! Ive forwarded it on, lets see if it reproduces.

I think Herbert and I may have zeroed in on the true cause
of this bug.  It's a bug older than TSO support, but it
never showed up because nothing really depended upon
skb->truesize being incredibly accurate.

do_tcp_sendpages(), when it allocates new SKBs, optimistically
sets skb->truesize to the struct sk_buff et al. overhead
plus tp->mss_cache.  This, in and of itself, leaves us generally
with a valid skb->truesize value.  At worst, it will be an
overestimate if we don't fully fill the SKB, but that's fine.
It's underestimates that can lead to the BUG case.

do_tcp_sendpages() aparently does this so it doesn't have to
keep adjusting skb->truesize, sk_wmem_queued, and sk_forward_alloc
as new page pieces are tacked onto the SKB.

tcp_sendmsg() works the other way, it actually does adjust all
the accounting knobs as each piece of user data is copied into
the packet.

So if tcp_sendmsg() creates the SKB, and then do_tcp_sendpages()
tacks pages onto the tail of that SKB, skb->truesize can be way
too small.

Later on if this were a TSO frame, and it gets deeply partially
acked, tcp_trim_skb() will underflow skb->truesize and this is
where all the trouble starts.

The easiest way to fix this is to simply make do_tcp_sendpages()
account just like tcp_sendmsg() does.  This is implemented below
and should be the real fix for the sk_forward_alloc assertion
failures.

===== net/ipv4/tcp.c 1.88 vs edited =====
--- 1.88/net/ipv4/tcp.c	2005-01-06 15:13:39 -08:00
+++ edited/net/ipv4/tcp.c	2005-01-13 19:44:36 -08:00
@@ -664,7 +664,7 @@
 			if (!sk_stream_memory_free(sk))
 				goto wait_for_sndbuf;
 
-			skb = sk_stream_alloc_pskb(sk, 0, tp->mss_cache,
+			skb = sk_stream_alloc_pskb(sk, 0, 0,
 						   sk->sk_allocation);
 			if (!skb)
 				goto wait_for_memory;
@@ -689,6 +689,9 @@
 
 		skb->len += copy;
 		skb->data_len += copy;
+		skb->truesize += copy;
+		sk->sk_wmem_queued += copy;
+		sk->sk_forward_alloc -= copy;
 		skb->ip_summed = CHECKSUM_HW;
 		tp->write_seq += copy;
 		TCP_SKB_CB(skb)->end_seq += copy;

  reply	other threads:[~2005-01-14  4:19 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-14  1:12 [DEBUG]: sk_forward_alloc assertion failures David S. Miller
2005-01-14  1:25 ` Anton Blanchard
2005-01-14  4:19   ` David S. Miller [this message]
2005-01-14 11:16     ` Herbert Xu
2005-01-14 12:03       ` Herbert Xu
2005-01-14 19:03         ` David S. Miller
2005-01-14 20:34           ` Herbert Xu
2005-01-14 21:27             ` David S. Miller
2005-01-14 21:38               ` Herbert Xu
2005-01-14 21:36                 ` David S. Miller
2005-01-14 21:55                   ` Herbert Xu
2005-01-14 22:04                     ` David S. Miller
2005-01-14 22:47                       ` Herbert Xu
2005-01-15  4:55                         ` David S. Miller
2005-01-15  5:45                           ` Herbert Xu
2005-01-17 20:37                             ` David S. Miller
2005-01-17 20:40                               ` Herbert Xu
2005-01-14 21:34         ` Herbert Xu
2005-01-14  1:37 ` Herbert Xu
2005-01-14  4:09   ` David S. Miller
2005-01-14  1:50 ` Sridhar Samudrala
2005-01-14  2:10   ` Herbert Xu
2005-01-14  3:44     ` David S. Miller
  -- strict thread matches above, loose matches on Subject: below --
2005-01-16 23:03 Nancy Milliner

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=20050113201914.46b7c4a2.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=anton@samba.org \
    --cc=herbert@gondor.apana.org.au \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.