Commit e70f3c70 authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

Revert "net: set SK_MEM_QUANTUM to 4096"

This reverts commit bd68a2a8.

This change broke memcg on arches with PAGE_SIZE != 4096

Later, commit 2bb2f5fb ("net: add new socket option SO_RESERVE_MEM")
also assumed PAGE_SIZE==SK_MEM_QUANTUM

Following patches in the series will greatly reduce the over allocations
problem.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Reviewed-by: default avatarShakeel Butt <shakeelb@google.com>
Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 5c281b4e
...@@ -1532,25 +1532,15 @@ int __sk_mem_schedule(struct sock *sk, int size, int kind); ...@@ -1532,25 +1532,15 @@ int __sk_mem_schedule(struct sock *sk, int size, int kind);
void __sk_mem_reduce_allocated(struct sock *sk, int amount); void __sk_mem_reduce_allocated(struct sock *sk, int amount);
void __sk_mem_reclaim(struct sock *sk, int amount); void __sk_mem_reclaim(struct sock *sk, int amount);
/* We used to have PAGE_SIZE here, but systems with 64KB pages #define SK_MEM_QUANTUM ((int)PAGE_SIZE)
* do not necessarily have 16x time more memory than 4KB ones.
*/
#define SK_MEM_QUANTUM 4096
#define SK_MEM_QUANTUM_SHIFT ilog2(SK_MEM_QUANTUM) #define SK_MEM_QUANTUM_SHIFT ilog2(SK_MEM_QUANTUM)
#define SK_MEM_SEND 0 #define SK_MEM_SEND 0
#define SK_MEM_RECV 1 #define SK_MEM_RECV 1
/* sysctl_mem values are in pages, we convert them in SK_MEM_QUANTUM units */ /* sysctl_mem values are in pages */
static inline long sk_prot_mem_limits(const struct sock *sk, int index) static inline long sk_prot_mem_limits(const struct sock *sk, int index)
{ {
long val = sk->sk_prot->sysctl_mem[index]; return sk->sk_prot->sysctl_mem[index];
#if PAGE_SIZE > SK_MEM_QUANTUM
val <<= PAGE_SHIFT - SK_MEM_QUANTUM_SHIFT;
#elif PAGE_SIZE < SK_MEM_QUANTUM
val >>= SK_MEM_QUANTUM_SHIFT - PAGE_SHIFT;
#endif
return val;
} }
static inline int sk_mem_pages(int amt) static inline int sk_mem_pages(int amt)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment