Skip to contentSkip to conversation

: sk_forward_alloc assertion failures

DEBUG David S. Miller 4 participants 23 messages Jan 14, 2005 – Jan 17, 2005

Subsystems (3)
lore
Share & tools
lore

David S. Miller

author maintainer
#0 lore raw

Anton, can you and the other IBM folks who can reproduce the problem give this test patch a whirl?

Herbert and I aren't exactly sure what the exact sequence of events is that causes the problem, but we do know that this code is highly suspect.

[ BTW, Herbert, it just occurred to me that these adjustments
are incorrect for the skb->data pulling case since we really aren't liberating the data. ]

Thanks.

===== net/ipv4/tcp_output.c 1.75 vs edited =====

net/ipv4/tcp_output.c +2 -2
@@ -580,12 +580,12 @@
 
 	TCP_SKB_CB(skb)->seq += len;
 	skb->ip_summed = CHECKSUM_HW;
-
+#if 0
 	skb->truesize	     -= len;
 	sk->sk_queue_shrunk   = 1;
 	sk->sk_wmem_queued   -= len;
 	sk->sk_forward_alloc += len;
-
+#endif
 	/* Any change of skb->len requires recalculation of tso
 	 * factor and mss.
 	 */
#1 lore raw

Hi Dave,

Quoted 10 lines

Anton, can you and the other IBM folks who can reproduce the problem give this test patch a whirl?

Herbert and I aren't exactly sure what the exact sequence of events is that causes the problem, but we do know that this code is highly suspect.

[ BTW, Herbert, it just occurred to me that these adjustments
are incorrect for the skb->data pulling case since we really aren't liberating the data. ]

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

Anton

author maintainer
#2 lore raw
Quoted 1 line · On Fri, 14 Jan 2005 12:25:04 +1100 Anton Blanchard <[email protected]> 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 =====

net/ipv4/tcp.c +4 -1
@@ -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;
#3 lore raw
Quoted 5 lines · David S. Miller

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.

Sorry, but this may bypass the memory checks if sk_forward_alloc is less than mss_now.

Since the packet is bounded by mss_now, and most of the time it will be exactly mss_now bytes long, how about if we simply replace tp->mss_cache by mss_now?

Could you guys please give this patch a go?

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

===== net/ipv4/tcp.c 1.88 vs edited =====

net/ipv4/tcp.c +1 -1
@@ -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, mss_now,
 						   sk->sk_allocation);
 			if (!skb)
 				goto wait_for_memory;
#4 lore raw
Quoted 4 lines · herbert

Since the packet is bounded by mss_now, and most of the time it will be exactly mss_now bytes long, how about if we simply replace tp->mss_cache by mss_now?

Doh! My patch is the same as the current code :)

What we need to do is to remember mss_now across sendpage calls. Luckily the value of truesize lets us deduce the value of mss_now. To complicate the picture the mss might have been reduced between sendpages calls. So we take the minimum of the remembered mss and the current mss.

Any brave souls out there to try this?

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

===== net/ipv4/tcp.c 1.88 vs edited =====

net/ipv4/tcp.c +13 -5
@@ -654,23 +654,31 @@
 
 	while (psize > 0) {
 		struct sk_buff *skb = sk->sk_write_queue.prev;
+		int skb_mss;
 		struct page *page = pages[poffset / PAGE_SIZE];
 		int copy, i;
 		int offset = poffset % PAGE_SIZE;
 		int size = min_t(size_t, psize, PAGE_SIZE - offset);
 
-		if (!sk->sk_send_head || (copy = mss_now - skb->len) <= 0) {
+		if (!sk->sk_send_head)
+			goto new_segment;
+
+		skb_mss = skb_netsize(skb) - skb_headroom(skb);
+		if (mss_now < skb_mss)
+			skb_mss = mss_now;
+		if ((copy = skb_mss - skb->len) <= 0) {
 new_segment:
 			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, mss_now,
 						   sk->sk_allocation);
 			if (!skb)
 				goto wait_for_memory;
 
 			skb_entail(sk, tp, skb);
 			copy = mss_now;
+			skb_mss = mss_now;
 		}
 
 		if (copy > size)
@@ -702,14 +710,14 @@
 		if (!(psize -= copy))
 			goto out;
 
-		if (skb->len != mss_now || (flags & MSG_OOB))
+		if (skb->len != skb_mss || (flags & MSG_OOB))
 			continue;
 
 		if (forced_push(tp)) {
 			tcp_mark_push(tp, skb);
-			__tcp_push_pending_frames(sk, tp, mss_now, TCP_NAGLE_PUSH);
+			__tcp_push_pending_frames(sk, tp, skb_mss, TCP_NAGLE_PUSH);
 		} else if (skb == sk->sk_send_head)
-			tcp_push_one(sk, mss_now);
+			tcp_push_one(sk, skb_mss);
 		continue;
 
 wait_for_sndbuf:

===== include/linux/skbuff.h 1.58 vs edited =====

include/linux/skbuff.h +5 -0
@@ -1124,6 +1124,11 @@
 	return buffer;
 }
 
