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>
This commit is contained in:
committed by
David S. Miller
parent
4633c9e07b
commit
1a24e04e4b
@@ -2069,12 +2069,13 @@ EXPORT_SYMBOL(__sk_mem_schedule);
|
||||
/**
|
||||
* __sk_reclaim - reclaim memory_allocated
|
||||
* @sk: socket
|
||||
* @amount: number of bytes (rounded down to a SK_MEM_QUANTUM multiple)
|
||||
*/
|
||||
void __sk_mem_reclaim(struct sock *sk)
|
||||
void __sk_mem_reclaim(struct sock *sk, int amount)
|
||||
{
|
||||
sk_memory_allocated_sub(sk,
|
||||
sk->sk_forward_alloc >> SK_MEM_QUANTUM_SHIFT);
|
||||
sk->sk_forward_alloc &= SK_MEM_QUANTUM - 1;
|
||||
amount >>= SK_MEM_QUANTUM_SHIFT;
|
||||
sk_memory_allocated_sub(sk, amount);
|
||||
sk->sk_forward_alloc -= amount << SK_MEM_QUANTUM_SHIFT;
|
||||
|
||||
if (sk_under_memory_pressure(sk) &&
|
||||
(sk_memory_allocated(sk) < sk_prot_mem_limits(sk, 0)))
|
||||
|
||||
Reference in New Issue
Block a user