Skip to contentSkip to conversation

lots of cpu time spent in skb_copy_bits() in net-next with small mtu

DISCUSSION Benjamin LaHaise 4 participants 6 messages Jun 12, 2009 – Jun 17, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi folks,

Just a heads up: something in net-next is resulting in lots of cpu time being spent in skb_copy_bits() (called from tcp_collapse()) when an ethernet interface mtu is lowered to 576 on the source and dest machines running netperf. This behaviour does not appear in 2.6.29. I'll try to bisect it this weekend.

-ben

#1 lore raw
Quoted 5 lines · Benjamin LaHaise

Just a heads up: something in net-next is resulting in lots of cpu time being spent in skb_copy_bits() (called from tcp_collapse()) when an ethernet interface mtu is lowered to 576 on the source and dest machines running netperf. This behaviour does not appear in 2.6.29. I'll try to bisect it this weekend.

I'd suggest somebody goes through DaveM's abstraction patch 915219441d56 (I'm totally out of time so somebody else has to do it if a timely solution is desired)... It was quite messy on those parts and I already found one issue from it (2df9001edc3) and wouldn't be too surprised if there would be some more lurking around...

Signature · 1 line
 i.
#2 lore raw
Quoted 8 lines · Ilpo Järvinen
Quoted 5 lines · Benjamin LaHaise

Just a heads up: something in net-next is resulting in lots of cpu time being spent in skb_copy_bits() (called from tcp_collapse()) when an ethernet interface mtu is lowered to 576 on the source and dest machines running netperf. This behaviour does not appear in 2.6.29. I'll try to bisect it this weekend.

Quoted 5 lines

I'd suggest somebody goes through DaveM's abstraction patch 915219441d56 (I'm totally out of time so somebody else has to do it if a timely solution is desired)... It was quite messy on those parts and I already found one issue from it (2df9001edc3) and wouldn't be too surprised if there would be some more lurking around...

I couldn't find anything wrong with tcp_prune_queue() and its helpers as they appear in today's net-next.

Take that with a grain of salt if you wish--I'm going to go take a couple grains of aspirin.

-- John

#3 lore raw
Quoted 15 lines · John Dykstra
Quoted 8 lines · Ilpo Järvinen
Quoted 5 lines · Benjamin LaHaise

Just a heads up: something in net-next is resulting in lots of cpu time being spent in skb_copy_bits() (called from tcp_collapse()) when an ethernet interface mtu is lowered to 576 on the source and dest machines running netperf. This behaviour does not appear in 2.6.29. I'll try to bisect it this weekend.

Quoted 5 lines

I'd suggest somebody goes through DaveM's abstraction patch 915219441d56 (I'm totally out of time so somebody else has to do it if a timely solution is desired)... It was quite messy on those parts and I already found one issue from it (2df9001edc3) and wouldn't be too surprised if there would be some more lurking around...

Quoted 5 lines

I couldn't find anything wrong with tcp_prune_queue() and its helpers as they appear in today's net-next.

Take that with a grain of salt if you wish--I'm going to go take a couple grains of aspirin.

:-) Thanks for taking a look.

While I took a very short view on it earlier I notice that handling of the case when head is at the last skb and tail is at the end of queue was changed (without mention in the commit message whether it was intentionally) in the Dave's change (we used to exit at skb == tail while we don't necessarily do that anymore but take the additional checks that are made inside the loop ub tcp_collapse()). It would be nice if Dave would split that kind of complex transformation into more easily verifiable changes, even if the intermediate form itself would not remain in the final form, as is it's rather hard to track it all :-).

I'm not sure if that change is significant though as one might view it as the opposite, ie., that the previous was unintented early exit since we wouldn't collapse bloated skb in the end but who knows... ...But I'm yet to really _understand_ everything that is going on there.

Signature · 1 line
 i.
maintainer
#4 lore raw

From: "Ilpo Järvinen" <[email protected]>
Date: Wed, 17 Jun 2009 08:46:56 +0300 (EEST)

Quoted 10 lines

While I took a very short view on it earlier I notice that handling of the case when head is at the last skb and tail is at the end of queue was changed (without mention in the commit message whether it was intentionally) in the Dave's change (we used to exit at skb == tail while we don't necessarily do that anymore but take the additional checks that are made inside the loop ub tcp_collapse()). It would be nice if Dave would split that kind of complex transformation into more easily verifiable changes, even if the intermediate form itself would not remain in the final form, as is it's rather hard to track it all :-).

