diff options
| author | Grant Likely <grant.likely@secretlab.ca> | 2012-02-28 13:48:58 -0600 | 
|---|---|---|
| committer | Grant Likely <grant.likely@secretlab.ca> | 2012-02-28 13:48:58 -0600 | 
| commit | b3950d50cfc343b3e7dc5c69c96a61b182fd1e37 (patch) | |
| tree | d54affae2b1e25464493b48aa88cd8d6b4770812 /net/ipv4/tcp.c | |
| parent | daefd89efc279b142bbb054577c2d706da211723 (diff) | |
| parent | 280ad7fda5f95211857fda38960f2b6fdf6edd3e (diff) | |
| download | olio-linux-3.10-b3950d50cfc343b3e7dc5c69c96a61b182fd1e37.tar.xz olio-linux-3.10-b3950d50cfc343b3e7dc5c69c96a61b182fd1e37.zip  | |
Merge branch 'irqdomain/next' into gpio/next
Diffstat (limited to 'net/ipv4/tcp.c')
| -rw-r--r-- | net/ipv4/tcp.c | 23 | 
1 files changed, 17 insertions, 6 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 06373b4a449..37755ccc0e9 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1876,6 +1876,20 @@ void tcp_shutdown(struct sock *sk, int how)  }  EXPORT_SYMBOL(tcp_shutdown); +bool tcp_check_oom(struct sock *sk, int shift) +{ +	bool too_many_orphans, out_of_socket_memory; + +	too_many_orphans = tcp_too_many_orphans(sk, shift); +	out_of_socket_memory = tcp_out_of_memory(sk); + +	if (too_many_orphans && net_ratelimit()) +		pr_info("TCP: too many orphaned sockets\n"); +	if (out_of_socket_memory && net_ratelimit()) +		pr_info("TCP: out of memory -- consider tuning tcp_mem\n"); +	return too_many_orphans || out_of_socket_memory; +} +  void tcp_close(struct sock *sk, long timeout)  {  	struct sk_buff *skb; @@ -2015,10 +2029,7 @@ adjudge_to_death:  	}  	if (sk->sk_state != TCP_CLOSE) {  		sk_mem_reclaim(sk); -		if (tcp_too_many_orphans(sk, 0)) { -			if (net_ratelimit()) -				printk(KERN_INFO "TCP: too many of orphaned " -				       "sockets\n"); +		if (tcp_check_oom(sk, 0)) {  			tcp_set_state(sk, TCP_CLOSE);  			tcp_send_active_reset(sk, GFP_ATOMIC);  			NET_INC_STATS_BH(sock_net(sk), @@ -3218,7 +3229,6 @@ __setup("thash_entries=", set_thash_entries);  void tcp_init_mem(struct net *net)  { -	/* Set per-socket limits to no more than 1/128 the pressure threshold */  	unsigned long limit = nr_free_buffer_pages() / 8;  	limit = max(limit, 128UL);  	net->ipv4.sysctl_tcp_mem[0] = limit / 4 * 3; @@ -3287,7 +3297,8 @@ void __init tcp_init(void)  	sysctl_max_syn_backlog = max(128, cnt / 256);  	tcp_init_mem(&init_net); -	limit = nr_free_buffer_pages() / 8; +	/* Set per-socket limits to no more than 1/128 the pressure threshold */ +	limit = nr_free_buffer_pages() << (PAGE_SHIFT - 10);  	limit = max(limit, 128UL);  	max_share = min(4UL*1024*1024, limit);  |