diff mbox series

[net-next,1/7] Revert "net: set SK_MEM_QUANTUM to 4096"

Message ID 20220609063412.2205738-2-eric.dumazet@gmail.com (mailing list archive)
State Accepted
Commit e70f3c701276a8825414dc650c4f76141a8704b4
Delegated to: Netdev Maintainers
Headers show
Series net: reduce tcp_memory_allocated inflation | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2885 this patch: 2885
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 631 this patch: 631
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 3015 this patch: 3015
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 28 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Eric Dumazet June 9, 2022, 6:34 a.m. UTC
From: Eric Dumazet <edumazet@google.com>

This reverts commit bd68a2a854ad5a85f0c8d0a9c8048ca3f6391efb.

This change broke memcg on arches with PAGE_SIZE != 4096

Later, commit 2bb2f5fb21b04 ("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: Eric Dumazet <edumazet@google.com>
---
 include/net/sock.h | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

Comments

Shakeel Butt June 9, 2022, 3:08 p.m. UTC | #1
On Wed, Jun 8, 2022 at 11:34 PM Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
> From: Eric Dumazet <edumazet@google.com>
>
> This reverts commit bd68a2a854ad5a85f0c8d0a9c8048ca3f6391efb.
>
> This change broke memcg on arches with PAGE_SIZE != 4096
>
> Later, commit 2bb2f5fb21b04 ("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: Eric Dumazet <edumazet@google.com>

Reviewed-by: Shakeel Butt <shakeelb@google.com>
diff mbox series

Patch

diff --git a/include/net/sock.h b/include/net/sock.h
index 657873e2d90fbb2254144aa2405a0551a789edbb..5c5265269899091a7bb8f14766085a463a476403 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -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_reclaim(struct sock *sk, int amount);
 
-/* We used to have PAGE_SIZE here, but systems with 64KB pages
- * do not necessarily have 16x time more memory than 4KB ones.
- */
-#define SK_MEM_QUANTUM 4096
+#define SK_MEM_QUANTUM ((int)PAGE_SIZE)
 #define SK_MEM_QUANTUM_SHIFT ilog2(SK_MEM_QUANTUM)
 #define SK_MEM_SEND	0
 #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)
 {
-	long val = 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;
+	return sk->sk_prot->sysctl_mem[index];
 }
 
 static inline int sk_mem_pages(int amt)