diff options
author | Ingo Molnar <mingo@elte.hu> | 2012-03-05 03:20:08 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2012-03-05 03:20:08 -0500 |
commit | 737f24bda723fdf89ecaacb99fa2bf5683c32799 (patch) | |
tree | 35495fff3e9956679cb5468e74e6814c8e44ee66 /net/ipv4/tcp.c | |
parent | 8eedce996556d7d06522cd3a0e6069141c8dffe0 (diff) | |
parent | b7c924274c456499264d1cfa3d44063bb11eb5db (diff) |
Merge branch 'perf/urgent' into perf/core
Conflicts:
tools/perf/builtin-record.c
tools/perf/builtin-top.c
tools/perf/perf.h
tools/perf/util/top.h
Merge reason: resolve these cherry-picking conflicts.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r-- | net/ipv4/tcp.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 06373b4a449a..22ef5f9fd2ff 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -1876,6 +1876,20 @@ void tcp_shutdown(struct sock *sk, int how) | |||
1876 | } | 1876 | } |
1877 | EXPORT_SYMBOL(tcp_shutdown); | 1877 | EXPORT_SYMBOL(tcp_shutdown); |
1878 | 1878 | ||
1879 | bool tcp_check_oom(struct sock *sk, int shift) | ||
1880 | { | ||
1881 | bool too_many_orphans, out_of_socket_memory; | ||
1882 | |||
1883 | too_many_orphans = tcp_too_many_orphans(sk, shift); | ||
1884 | out_of_socket_memory = tcp_out_of_memory(sk); | ||
1885 | |||
1886 | if (too_many_orphans && net_ratelimit()) | ||
1887 | pr_info("TCP: too many orphaned sockets\n"); | ||
1888 | if (out_of_socket_memory && net_ratelimit()) | ||
1889 | pr_info("TCP: out of memory -- consider tuning tcp_mem\n"); | ||
1890 | return too_many_orphans || out_of_socket_memory; | ||
1891 | } | ||
1892 | |||
1879 | void tcp_close(struct sock *sk, long timeout) | 1893 | void tcp_close(struct sock *sk, long timeout) |
1880 | { | 1894 | { |
1881 | struct sk_buff *skb; | 1895 | struct sk_buff *skb; |
@@ -2015,10 +2029,7 @@ adjudge_to_death: | |||
2015 | } | 2029 | } |
2016 | if (sk->sk_state != TCP_CLOSE) { | 2030 | if (sk->sk_state != TCP_CLOSE) { |
2017 | sk_mem_reclaim(sk); | 2031 | sk_mem_reclaim(sk); |
2018 | if (tcp_too_many_orphans(sk, 0)) { | 2032 | if (tcp_check_oom(sk, 0)) { |
2019 | if (net_ratelimit()) | ||
2020 | printk(KERN_INFO "TCP: too many of orphaned " | ||
2021 | "sockets\n"); | ||
2022 | tcp_set_state(sk, TCP_CLOSE); | 2033 | tcp_set_state(sk, TCP_CLOSE); |
2023 | tcp_send_active_reset(sk, GFP_ATOMIC); | 2034 | tcp_send_active_reset(sk, GFP_ATOMIC); |
2024 | NET_INC_STATS_BH(sock_net(sk), | 2035 | NET_INC_STATS_BH(sock_net(sk), |
@@ -3218,7 +3229,6 @@ __setup("thash_entries=", set_thash_entries); | |||
3218 | 3229 | ||
3219 | void tcp_init_mem(struct net *net) | 3230 | void tcp_init_mem(struct net *net) |
3220 | { | 3231 | { |
3221 | /* Set per-socket limits to no more than 1/128 the pressure threshold */ | ||
3222 | unsigned long limit = nr_free_buffer_pages() / 8; | 3232 | unsigned long limit = nr_free_buffer_pages() / 8; |
3223 | limit = max(limit, 128UL); | 3233 | limit = max(limit, 128UL); |
3224 | net->ipv4.sysctl_tcp_mem[0] = limit / 4 * 3; | 3234 | net->ipv4.sysctl_tcp_mem[0] = limit / 4 * 3; |
@@ -3230,7 +3240,8 @@ void __init tcp_init(void) | |||
3230 | { | 3240 | { |
3231 | struct sk_buff *skb = NULL; | 3241 | struct sk_buff *skb = NULL; |
3232 | unsigned long limit; | 3242 | unsigned long limit; |
3233 | int i, max_share, cnt; | 3243 | int max_share, cnt; |
3244 | unsigned int i; | ||
3234 | unsigned long jiffy = jiffies; | 3245 | unsigned long jiffy = jiffies; |
3235 | 3246 | ||
3236 | BUILD_BUG_ON(sizeof(struct tcp_skb_cb) > sizeof(skb->cb)); | 3247 | BUILD_BUG_ON(sizeof(struct tcp_skb_cb) > sizeof(skb->cb)); |
@@ -3273,7 +3284,7 @@ void __init tcp_init(void) | |||
3273 | &tcp_hashinfo.bhash_size, | 3284 | &tcp_hashinfo.bhash_size, |
3274 | NULL, | 3285 | NULL, |
3275 | 64 * 1024); | 3286 | 64 * 1024); |
3276 | tcp_hashinfo.bhash_size = 1 << tcp_hashinfo.bhash_size; | 3287 | tcp_hashinfo.bhash_size = 1U << tcp_hashinfo.bhash_size; |
3277 | for (i = 0; i < tcp_hashinfo.bhash_size; i++) { | 3288 | for (i = 0; i < tcp_hashinfo.bhash_size; i++) { |
3278 | spin_lock_init(&tcp_hashinfo.bhash[i].lock); | 3289 | spin_lock_init(&tcp_hashinfo.bhash[i].lock); |
3279 | INIT_HLIST_HEAD(&tcp_hashinfo.bhash[i].chain); | 3290 | INIT_HLIST_HEAD(&tcp_hashinfo.bhash[i].chain); |
@@ -3287,7 +3298,8 @@ void __init tcp_init(void) | |||
3287 | sysctl_max_syn_backlog = max(128, cnt / 256); | 3298 | sysctl_max_syn_backlog = max(128, cnt / 256); |
3288 | 3299 | ||
3289 | tcp_init_mem(&init_net); | 3300 | tcp_init_mem(&init_net); |
3290 | limit = nr_free_buffer_pages() / 8; | 3301 | /* Set per-socket limits to no more than 1/128 the pressure threshold */ |
3302 | limit = nr_free_buffer_pages() << (PAGE_SHIFT - 10); | ||
3291 | limit = max(limit, 128UL); | 3303 | limit = max(limit, 128UL); |
3292 | max_share = min(4UL*1024*1024, limit); | 3304 | max_share = min(4UL*1024*1024, limit); |
3293 | 3305 | ||