Subject: Re: [PATCH net] net: avoid indirect memory pressure calls

From: Florian Westphal <[email-masked]>
Date: Wed, 1 Mar 2023 13:31:14 +0100

Eric Dumazet <[email-masked]> wrote:
> 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 <[email-masked]>
> Date:   Thu Mar 3 19:09:49 2022 -0800
> 
>     PRODKERNEL: net-directcall: annotate tcp_leave_memory_pressure and
>     tcp_getsockopt
> 
> diff --git a/net/core/sock.c b/net/core/sock.c
> index 05032b399c873984e5297898d647905ca9f21f2e..54cb989dc162f3982380ac12cf5a150214e209a2
> 100644
> --- 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.

Thanks.