tcp: replace hard coded GFP_KERNEL with sk_allocation
This fixed a lockdep warning which appeared when doing stress memory tests over NFS: inconsistent {RECLAIM_FS-ON-W} -> {IN-RECLAIM_FS-W} usage. page reclaim => nfs_writepage => tcp_sendmsg => lock sk_lock mount_root => nfs_root_data => tcp_close => lock sk_lock => tcp_send_fin => alloc_skb_fclone => page reclaim David raised a concern that if the allocation fails in tcp_send_fin(), and it's GFP_ATOMIC, we are going to yield() (which sleeps) and loop endlessly waiting for the allocation to succeed. But fact is, the original GFP_KERNEL also sleeps. GFP_ATOMIC+yield() looks weird, but it is no worse the implicit sleep inside GFP_KERNEL. Both could loop endlessly under memory pressure. CC: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> CC: David S. Miller <davem@davemloft.net> CC: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
05c6a8d7a7
commit
aa1330766c
@@ -2135,7 +2135,8 @@ void tcp_send_fin(struct sock *sk)
|
||||
} else {
|
||||
/* Socket is locked, keep trying until memory is available. */
|
||||
for (;;) {
|
||||
skb = alloc_skb_fclone(MAX_TCP_HEADER, GFP_KERNEL);
|
||||
skb = alloc_skb_fclone(MAX_TCP_HEADER,
|
||||
sk->sk_allocation);
|
||||
if (skb)
|
||||
break;
|
||||
yield();
|
||||
@@ -2388,7 +2389,7 @@ int tcp_connect(struct sock *sk)
|
||||
sk->sk_wmem_queued += buff->truesize;
|
||||
sk_mem_charge(sk, buff->truesize);
|
||||
tp->packets_out += tcp_skb_pcount(buff);
|
||||
tcp_transmit_skb(sk, buff, 1, GFP_KERNEL);
|
||||
tcp_transmit_skb(sk, buff, 1, sk->sk_allocation);
|
||||
|
||||
/* We change tp->snd_nxt after the tcp_transmit_skb() call
|
||||
* in order to make this packet get counted in tcpOutSegs.
|
||||
|
Reference in New Issue
Block a user