+static inline int skb_netsize(const struct sk_buff *skb)
+{
+	return skb->truesize - sizeof(struct sk_buff);
+}
+
 extern void skb_init(void);
 extern void skb_add_mtu(int mtu);
 
author maintainer
#5 lore raw
Quoted 7 lines · On Fri, 14 Jan 2005 23:03:22 +1100 Herbert Xu <[email protected]>…

What we need to do is to remember mss_now across sendpage calls. Luckily the value of truesize lets us deduce the value of mss_now. To complicate the picture the mss might have been reduced between sendpages calls. So we take the minimum of the remembered mss and the current mss.

Any brave souls out there to try this?

Herbert, this patch doesn't fix the bug. We still have to do the adjustments gradually just like sendmsg(). That's the whole problem.

If sendmsg() creates the SKB, then sendpages() adds paged data onto the end, we don't make skb->truesize big enough.

#6 lore raw
Quoted 7 lines · David S. Miller

Herbert, this patch doesn't fix the bug. We still have to do the adjustments gradually just like sendmsg(). That's the whole problem.

If sendmsg() creates the SKB, then sendpages() adds paged data onto the end, we don't make skb->truesize big enough.

My reasoning is as follows:

The size of the skb is bounded by the MSS. Therefore it can never grow beyond that. So if we allocated that much memory then we can tack bits on as long as we don't exceed the original MSS that was used.

The problem before was that the MSS could've changed between sendpages calls. If it increased then we may exceed the amount of memory allocated originally.

My idea is to remember the original MSS so that we never exceed it. Did I missing something?

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
author maintainer
#7 lore raw
Quoted 7 lines · On Sat, 15 Jan 2005 07:34:52 +1100 Herbert Xu <[email protected]>…

My reasoning is as follows:

The size of the skb is bounded by the MSS. Therefore it can never grow beyond that. So if we allocated that much memory then we can tack bits on as long as we don't exceed the original MSS that was used.

Quoted 6 lines

The problem before was that the MSS could've changed between sendpages calls. If it increased then we may exceed the amount of memory allocated originally.

My idea is to remember the original MSS so that we never exceed it. Did I missing something?

You missed the whole problem.

It has nothing to do with the MSS changing.

The bug case is when _SEND_MSG_ creates the SKB, and a subsequent _SEND_PAGE_ call adds pages onto that SKB in the queue.

Unlike _SEND_PAGE_, _SEND_MSG_ does not do the "allocate tp->mss_cache" thingy. Instead, it adjusts the queueing allocation values as it copies the data into the SKB.

Therefore my change aims to make _SEND_PAGE_ use _SEND_MSG_'s accounting scheme (adjust as we actually add the data) so that it all works out.

That fix is in Linus's tree at this point.

#8 lore raw
Quoted 4 lines · David S. Miller

You missed the whole problem.

It has nothing to do with the MSS changing.

However if the MSS does change then it can cause the same symptoms. In fact the MSS can easily increase when TSO is enabled since it increases as the RCV window is opened up.

Quoted 9 lines

The bug case is when _SEND_MSG_ creates the SKB, and a subsequent _SEND_PAGE_ call adds pages onto that SKB in the queue.

Unlike _SEND_PAGE_, _SEND_MSG_ does not do the "allocate tp->mss_cache" thingy. Instead, it adjusts the queueing allocation values as it copies the data into the SKB.

Therefore my change aims to make _SEND_PAGE_ use _SEND_MSG_'s accounting scheme (adjust as we actually add the data) so that it all works out.

I understand your point about sendmsg followed by sendpages. My patch addresses that as well by making sure that we don't tack on more bits than what's allowed by skb->truesize.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
author maintainer
#9 lore raw
Quoted 9 lines · On Sat, 15 Jan 2005 08:38:29 +1100 Herbert Xu <[email protected]>…
Quoted 4 lines · David S. Miller

You missed the whole problem.

It has nothing to do with the MSS changing.