Quoted 4 lines

I'm not sure if that change is significant though as one might view it as the opposite, ie., that the previous was unintented early exit since we wouldn't collapse bloated skb in the end but who knows... ...But I'm yet to really _understand_ everything that is going on there.

Sorry, will be more careful in the future. :-)

Can we atleast verify that applying the following revert patch makes the problem go away? (it's a combination revert of commits 2df9001edc382c331f338f45d259feeaa740c418 and 915219441d566f1da0caa0e262be49b666159e17).

net/ipv4/tcp.c +10 -7
index 17b89c5..0fb8b44 100644
@@ -439,14 +439,12 @@ int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg)
 			 !tp->urg_data ||
 			 before(tp->urg_seq, tp->copied_seq) ||
 			 !before(tp->urg_seq, tp->rcv_nxt)) {
-			struct sk_buff *skb;
-
 			answ = tp->rcv_nxt - tp->copied_seq;
 
 			/* Subtract 1, if FIN is in queue. */
-			skb = skb_peek_tail(&sk->sk_receive_queue);
-			if (answ && skb)
-				answ -= tcp_hdr(skb)->fin;
+			if (answ && !skb_queue_empty(&sk->sk_receive_queue))
+				answ -=
+		       tcp_hdr((struct sk_buff *)sk->sk_receive_queue.prev)->fin;
 		} else
 			answ = tp->urg_seq - tp->copied_seq;
 		release_sock(sk);
@@ -1384,7 +1382,11 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
 
 		/* Next get a buffer. */
 
-		skb_queue_walk(&sk->sk_receive_queue, skb) {
+		skb = skb_peek(&sk->sk_receive_queue);
+		do {
+			if (!skb)
+				break;
+
 			/* Now that we have two receive queues this
 			 * shouldn't happen.
 			 */
@@ -1401,7 +1403,8 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
 			if (tcp_hdr(skb)->fin)
 				goto found_fin_ok;
 			WARN_ON(!(flags & MSG_PEEK));
-		}
+			skb = skb->next;
+		} while (skb != (struct sk_buff *)&sk->sk_receive_queue);
 
 		/* Well, if we have backlog, try to process it now yet. */
 
net/ipv4/tcp_input.c +28 -70

185 lines not on this page · raw message

#5 lore raw
Quoted 13 lines · David Miller

From: "Ilpo Järvinen" <[email protected]>
Date: Wed, 17 Jun 2009 08:46:56 +0300 (EEST)

Quoted 10 lines

While I took a very short view on it earlier I notice that handling of the case when head is at the last skb and tail is at the end of queue was changed (without mention in the commit message whether it was intentionally) in the Dave's change (we used to exit at skb == tail while we don't necessarily do that anymore but take the additional checks that are made inside the loop ub tcp_collapse()). It would be nice if Dave would split that kind of complex transformation into more easily verifiable changes, even if the intermediate form itself would not remain in the final form, as is it's rather hard to track it all :-).

Quoted 6 lines
Quoted 4 lines

I'm not sure if that change is significant though as one might view it as the opposite, ie., that the previous was unintented early exit since we wouldn't collapse bloated skb in the end but who knows... ...But I'm yet to really _understand_ everything that is going on there.

Sorry, will be more careful in the future. :-)

I re-looked into the problem I supposedly found earlier and it seems that it turned out to be a false alarm... Huoh, how complex it is track that change :-).

Quoted 4 lines

Can we atleast verify that applying the following revert patch makes the problem go away? (it's a combination revert of commits 2df9001edc382c331f338f45d259feeaa740c418 and 915219441d566f1da0caa0e262be49b666159e17).

Yeah, that's a good start...

Signature · 3 lines
 i.

ps. I'll be out of reach of email access for a week.