diff options
Diffstat (limited to 'net/core/sock.c')
-rw-r--r-- | net/core/sock.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index a4e840e5a05..7a081b647bf 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -1071,7 +1071,7 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority) | |||
1071 | newsk->sk_sleep = NULL; | 1071 | newsk->sk_sleep = NULL; |
1072 | 1072 | ||
1073 | if (newsk->sk_prot->sockets_allocated) | 1073 | if (newsk->sk_prot->sockets_allocated) |
1074 | atomic_inc(newsk->sk_prot->sockets_allocated); | 1074 | percpu_counter_inc(newsk->sk_prot->sockets_allocated); |
1075 | } | 1075 | } |
1076 | out: | 1076 | out: |
1077 | return newsk; | 1077 | return newsk; |
@@ -1463,8 +1463,12 @@ int __sk_mem_schedule(struct sock *sk, int size, int kind) | |||
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | if (prot->memory_pressure) { | 1465 | if (prot->memory_pressure) { |
1466 | if (!*prot->memory_pressure || | 1466 | int alloc; |
1467 | prot->sysctl_mem[2] > atomic_read(prot->sockets_allocated) * | 1467 | |
1468 | if (!*prot->memory_pressure) | ||
1469 | return 1; | ||
1470 | alloc = percpu_counter_read_positive(prot->sockets_allocated); | ||
1471 | if (prot->sysctl_mem[2] > alloc * | ||
1468 | sk_mem_pages(sk->sk_wmem_queued + | 1472 | sk_mem_pages(sk->sk_wmem_queued + |
1469 | atomic_read(&sk->sk_rmem_alloc) + | 1473 | atomic_read(&sk->sk_rmem_alloc) + |
1470 | sk->sk_forward_alloc)) | 1474 | sk->sk_forward_alloc)) |