However if the MSS does change then it can cause the same symptoms. In fact the MSS can easily increase when TSO is enabled since it increases as the RCV window is opened up.

MSS changes are handled _transparently_ if we do the adjustments as we actaully add data to the packet. We always account what is actually put into the packet in this way.

That's why I made the fix the way that I did.

#10 lore raw
Quoted 6 lines · David S. Miller

MSS changes are handled _transparently_ if we do the adjustments as we actaully add data to the packet. We always account what is actually put into the packet in this way.

That's why I made the fix the way that I did.

You're right. However, doing so requires us to check sk_forward_alloc every time around the loop. That is, you'll need to do the same check as is done in sk_stream_alloc_pskb and sk_stream_alloc_page. If we simply adjust sk_forward_alloc as you do now then it can easily go negative if we didn't have enough memory to start with.

My point is that most of the time sendpages will produce a packet that is MSS-sized. Therefore we can avoid the duplicate work (if the connection is at full throttle then MSS ~~ 64K which is much bigger than the page size of 4K) by allocating MSS bytes up front in sk_forward_alloc.

As long as we're careful about what we've allocated in the skb then everything will be alright. We're in trouble right now with mixed sendmsg/sendpages calls and changing MSSs only because we're not careful about keeping track of how much memory we've allocated at the start.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
author maintainer
#11 lore raw
Quoted 5 lines · On Sat, 15 Jan 2005 08:55:04 +1100 Herbert Xu <[email protected]>…

As long as we're careful about what we've allocated in the skb then everything will be alright. We're in trouble right now with mixed sendmsg/sendpages calls and changing MSSs only because we're not careful about keeping track of how much memory we've allocated at the start.

I see, but we don't want sendmsg() to charge a full MSS if the user is only writing 10 bytes of data onto the wire. That seems to be what happens if we implement things the way you are suggesting.

#12 lore raw
Quoted 4 lines · David S. Miller

I see, but we don't want sendmsg() to charge a full MSS if the user is only writing 10 bytes of data onto the wire. That seems to be what happens if we implement things the way you are suggesting.

Yes you're right. Although I belive it only happens in the case of sendpages(). It will allocate more memory than what's required in that case. I'd say that it should be rare to have a 10 byte packet with sendfile() though.

However, it's not all that difficult to fix up either. We can adjust truesize to a more reasonable value in tcp_write_xmit(). Something like this will do.

Actually it happens in the case of sendmsg() too. Unfortunately in that case we can't do a thing about it since the memory is allocated between skb->head and skb->tail.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

===== net/ipv4/tcp_output.c 1.75 vs edited =====

