Messages in this thread | | | Date | Mon, 18 Sep 2023 15:48:39 +0800 | Subject | Re: [RFC PATCH net-next 3/3] sock: Throttle pressure-aware sockets under pressure | From | Abel Wu <> |
| |
On 9/1/23 2:21 PM, Abel Wu wrote: > @@ -3087,8 +3100,20 @@ int __sk_mem_raise_allocated(struct sock *sk, int size, int amt, int kind) > if (sk_has_memory_pressure(sk)) { > u64 alloc; > > - if (!sk_under_memory_pressure(sk)) > + /* Be more conservative if the socket's memcg (or its > + * parents) is under reclaim pressure, try to possibly > + * avoid further memstall. > + */ > + if (under_memcg_pressure) > + goto suppress_allocation; > + > + if (!sk_under_global_memory_pressure(sk)) > return 1; > + > + /* Trying to be fair among all the sockets of same > + * protocal under global memory pressure, by allowing > + * the ones that under average usage to raise. > + */ > alloc = sk_sockets_allocated_read_positive(sk); > if (sk_prot_mem_limits(sk, 2) > alloc * > sk_mem_pages(sk->sk_wmem_queued +
I totally agree with what Shakeel said in last reply and will try ebpf- based solution to let userspace inject proper strategies. But IMHO the above hunk is irrelevant to the idea of this patchset, and is the right thing to do, so maybe worth a separate patch?
This hunk originally passes the allocation when this socket is below average usage even under global and/or memcg pressure. It makes sense to do so under global pressure, as the 'average' is in the scope of global, but it's really weird from a memcg's point of view. Actually this pass condition was present before memcg pressure was introduced.
Please correct me if I missed something, thanks!
Best, Abel
| |