Crash when receiving FIN-ACK in TCP_FIN_WAIT1 state
Subsystems (3)
We are seeing a crash in the TCP ACK codepath often in our regression racks with an ARM64 device with 4.19 based kernel.
It appears that the tp->highest_ack is invalid when being accessed when a FIN-ACK is received. In all the instances of the crash, the tcp socket is in TCP_FIN_WAIT1 state.
[include/net/tcp.h]
static inline u32 tcp_highest_sack_seq(struct tcp_sock *tp)
{
if (!tp->sacked_out)
return tp->snd_una;
if (tp->highest_sack == NULL)
return tp->snd_nxt;
return TCP_SKB_CB(tp->highest_sack)->seq;
}[net/ipv4/tcp_input.c]
static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) {
...
prior_fack = tcp_is_sack(tp) ? tcp_highest_sack_seq(tp) : tp->snd_una;
Crash call stack below-
16496.596106: <6> Unable to handle kernel paging request at virtual
address fffffff2cd81a368
16496.730771: <2> pc : tcp_ack+0x174/0x11e8 16496.734536: <2> lr : tcp_rcv_state_process+0x318/0x1300 16497.183109: <2> Call trace: 16497.183114: <2> tcp_ack+0x174/0x11e8 16497.183115: <2> tcp_rcv_state_process+0x318/0x1300 16497.183117: <2> tcp_v4_do_rcv+0x1a8/0x1f0 16497.183118: <2> tcp_v4_rcv+0xe90/0xec8 16497.183120: <2> ip_protocol_deliver_rcu+0x150/0x298 16497.183121: <2> ip_local_deliver+0x21c/0x2a8 16497.183122: <2> ip_rcv+0x1c4/0x210 16497.183124: <2> __netif_receive_skb_core+0xab0/0xd90 16497.183125: <2> netif_receive_skb_internal+0x12c/0x368 16497.183126: <2> napi_gro_receive+0x1e0/0x290
Is it expected for the tp->highest_ack to be
accessed in this state?
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Neal Cardwell
maintainertcp_write_queue_purgeOn Sun, Oct 20, 2019 at 4:25 PM Subash Abhinov
Quoted 8 lines · Kasiviswanathan
We are seeing a crash in the TCP ACK codepath often in our regression racks with an ARM64 device with 4.19 based kernel.
It appears that the
tp->highest_ackis invalid when being accessed when a
FIN-ACK is received. In all the instances of the crash, the tcp socket is inTCP_FIN_WAIT1state.
Hmm. Random related thought while searching for a possible cause: I wonder if tcp_write_queue_purge() should clear tp->highest_sack (and possibly tp->sacked_out)? The tcp_write_queue_purge() code is careful to call tcp_clear_all_retrans_hints(tcp_sk(sk)) and I would imagine that similar considerations would imply that we should clear at least tp->highest_sack?
neal
Quoted 8 lines
Hmm. Random related thought while searching for a possible cause: I wonder if
tcp_write_queue_purge()should cleartp->highest_sack(and possiblytp->sacked_out)? Thetcp_write_queue_purge()code is careful to call tcp_clear_all_retrans_hints(tcp_sk(sk)) and I would imagine that similar considerations would imply that we should clear at leasttp->highest_sack?neal
Hi Neal
If the socket is in FIN-WAIT1, does that mean that all the segments corresponding to SACK blocks are sent and ACKed already?
tp->sacked_out is non zero in all these crashes (is the SACK information possibly invalid or stale here?).
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Neal Cardwell
maintainerQuoted 8 lines · Subash Abhinov Kasiviswanathan
Quoted 8 lines
Hmm. Random related thought while searching for a possible cause: I wonder if
tcp_write_queue_purge()should cleartp->highest_sack(and possiblytp->sacked_out)? Thetcp_write_queue_purge()code is careful to call tcp_clear_all_retrans_hints(tcp_sk(sk)) and I would imagine that similar considerations would imply that we should clear at leasttp->highest_sack?
Quoted 6 lines
Quoted 1 line
neal
Hi Neal
If the socket is in FIN-WAIT1, does that mean that all the segments corresponding to SACK blocks are sent and ACKed already?
FIN-WAIT1 just means the local application has called close() or shutdown() to shut down the sending direction of the socket, and the local TCP stack has sent a FIN, and is waiting to receive a FIN and an ACK from the other side (in either order, or simultaneously). The ASCII art state transition diagram on page 22 of RFC 793 (e.g.
https://tools.ietf.org/html/rfc793#section-3.2 ) is one source for this, though the W. Richard Stevens books have a much more readable diagram.
There may still be unacked and SACKed data in the retransmit queue at this point.
Quoted 1 line
tp->sacked_outis non zero in all these crashes
Thanks, that is a useful data point. Do you know what particular value
tp->sacked_out has? Would you be able to capture/log the value oftp->packets_out, tp->lost_out, and tp->retrans_out as well?
Quoted 1 line
(is the SACK information possibly invalid or stale here?).
Yes, one guess would be that somehow the skbs in the retransmit queue have been freed, but tp->sacked_out is still non-zero and tp->highest_sack is still a dangling pointer into one of those freed skbs. The tcp_write_queue_purge() function is one function that fees the skbs in the retransmit queue and leaves tp->sacked_out as non-zero and tp->highest_sack as a dangling pointer to a freed skb, AFAICT, so that's why I'm wondering about that function. I can't think of a specific sequence of events that would involve tcp_write_queue_purge() and then a socket that's still in FIN-WAIT1. Maybe I'm not being creative enough, or maybe that guess is on the wrong track. Would you be able to set a new bit in the tcp_sock in tcp_write_queue_purge() and log it in your instrumentation point, to see if tcp_write_queue_purge() was called for these connections that cause this crash?
thanks,
neal
Quoted 9 lines
FIN-WAIT1 just means the local application has called
close()orshutdown()to shut down the sending direction of the socket, and the local TCP stack has sent a FIN, and is waiting to receive a FIN and an ACK from the other side (in either order, or simultaneously). The ASCII art state transition diagram on page 22 of RFC 793 (e.g.
https://tools.ietf.org/html/rfc793#section-3.2 ) is one source for this, though the W. Richard Stevens books have a much more readable diagram.
Quoted 3 lines
There may still be unacked and SACKed data in the retransmit queue at this point.
Thanks for the clarification.
Quoted 4 lines
Thanks, that is a useful data point. Do you know what particular value
tp->sacked_outhas? Would you be able to capture/log the value oftp->packets_out,tp->lost_out, andtp->retrans_outas well?
tp->sacket_out varies per crash instance - 55, 180 etc. However the other values are always the same - tp->packets_out is 0, tp->lost_out is 1 and tp->retrans_out is 1.
Quoted 6 lines
Yes, one guess would be that somehow the skbs in the retransmit queue have been freed, but
tp->sacked_outis still non-zero andtp->highest_sackis still a dangling pointer into one of those freed skbs. Thetcp_write_queue_purge()function is one function that fees the skbs in the retransmit queue and leavestp->sacked_outas non-zero andtp->highest_sackas a dangling pointer to a freed skb, AFAICT, so
Quoted 8 lines
that's why I'm wondering about that function. I can't think of a specific sequence of events that would involve
tcp_write_queue_purge()and then a socket that's still in FIN-WAIT1. Maybe I'm not being creative enough, or maybe that guess is on the wrong track. Would you be able to set a new bit in thetcp_sockintcp_write_queue_purge()and log it in your instrumentation point, to see iftcp_write_queue_purge()was called for these connections that cause this crash?
Sure, I can try this out.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Neal Cardwell
maintainerQuoted 16 lines · Subash Abhinov Kasiviswanathan
Quoted 10 lines
FIN-WAIT1 just means the local application has called
close()orshutdown()to shut down the sending direction of the socket, and the local TCP stack has sent a FIN, and is waiting to receive a FIN and an ACK from the other side (in either order, or simultaneously). The ASCII art state transition diagram on page 22 of RFC 793 (e.g.
https://tools.ietf.org/html/rfc793#section-3.2 ) is one source for this, though the W. Richard Stevens books have a much more readable diagram.Quoted 3 lines
There may still be unacked and SACKed data in the retransmit queue at this point.
Thanks for the clarification.
Quoted 8 lines
Quoted 4 lines
Thanks, that is a useful data point. Do you know what particular value
tp->sacked_outhas? Would you be able to capture/log the value oftp->packets_out,tp->lost_out, andtp->retrans_outas well?
tp->sacket_outvaries per crash instance - 55, 180 etc. However the other values are always the same -tp->packets_outis 0,tp->lost_outis 1 andtp->retrans_outis 1.
Interesting! As tcp_input.c summarizes, "packets_out is SND.NXT-SND.UNA counted in packets". In the normal operation of a socket, tp->packets_out should not be 0 if any of those other fields are non-zero.
The tcp_write_queue_purge() function sets packets_out to 0:
https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/tree/net/ipv4/tcp.c?h=v4.19#n2526
So the execution of tcp_write_queue_purge() before this point is one way for the socket to end up in this weird state.
Quoted 15 lines
Quoted 6 lines
Yes, one guess would be that somehow the skbs in the retransmit queue have been freed, but
tp->sacked_outis still non-zero andtp->highest_sackis still a dangling pointer into one of those freed skbs. Thetcp_write_queue_purge()function is one function that fees the skbs in the retransmit queue and leavestp->sacked_outas non-zero andtp->highest_sackas a dangling pointer to a freed skb, AFAICT, soQuoted 8 lines
that's why I'm wondering about that function. I can't think of a specific sequence of events that would involve
tcp_write_queue_purge()and then a socket that's still in FIN-WAIT1. Maybe I'm not being creative enough, or maybe that guess is on the wrong track. Would you be able to set a new bit in thetcp_sockintcp_write_queue_purge()and log it in your instrumentation point, to see iftcp_write_queue_purge()was called for these connections that cause this crash?
Quoted 1 line
Sure, I can try this out.
Great! Thanks!
neal
Quoted 3 lines · Subash Abhinov Kasiviswanathan
We are seeing a crash in the TCP ACK codepath often in our regression racks with an ARM64 device with 4.19 based kernel.
Please give us a pointer to the exact git tree and sha1.
I do not analyze TCP stack problems without an exact starting point, or at least a crystal ball, which I do not have.
Quoted 4 lines
Please give us a pointer to the exact git tree and sha1.
I do not analyze TCP stack problems without an exact starting point, or at least a crystal ball, which I do not have.
Hi Eric
We are at this commit - Merge 4.19.75 into android-4.19-q.
https://android.googlesource.com/kernel/common/+/cfe571e421ab873403a8f75413e04ecf5bf7e393
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 8 lines · Subash Abhinov Kasiviswanathan
Quoted 5 lines
Please give us a pointer to the exact git tree and sha1.
I do not analyze TCP stack problems without an exact starting point, or at least a crystal ball, which I do not have.
Hi Eric
Quoted 7 lines
We are at this commit - Merge 4.19.75 into android-4.19-q.
https://android.googlesource.com/kernel/common/+/cfe571e421ab873403a8f75413e04ecf5bf7e393
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
We were investigating a problem in this area a few months back (it turned out to be something else), but were wondering if retrans_out, lost_out, and sacked_out should be cleared in tcp_rtx_queue_purge()? I meant to get back to it, but it got buried and this just thread jogged my memory...
Signature · 1 line
Josh
Quoted 5 lines
Interesting! As
tcp_input.csummarizes, "packets_outis SND.NXT-SND.UNA counted in packets". In the normal operation of a socket,tp->packets_outshould not be 0 if any of those other fields are non-zero.
Quoted 8 lines
The
tcp_write_queue_purge()function setspackets_outto 0:https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/tree/net/ipv4/tcp.c?h=v4.19#n2526
So the execution of
tcp_write_queue_purge()before this point is one way for the socket to end up in this weird state.
In one of the instances, the values are tp->snd_nxt = 1016118098, tp->snd_una = 1016047820
tp->mss_cache = 1378
I assume the number of outstanding segments should be (tp->snd_nxt - tp->snd_una)/tp->mss_cache = 51
tp->packets_out = 0 and tp->sacked_out = 158 in this case.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Yes, one guess would be that somehow the skbs in the retransmit queue have been freed, but
tp->sacked_outis still non-zero andtp->highest_sackis still a dangling pointer into one of those freed skbs. Thetcp_write_queue_purge()function is one function that fees the skbs in the retransmit queue and leavestp->sacked_outas non-zero andtp->highest_sackas a dangling pointer to a freed skb, AFAICT, so
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
that's why I'm wondering about that function. I can't think of a specific sequence of events that would involve
tcp_write_queue_purge()and then a socket that's still in FIN-WAIT1. Maybe I'm not being creative enough, or maybe that guess is on the wrong track. Would you be able to set a new bit in thetcp_sockintcp_write_queue_purge()and log it in your instrumentation point, to see iftcp_write_queue_purge()was called for these connections that cause this crash?
I've queued up a build which logs calls to tcp_write_queue_purge and clears tp->highest_sack and tp->sacked_out. I will let you know how it fares by end of week.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Neal Cardwell
maintainerQuoted 15 lines · Subash Abhinov Kasiviswanathan
Quoted 6 lines
Interesting! As
tcp_input.csummarizes, "packets_outis SND.NXT-SND.UNA counted in packets". In the normal operation of a socket,tp->packets_outshould not be 0 if any of those other fields are non-zero.Quoted 8 lines
The
tcp_write_queue_purge()function setspackets_outto 0:https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/tree/net/ipv4/tcp.c?h=v4.19#n2526
So the execution of
tcp_write_queue_purge()before this point is one way for the socket to end up in this weird state.
Quoted 7 lines
In one of the instances, the values are
tp->snd_nxt= 1016118098,tp->snd_una= 1016047820
tp->mss_cache= 1378I assume the number of outstanding segments should be (
tp->snd_nxt- tp->snd_una)/tp->mss_cache = 51
That would be a good expectation if all the packets were full-sized.
Quoted 1 line
tp->packets_out= 0 andtp->sacked_out= 158 in this case.
OK, thanks. It could be that sacked_out is reasonable and some of the packets were not full-sized. But, as discussed above, typically the packets_out should not be 0 if sacked_out is non-zero (with at least the exception of the tcp_write_queue_purge() case).
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Yes, one guess would be that somehow the skbs in the retransmit queue have been freed, but
tp->sacked_outis still non-zero andtp->highest_sackis still a dangling pointer into one of those freed skbs. Thetcp_write_queue_purge()function is one function that fees the skbs in the retransmit queue and leavestp->sacked_outas non-zero andtp->highest_sackas a dangling pointer to a freed skb, AFAICT, soQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
that's why I'm wondering about that function. I can't think of a specific sequence of events that would involve
tcp_write_queue_purge()and then a socket that's still in FIN-WAIT1. Maybe I'm not being creative enough, or maybe that guess is on the wrong track. Would you be able to set a new bit in thetcp_sockintcp_write_queue_purge()and log it in your instrumentation point, to see iftcp_write_queue_purge()was called for these connections that cause this crash?
Quoted 3 lines
I've queued up a build which logs calls to
tcp_write_queue_purgeand clearstp->highest_sackandtp->sacked_out. I will let you know how it fares by end of week.
OK, thanks. That should be a useful data point.
cheers,
neal
Quoted 5 lines
Quoted 3 lines
I've queued up a build which logs calls to
tcp_write_queue_purgeand clearstp->highest_sackandtp->sacked_out. I will let you know how it fares by end of week.OK, thanks. That should be a useful data point.
I haven't seen the crash in the testing so far.
Looks like clearing these values seems to help.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Neal Cardwell
maintainerQuoted 9 lines · Subash Abhinov Kasiviswanathan
Quoted 6 lines
Quoted 4 lines
I've queued up a build which logs calls to
tcp_write_queue_purgeand clearstp->highest_sackandtp->sacked_out. I will let you know how it fares by end of week.OK, thanks. That should be a useful data point.
I haven't seen the crash in the testing so far.
Looks like clearing these values seems to help.
Thanks. Do you mind sharing what your patch looked like, so we can understand precisely what was changed?
Also, are you able to share what the workload looked like that tickled this issue? (web client? file server?...)
thanks,
neal
Quoted 5 lines
Thanks. Do you mind sharing what your patch looked like, so we can understand precisely what was changed?
Also, are you able to share what the workload looked like that tickled this issue? (web client? file server?...)
Sure. This was seen only on our regression racks and the workload there is a combination of FTP, browsing and other apps.
include/linux/tcp.h +0 -0
@@ -232,7 +232,8 @@ struct tcp_sock { fastopen_connect:1, /* FASTOPEN_CONNECT sockopt */ fastopen_no_cookie:1, /* Allow send/recv SYN+data
without a cookie */
is_sack_reneg:1, /* in recovery from loss with SACK
reneg? */
- unused:2;
+ unused:1,
+ wqp_called:1;
u8 nonagle : 4,/* Disable Nagle algorithm? */
thin_lto : 1,/* Use linear timeouts for thin streams
*/
recvmsg_inq : 1,/* Indicate # of bytes in queue upon
recvmsg */
net/ipv4/tcp.c +3 -0
@@ -2534,6 +2534,9 @@ void tcp_write_queue_purge(struct sock *sk)INIT_LIST_HEAD (&tcp_sk (sk)->tsorted_sent_queue);sk_mem_reclaim (sk);tcp_clear_all_retrans_hints (tcp_sk (sk)); +tcp_sk (sk)->highest_sack =NULL ; +tcp_sk (sk)->sacked_out =0 ; +tcp_sk (sk)->wqp_called =1 ;tcp_sk (sk)->packets_out =0 ;inet_csk (sk)->icsk_backoff =0 ; }
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 33 lines · Subash Abhinov Kasiviswanathan
Quoted 5 lines
Thanks. Do you mind sharing what your patch looked like, so we can understand precisely what was changed?
Also, are you able to share what the workload looked like that tickled this issue? (web client? file server?...)
Sure. This was seen only on our regression racks and the workload there is a combination of FTP, browsing and other apps.
include/linux/tcp.h +0
-0@@ -232,7 +232,8 @@ struct tcp_sock { fastopen_connect:1, /* FASTOPEN_CONNECT sockopt */ fastopen_no_cookie:1, /* Allow send/recv SYN+datawithout a cookie */
is_sack_reneg:1, /* in recovery from loss with SACK
reneg? */
- unused:2;
+ unused:1,
+ wqp_called:1;
u8 nonagle : 4,/* Disable Nagle algorithm? */ thin_lto : 1,/* Use linear timeouts for thin streams */recvmsg_inq: 1,/* Indicate # of bytes in queue upon
recvmsg */net/ipv4/tcp.c +0
-0
net/ipv4/tcp.c void tcp_write_queue_purge(struct sock *sk) · line 2542
Quoted 9 lines
net/ipv4/tcp.c +3
-0@@ -2534,6 +2534,9 @@ void tcp_write_queue_purge(struct sock *sk) INIT_LIST_HEAD(&tcp_sk(sk)->tsorted_sent_queue); sk_mem_reclaim(sk); tcp_clear_all_retrans_hints(tcp_sk(sk)); + tcp_sk(sk)->highest_sack = NULL; + tcp_sk(sk)->sacked_out = 0; + tcp_sk(sk)->wqp_called = 1; tcp_sk(sk)->packets_out = 0; inet_csk(sk)->icsk_backoff = 0; }
Neal
Since tcp_write_queue_purge() calls tcp_rtx_queue_purge() and we're deleting everything in the retrans queue there, doesn't it make sense to zero out all of those associated counters? Obviously clearing sacked_out is helping here, but is there a reason to keep track of lost_out, retrans_out, etc if retrans queue is now empty? Maybe calling tcp_clear_retrans() from tcp_rtx_queue_purge() ?
Josh
Quoted 28 lines · Subash Abhinov Kasiviswanathan
Quoted 5 lines
Thanks. Do you mind sharing what your patch looked like, so we can understand precisely what was changed?
Also, are you able to share what the workload looked like that tickled this issue? (web client? file server?...)
Sure. This was seen only on our regression racks and the workload there is a combination of FTP, browsing and other apps.
include/linux/tcp.h +0
-0@@ -232,7 +232,8 @@ struct tcp_sock {fastopen_connect:1, /*
FASTOPEN_CONNECTsockopt */ fastopen_no_cookie:1, /* Allow send/recv SYN+data without a cookie */ is_sack_reneg:1, /* in recovery from loss with SACK reneg? */ - unused:2;
+ unused:1,
+ wqp_called:1;
u8 nonagle : 4,/* Disable Nagle algorithm? */ thin_lto : 1,/* Use linear timeouts for thin streams */recvmsg_inq: 1,/* Indicate # of bytes in queue upon recvmsg */net/ipv4/tcp.c +0
-0
net/ipv4/tcp.c void tcp_write_queue_purge(struct sock *sk) · line 2539
Quoted 6 lines
net/ipv4/tcp.c +3
-0@@ -2534,6 +2534,9 @@ void tcp_write_queue_purge(struct sock *sk) INIT_LIST_HEAD(&tcp_sk(sk)->tsorted_sent_queue); sk_mem_reclaim(sk); tcp_clear_all_retrans_hints(tcp_sk(sk)); + tcp_sk(sk)->highest_sack = NULL; + tcp_sk(sk)->sacked_out = 0; + tcp_sk(sk)->wqp_called = 1;
What is this wqp_called exactly ?
Quoted 1 line
What is this
wqp_calledexactly ?
This was just a debug to ensure that tcp_write_queue_purge() was called. In case the same crash was seen with the patch, this bit would atleast tell whether this function was invoked or not.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 43 lines · Josh Hunt
Quoted 30 lines · Subash Abhinov Kasiviswanathan
Quoted 5 lines
Thanks. Do you mind sharing what your patch looked like, so we can understand precisely what was changed?
Also, are you able to share what the workload looked like that tickled this issue? (web client? file server?...)
Sure. This was seen only on our regression racks and the workload there is a combination of FTP, browsing and other apps.
include/linux/tcp.h +0
-0@@ -232,7 +232,8 @@ struct tcp_sock {fastopen_connect:1, /*
FASTOPEN_CONNECTsockopt */ fastopen_no_cookie:1, /* Allow send/recv SYN+data without a cookie */ is_sack_reneg:1, /* in recovery from loss with SACK reneg? */ - unused:2;
+ unused:1,
+ wqp_called:1;
u8 nonagle : 4,/* Disable Nagle algorithm? */
thin_lto : 1,/* Use linear timeouts for thin streams */recvmsg_inq: 1,/* Indicate # of bytes in queue upon recvmsg */net/ipv4/tcp.c +0
-0net/ipv4/tcp.c void tcp_write_queue_purge(struct sock *sk) · line 2542
Quoted 9 lines
net/ipv4/tcp.c +3
-0@@ -2534,6 +2534,9 @@ void tcp_write_queue_purge(struct sock *sk) INIT_LIST_HEAD(&tcp_sk(sk)->tsorted_sent_queue); sk_mem_reclaim(sk); tcp_clear_all_retrans_hints(tcp_sk(sk)); + tcp_sk(sk)->highest_sack = NULL; + tcp_sk(sk)->sacked_out = 0; + tcp_sk(sk)->wqp_called = 1; tcp_sk(sk)->packets_out = 0; inet_csk(sk)->icsk_backoff = 0; }Neal
Quoted 1 line
Since
tcp_write_queue_purge()callstcp_rtx_queue_purge()and we're deleting everything in the retrans queue there, doesn't it make sense to zero out all of those associated counters? Obviously clearingsacked_outis helping here, but is there a reason to keep track oflost_out,retrans_out, etc if retrans queue is now empty? Maybe callingtcp_clear_retrans()fromtcp_rtx_queue_purge()?
First, I would like to understand if we hit this problem on current upstream kernels.
Maybe a backport forgot a dependency.
tcp_write_queue_purge() calls tcp_clear_all_retrans_hints(), not tcp_clear_retrans(), this is probably for a reason.
Brute force clearing these fields might hide a serious bug.
Quoted 48 lines · Eric Dumazet
Quoted 43 lines · Josh Hunt
Quoted 30 lines · Subash Abhinov Kasiviswanathan
Quoted 5 lines
Thanks. Do you mind sharing what your patch looked like, so we can understand precisely what was changed?
Also, are you able to share what the workload looked like that tickled this issue? (web client? file server?...)
Sure. This was seen only on our regression racks and the workload there is a combination of FTP, browsing and other apps.
include/linux/tcp.h +0
-0@@ -232,7 +232,8 @@ struct tcp_sock {fastopen_connect:1, /*
FASTOPEN_CONNECTsockopt */ fastopen_no_cookie:1, /* Allow send/recv SYN+data without a cookie */ is_sack_reneg:1, /* in recovery from loss with SACK reneg? */ - unused:2;
+ unused:1,
+ wqp_called:1;
u8 nonagle : 4,/* Disable Nagle algorithm? */
thin_lto : 1,/* Use linear timeouts for thin streams */recvmsg_inq: 1,/* Indicate # of bytes in queue upon recvmsg */net/ipv4/tcp.c +0
-0net/ipv4/tcp.c void tcp_write_queue_purge(struct sock *sk) · line 2542
Quoted 9 lines
net/ipv4/tcp.c +3
-0@@ -2534,6 +2534,9 @@ void tcp_write_queue_purge(struct sock *sk) INIT_LIST_HEAD(&tcp_sk(sk)->tsorted_sent_queue); sk_mem_reclaim(sk); tcp_clear_all_retrans_hints(tcp_sk(sk)); + tcp_sk(sk)->highest_sack = NULL; + tcp_sk(sk)->sacked_out = 0; + tcp_sk(sk)->wqp_called = 1; tcp_sk(sk)->packets_out = 0; inet_csk(sk)->icsk_backoff = 0; }Neal
Quoted 1 line
Since
tcp_write_queue_purge()callstcp_rtx_queue_purge()and we're deleting everything in the retrans queue there, doesn't it make sense to zero out all of those associated counters? Obviously clearingsacked_outis helping here, but is there a reason to keep track oflost_out,retrans_out, etc if retrans queue is now empty? Maybe callingtcp_clear_retrans()fromtcp_rtx_queue_purge()?
Quoted 9 lines
First, I would like to understand if we hit this problem on current upstream kernels.
Maybe a backport forgot a dependency.
tcp_write_queue_purge()callstcp_clear_all_retrans_hints(), nottcp_clear_retrans(), this is probably for a reason.Brute force clearing these fields might hide a serious bug.
I guess we are all too busy to get more understanding on this :/
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Since
tcp_write_queue_purge()callstcp_rtx_queue_purge()and we're deleting everything in the retrans queue there, doesn't it make sense to zero out all of those associated counters? Obviously clearingsacked_outis helping here, but is there a reason to keep track oflost_out,retrans_out, etc if retrans queue is now empty? Maybe callingtcp_clear_retrans()fromtcp_rtx_queue_purge()?First, I would like to understand if we hit this problem on current upstream kernels.
Maybe a backport forgot a dependency.
Quoted 7 lines
Quoted 5 lines
tcp_write_queue_purge()callstcp_clear_all_retrans_hints(), nottcp_clear_retrans(), this is probably for a reason.Brute force clearing these fields might hide a serious bug.
I guess we are all too busy to get more understanding on this :/
Our test devices are on 4.19.x and it is not possible to switch to a newer version. Perhaps Josh has seen this on a newer kernel.
Hi Eric,
This crash looks quite similar to the one I am experiencing [1] and reported already.
[1] https://www.spinics.net/lists/netdev/msg611694.html
Thanks,
Avinash
Quoted 25 lines · On Fri, Nov 29, 2019 at 6:52 PM <[email protected]> wrote:
Quoted 13 lines
Quoted 13 lines
Quoted 7 lines
Since
tcp_write_queue_purge()callstcp_rtx_queue_purge()and we're deleting everything in the retrans queue there, doesn't it make sense to zero out all of those associated counters? Obviously clearingsacked_outis helping here, but is there a reason to keep track oflost_out,retrans_out, etc if retrans queue is now empty? Maybe callingtcp_clear_retrans()fromtcp_rtx_queue_purge()?First, I would like to understand if we hit this problem on current upstream kernels.
Maybe a backport forgot a dependency.
Quoted 8 lines
Quoted 6 lines
tcp_write_queue_purge()callstcp_clear_all_retrans_hints(), nottcp_clear_retrans(),
this is probably for a reason.Brute force clearing these fields might hide a serious bug.
I guess we are all too busy to get more understanding on this :/
Our test devices are on 4.19.x and it is not possible to switch to a newer
version. Perhaps Josh has seen this on a newer kernel.
Quoted 7 lines · Avinash Patil
Hi Eric,
This crash looks quite similar to the one I am experiencing [1] and reported already.
Please start a bisection.
Thanks you.
Quoted 9 lines · On 11/29/19 6:51 PM, [email protected] wrote:
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
Since
tcp_write_queue_purge()callstcp_rtx_queue_purge()and we're deleting everything in the retrans queue there, doesn't it make sense to zero out all of those associated counters? Obviously clearingsacked_outis helping here, but is there a reason to keep track oflost_out,retrans_out, etc if retrans queue is now empty? Maybe callingtcp_clear_retrans()fromtcp_rtx_queue_purge()?First, I would like to understand if we hit this problem on current upstream kernels.
Maybe a backport forgot a dependency.
tcp_write_queue_purge()callstcp_clear_all_retrans_hints(), nottcp_clear_retrans(), this is probably for a reason.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Brute force clearing these fields might hide a serious bug.
I guess we are all too busy to get more understanding on this :/
Our test devices are on 4.19.x and it is not possible to switch to a newer version. Perhaps Josh has seen this on a newer kernel.
Sorry I've been out of town without email access. To be clear I've never seen this crash. I've only noticed that we do not clear some counters when we clear out the retransmit queue and this caught my eye when debugging another unrelated issue. I will try and get some cycles this week to instrument a kernel and reproduce the behavior I was seeing. My concern IIRC was more around tcp_left_out() being > packets_out and retrans_out causing tcp_packets_in_flight() to wrap. Anyway I'll report my findings on this thread if they seem relevant otherwise maybe I'll start another discussion thread. I don't want to pollute this one with my ramblings...
Josh