net/ipv4/tcp_output.c +12 -0
@@ -750,9 +750,21 @@
 		       tcp_snd_test(tp, skb, mss_now,
 			       	    tcp_skb_is_last(sk, skb) ? nonagle :
 				    			       TCP_NAGLE_PUSH)) {
+			unsigned int len, used;
+
 			if (skb->len > mss_now) {
 				if (tcp_fragment(sk, skb, mss_now))
 					break;
+			}
+
+			len = skb_netsize(skb);
+			used = skb->data_len + (skb->end - skb->head);
+			if (len > used) {
+				len -= used;
+				skb->truesize	     -= len;
+				sk->sk_queue_shrunk   = 1;
+				sk->sk_wmem_queued   -= len;
+				sk->sk_forward_alloc += len;
 			}
 
 			TCP_SKB_CB(skb)->when = tcp_time_stamp;
author maintainer
#13 lore raw
Quoted 7 lines · On Sat, 15 Jan 2005 09:47:45 +1100 Herbert Xu <[email protected]>…

However, it's not all that difficult to fix up either. We can adjust truesize to a more reasonable value in tcp_write_xmit(). Something like this will do.

Actually it happens in the case of sendmsg() too. Unfortunately in that case we can't do a thing about it since the memory is allocated between skb->head and skb->tail.

Doing the adjustments at tcp_write_xmit() time also runs into the problem you mentioned where we're just blindly subtracting from sk_forward_alloc.

I really still feel that the best way is to "adjust as we add data". sendmsg() does that already, I tried to add it simply to sendpage() but it just needs some checks and wait_for_memory logic.

Here's a patch against current BK that tries to do that. See any holes? :-)

===== net/ipv4/tcp.c 1.89 vs edited =====

net/ipv4/tcp.c +12 -6
@@ -655,7 +655,7 @@
 	while (psize > 0) {
 		struct sk_buff *skb = sk->sk_write_queue.prev;
 		struct page *page = pages[poffset / PAGE_SIZE];
-		int copy, i;
+		int copy, i, can_coalesce;
 		int offset = poffset % PAGE_SIZE;
 		int size = min_t(size_t, psize, PAGE_SIZE - offset);
 
@@ -677,14 +677,20 @@
 			copy = size;
 
 		i = skb_shinfo(skb)->nr_frags;
-		if (skb_can_coalesce(skb, i, page, offset)) {
+		can_coalesce = skb_can_coalesce(skb, i, page, offset);
+		if (!can_coalesce && i >= MAX_SKB_FRAGS) {
+			tcp_mark_push(tp, skb);
+			goto new_segment;
+		}
+		if (sk->sk_forward_alloc < copy &&
+		    !sk_stream_mem_schedule(sk, copy, 0))
+			goto wait_for_memory;
+		
+		if (can_coalesce) {
 			skb_shinfo(skb)->frags[i - 1].size += copy;
-		} else if (i < MAX_SKB_FRAGS) {
+		} else {
 			get_page(page);
 			skb_fill_page_desc(skb, i, page, offset, copy);
-		} else {
-			tcp_mark_push(tp, skb);
-			goto new_segment;
 		}
 
 		skb->len += copy;
#14 lore raw
Quoted 4 lines · David S. Miller

Doing the adjustments at tcp_write_xmit() time also runs into the problem you mentioned where we're just blindly subtracting from sk_forward_alloc.

Not really because what we're doing there is increasing sk_forward_alloc, just as we do in tcp_trim_head.

Anyway, I'm not terribly attached to that idea since we're doing a page's worth of data each time around the loop anyway so it's not too bad.

Quoted 2 lines

Here's a patch against current BK that tries to do that. See any holes? :-)

Just one little problem :)

net/ipv4/tcp.c line 686

Quoted 2 lines
net/ipv4/tcp.c +2 -0
+		if (sk->sk_forward_alloc < copy &&
+		    !sk_stream_mem_schedule(sk, copy, 0))

You want to have sk->sk_allocation here instead of 0.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
author maintainer
#15 lore raw
Quoted 4 lines · On Sat, 15 Jan 2005 16:45:47 +1100 Herbert Xu <[email protected]>…

net/ipv4/tcp.c line 686

Quoted 2 lines
net/ipv4/tcp.c +2 -0
+		if (sk->sk_forward_alloc < copy &&
+		    !sk_stream_mem_schedule(sk, copy, 0))

You want to have sk->sk_allocation here instead of 0.

The third argument to sk_stream_mem_schedule() is "int kind" which is to be set to 1 for receive packet allocations and 0 for send packet allocations.

Why would I want to use a sk_allocation gfp mask here? :-)

#16 lore raw
Quoted 8 lines · David S. Miller
Quoted 4 lines · On Sat, 15 Jan 2005 16:45:47 +1100 Herbert Xu <[email protected]>…

net/ipv4/tcp.c line 686

Quoted 2 lines
net/ipv4/tcp.c +2 -0
+		if (sk->sk_forward_alloc < copy &&
+		    !sk_stream_mem_schedule(sk, copy, 0))

You want to have sk->sk_allocation here instead of 0.

Quoted 5 lines

The third argument to sk_stream_mem_schedule() is "int kind" which is to be set to 1 for receive packet allocations and 0 for send packet allocations.

Why would I want to use a sk_allocation gfp mask here? :-)

You're right. I got carried away there :)

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#17 lore raw
In reply to Herbert Xu
Quoted 4 lines · herbert

To complicate the picture the mss might have been reduced between sendpages calls. So we take the minimum of the remembered mss and the current mss.

With that the packet size might actually exceed the current mss. So we need to change the skb->len != skb_mss test to skb->len < skb_mss.

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

===== net/ipv4/tcp.c 1.88 vs edited =====

