diff options
author | Eric Dumazet <edumazet@google.com> | 2015-05-15 15:39:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-05-17 22:45:48 -0400 |
commit | 1a24e04e4b50939daa3041682b38b82c896ca438 (patch) | |
tree | dc47be63f82d9c6be6d193607688d10b3f78a366 /net/core/sock.c | |
parent | 4633c9e07b3b7d7fc262a5f59ff635c1f702af6f (diff) |
net: fix sk_mem_reclaim_partial()
sk_mem_reclaim_partial() goal is to ensure each socket has
one SK_MEM_QUANTUM forward allocation. This is needed both for
performance and better handling of memory pressure situations in
follow up patches.
SK_MEM_QUANTUM is currently a page, but might be reduced to 4096 bytes
as some arches have 64KB pages.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/sock.c')
-rw-r--r-- | net/core/sock.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index c18738a795b0..29124fcdc42a 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -2069,12 +2069,13 @@ EXPORT_SYMBOL(__sk_mem_schedule); | |||
2069 | /** | 2069 | /** |
2070 | * __sk_reclaim - reclaim memory_allocated | 2070 | * __sk_reclaim - reclaim memory_allocated |
2071 | * @sk: socket | 2071 | * @sk: socket |
2072 | * @amount: number of bytes (rounded down to a SK_MEM_QUANTUM multiple) | ||
2072 | */ | 2073 | */ |
2073 | void __sk_mem_reclaim(struct sock *sk) | 2074 | void __sk_mem_reclaim(struct sock *sk, int amount) |
2074 | { | 2075 | { |
2075 | sk_memory_allocated_sub(sk, | 2076 | amount >>= SK_MEM_QUANTUM_SHIFT; |
2076 | sk->sk_forward_alloc >> SK_MEM_QUANTUM_SHIFT); | 2077 | sk_memory_allocated_sub(sk, amount); |
2077 | sk->sk_forward_alloc &= SK_MEM_QUANTUM - 1; | 2078 | sk->sk_forward_alloc -= amount << SK_MEM_QUANTUM_SHIFT; |
2078 | 2079 | ||
2079 | if (sk_under_memory_pressure(sk) && | 2080 | if (sk_under_memory_pressure(sk) && |
2080 | (sk_memory_allocated(sk) < sk_prot_mem_limits(sk, 0))) | 2081 | (sk_memory_allocated(sk) < sk_prot_mem_limits(sk, 0))) |