On Wed, Oct 23, 2024 at 4:35 PM Yafang Shao <[email protected]> wrote:
>
> On Wed, Oct 23, 2024 at 9:01 PM Eric Dumazet <[email protected]> wrote:
> >
> > On Wed, Oct 23, 2024 at 2:33 PM Yafang Shao <[email protected]> wrote:
> > >
> > > We previously hooked the tcp_drop_reason() function using BPF to monitor
> > > TCP drop reasons. However, after upgrading our compiler from GCC 9 to GCC
> > > 11, tcp_drop_reason() is now inlined, preventing us from hooking into it.
> > > To address this, it would be beneficial to introduce a dedicated
> > > tracepoint
> > > for monitoring.
> >
> > This patch would require changes in user space tracers.
> > I am surprised no one came up with a noinline variant.
> >
> > __bpf_kfunc is using
> >
> > #define __bpf_kfunc __used __retain noinline
> >
> > I would rather not have include/trace/events/tcp.h becoming the
> > biggest file in TCP stack...
>
> I’d prefer not to introduce a new tracepoint if we can easily hook it
> with BPF. Does the following change look good to you?
>
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index 092456b8f8af..ebea844cc974 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -4720,7 +4720,7 @@ static bool tcp_ooo_try_coalesce(struct sock *sk,
> return res;
> }
>
> -static void tcp_drop_reason(struct sock *sk, struct sk_buff *skb,
> +noinline static void tcp_drop_reason(struct sock *sk, struct sk_buff *skb,
> enum skb_drop_reason reason)
> {
> sk_drops_add(sk, skb);
>
I would suggest adding an explicit keyword, like the one we have for
noinline_for_stack, for documentation purposes.
noinline_for_tracing perhaps ?
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index
1a957ea2f4fe78ed12d7f6a65e5759d07cea4449..9a687ca4bb4392583d150349ee11015bcb82ec74
100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -265,6 +265,12 @@ struct ftrace_likely_data {
*/
#define noinline_for_stack noinline
+/*
+ * Use noinline_for_tracing for functions that should not be inlined,
+ * for tracing reasons.
+ */
+#define noinline_for_tracing noinline
+
/*
* Sanitizer helper attributes: Because using __always_inline and
* __no_sanitize_* conflict, provide helper attributes that will either expand