net/ipv4/tcp.c +13 -5
@@ -654,23 +654,31 @@
 
 	while (psize > 0) {
 		struct sk_buff *skb = sk->sk_write_queue.prev;
+		int skb_mss;
 		struct page *page = pages[poffset / PAGE_SIZE];
 		int copy, i;
 		int offset = poffset % PAGE_SIZE;
 		int size = min_t(size_t, psize, PAGE_SIZE - offset);
 
-		if (!sk->sk_send_head || (copy = mss_now - skb->len) <= 0) {
+		if (!sk->sk_send_head)
+			goto new_segment;
+
+		skb_mss = skb_netsize(skb) - skb_headroom(skb);
+		if (mss_now < skb_mss)
+			skb_mss = mss_now;
+		if ((copy = skb_mss - skb->len) <= 0) {
 new_segment:
 			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, mss_now,
 						   sk->sk_allocation);
 			if (!skb)
 				goto wait_for_memory;
 
 			skb_entail(sk, tp, skb);
 			copy = mss_now;
+			skb_mss = mss_now;
 		}
 
 		if (copy > size)
@@ -702,14 +710,14 @@
 		if (!(psize -= copy))
 			goto out;
 
-		if (skb->len != mss_now || (flags & MSG_OOB))
+		if (skb->len < skb_mss || (flags & MSG_OOB))
 			continue;
 
 		if (forced_push(tp)) {
 			tcp_mark_push(tp, skb);
-			__tcp_push_pending_frames(sk, tp, mss_now, TCP_NAGLE_PUSH);
+			__tcp_push_pending_frames(sk, tp, skb_mss, TCP_NAGLE_PUSH);
 		} else if (skb == sk->sk_send_head)
-			tcp_push_one(sk, mss_now);
+			tcp_push_one(sk, skb_mss);
 		continue;
 
 wait_for_sndbuf:

===== include/linux/skbuff.h 1.58 vs edited =====

include/linux/skbuff.h +5 -0
@@ -1124,6 +1124,11 @@
 	return buffer;
 }
 
+static inline int skb_netsize(const struct sk_buff *skb)
+{
+	return skb->truesize - sizeof(struct sk_buff);
+}
+
 extern void skb_init(void);
 extern void skb_add_mtu(int mtu);
 
#18 lore raw
In reply to David S. Miller
Quoted 4 lines · David S. Miller

[ BTW, Herbert, it just occurred to me that these adjustments
are incorrect for the skb->data pulling case since we really aren't liberating the data. ]

Yes but I thought the idea was to fake it so the application can transmit more packets? Without TSO, the data would've been freed at this point.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
author maintainer
#19 lore raw
Quoted 9 lines · On Fri, 14 Jan 2005 12:37:37 +1100 Herbert Xu <[email protected]>…
Quoted 4 lines · David S. Miller

[ BTW, Herbert, it just occurred to me that these adjustments
are incorrect for the skb->data pulling case since we really aren't liberating the data. ]

Yes but I thought the idea was to fake it so the application can transmit more packets? Without TSO, the data would've been freed at this point.

You're right. At most we'll pseudo-free no more than 1 full packet, so it's safe.

#20 lore raw
In reply to David S. Miller

Dave,

I think with this patch we will start seeing
sk_wmem_queued assertions.

Currently sk_wmem_queued seems to be accounted
correctly, but this patch changes this value too.

-Sridhar

Quoted 34 lines · David S. Miller

Anton, can you and the other IBM folks who can reproduce the problem give this test patch a whirl?

Herbert and I aren't exactly sure what the exact sequence of events is that causes the problem, but we do know that this code is highly suspect.

[ BTW, Herbert, it just occurred to me that these adjustments
are incorrect for the skb->data pulling case since we really aren't liberating the data. ]

Thanks.

===== net/ipv4/tcp_output.c 1.75 vs edited =====

net/ipv4/tcp_output.c +2 -2
@@ -580,12 +580,12 @@
 
 	TCP_SKB_CB(skb)->seq += len;
 	skb->ip_summed = CHECKSUM_HW;
-
+#if 0
 	skb->truesize	     -= len;
 	sk->sk_queue_shrunk   = 1;
 	sk->sk_wmem_queued   -= len;
 	sk->sk_forward_alloc += len;
-
+#endif
 	/* Any change of skb->len requires recalculation of tso
 	 * factor and mss.
 	 */
#21 lore raw
Quoted 3 lines · Sridhar Samudrala

I think with this patch we will start seeing
sk_wmem_queued assertions.

Not necessarily. What's probably happening currently is that sk_forward_alloc is temporarily raised above the value it should have. It then gets cut down by the reclaim function and subsequently goes negative.

Since there is no reclaim for sk_wmem_queued it doesn't happen there.

So taking out the adjustments should not cause any problems of sk_wmem_queued, theoretically :)

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
author maintainer
#22 lore raw
Quoted 5 lines · On Fri, 14 Jan 2005 13:10:05 +1100 Herbert Xu <[email protected]>…

Since there is no reclaim for sk_wmem_queued it doesn't happen there.

So taking out the adjustments should not cause any problems of sk_wmem_queued, theoretically :)

If we take out the skb->truesize adjustment, as the test patch does, then we must take out the sk_wmem_queued and sk_forward_alloc adjustments, as the test patch also does. :-)