Message ID | 20210202193408.1171634-1-weiwan@google.com (mailing list archive) |
---|---|
State | Accepted |
Commit | f5a5589c72509abaeb705123b64e7f5a078becf0 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next] tcp: use a smaller percpu_counter batch size for sk_alloc | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | success | CCed 3 of 3 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 4407 this patch: 4407 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 20 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 4828 this patch: 4828 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
Hello: This patch was applied to netdev/net-next.git (refs/heads/master): On Tue, 2 Feb 2021 11:34:08 -0800 you wrote: > Currently, a percpu_counter with the default batch size (2*nr_cpus) is > used to record the total # of active sockets per protocol. This means > sk_sockets_allocated_read_positive() could be off by +/-2*(nr_cpus^2). > This under/over-estimation could lead to wrong memory suppression > conditions in __sk_raise_mem_allocated(). > Fix this by using a more reasonable fixed batch size of 16. > > [...] Here is the summary with links: - [net-next] tcp: use a smaller percpu_counter batch size for sk_alloc https://git.kernel.org/netdev/net-next/c/f5a5589c7250 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
diff --git a/include/net/sock.h b/include/net/sock.h index 129d200bccb4..690e496a0e79 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1350,14 +1350,18 @@ sk_memory_allocated_sub(struct sock *sk, int amt) atomic_long_sub(amt, sk->sk_prot->memory_allocated); } +#define SK_ALLOC_PERCPU_COUNTER_BATCH 16 + static inline void sk_sockets_allocated_dec(struct sock *sk) { - percpu_counter_dec(sk->sk_prot->sockets_allocated); + percpu_counter_add_batch(sk->sk_prot->sockets_allocated, -1, + SK_ALLOC_PERCPU_COUNTER_BATCH); } static inline void sk_sockets_allocated_inc(struct sock *sk) { - percpu_counter_inc(sk->sk_prot->sockets_allocated); + percpu_counter_add_batch(sk->sk_prot->sockets_allocated, 1, + SK_ALLOC_PERCPU_COUNTER_BATCH); } static inline u64