Re: [PATCH net] net: avoid indirect memory pressure calls
From: Eric Dumazet <edumazet@google.com>
Date: 2023-03-01 12:51:31
On Wed, Mar 1, 2023 at 1:31 PM Florian Westphal [off-list ref] wrote:
Eric Dumazet [off-list ref] wrote:quoted
BTW I was curious why Google was not seeing this, and it appears Brian Vasquez forgot to upstream this change... commit 5ea2f21d6c1078d2c563cb455ad5877b4ada94e1 Author: Brian Vazquez [off-list ref] Date: Thu Mar 3 19:09:49 2022 -0800 PRODKERNEL: net-directcall: annotate tcp_leave_memory_pressure and tcp_getsockoptdiff --git a/net/core/sock.c b/net/core/sock.c index 05032b399c873984e5297898d647905ca9f21f2e..54cb989dc162f3982380ac12cf5a150214e209a2100644--- a/net/core/sock.c +++ b/net/core/sock.c@@ -2647,10 +2647,13 @@ static void sk_enter_memory_pressure(struct sock *sk) sk->sk_prot->enter_memory_pressure(sk); } +INDIRECT_CALLABLE_DECLARE(void tcp_leave_memory_pressure(struct sock *sk)); + static void sk_leave_memory_pressure(struct sock *sk) { if (sk->sk_prot->leave_memory_pressure) { - sk->sk_prot->leave_memory_pressure(sk); + INDIRECT_CALL_1(sk->sk_prot->leave_memory_pressure, + tcp_leave_memory_pressure, sk); } else { unsigned long *memory_pressure = sk->sk_prot->memory_pressure;re-tested: this change also resolves the regression i was seeing. If you prefer to upstream this instead of the proposed change then I'm fine with that.
This seems a bit less risky, if the plan is to add this to stable trees. ( We had this mitigation for ~4 years at Google) I will rebase Brian patch (only the tcp_leave_memory_pressure part) and send it. Thanks !