linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Breno Leitao <leitao@debian.org>,
	 Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	 Masami Hiramatsu <mhiramat@kernel.org>,
	 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	 "David S. Miller" <davem@davemloft.net>,
	 David Ahern <dsahern@kernel.org>,
	 Eric Dumazet <edumazet@google.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>,
	 Simon Horman <horms@kernel.org>,
	 kuniyu@amazon.com,  netdev@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	 linux-trace-kernel@vger.kernel.org,  yonghong.song@linux.dev,
	 song@kernel.org,  kernel-team@meta.com
Subject: Re: [PATCH net-next] udp: Add tracepoint for udp_sendmsg()
Date: Thu, 17 Apr 2025 09:38:41 -0400	[thread overview]
Message-ID: <68010461348e6_159c5529499@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <aADmq6cGLe3yD9Qx@gmail.com>

Breno Leitao wrote:
> Hello Willem,
> 
> On Wed, Apr 16, 2025 at 03:34:38PM -0400, Willem de Bruijn wrote:
> > Breno Leitao wrote:
> > > Add a lightweight tracepoint to monitor UDP send message operations,
> > > similar to the recently introduced tcp_sendmsg_locked() trace event in
> > > commit 0f08335ade712 ("trace: tcp: Add tracepoint for
> > > tcp_sendmsg_locked()")
> > > 
> > > This implementation uses DECLARE_TRACE instead of TRACE_EVENT to avoid
> > > creating extensive trace event infrastructure and exporting to tracefs,
> > > keeping it minimal and efficient.
> > > 
> > > Since this patch creates a rawtracepoint, it can be accessed using
> > > standard tracing tools like bpftrace:
> > > 
> > >     rawtracepoint:udp_sendmsg_tp {
> > >         ...
> > >     }
> > 
> > What does this enable beyond kfunc:udp_sendmsg?
> 
> A few things come to mind when evaluating the use of tracepoints.
> 
> One significant advantage is that tracepoints provide a stable API where
> programs can hook into, making it easier for users to interact with key
> functions.
> 
> However, kfunc/kprobes has some notable disadvantages. For instance,
> partial or total inlining can cause hooks to fail, which is not ideal
> and can lead to issues (mainly when we have partial inlines, and the
> hook works _sometimes_).

As Paolo explained, that is unlikely to happen in this case, as this
is a protocol specific callback function.
 
> In contrast, tracepoints create a more stable API for users to hook
> into, eliminating the need to patch the kernel with noinline function
> attributes. This solution may be ugly, but it is a common practice.
> (and this is my main goal with it, remove `noinline` from our internal
> kernel)
> 
> While tracepoints are not officially considered stable APIs, they tend
> to be "more stable" in practice due to their deliberate and strategic
> placement. As a result, they are less likely to get renamed or changed
> frequently.
> 
> Additionally, tracepoints offer performance benefits, being faster than
> both kfunc and kprobes. 

The performance argument is fair.

Perhaps we want to think this through more broadly for networking
tracepoints vs more flexible kprobes/kfuncs, rather than on a case
by case basis:

Where do we think the performance or functionality (if exposing
additional info, as for tcp_sendmsg) warrants the tracepoint?

I suspect that the use is predominantly for on-demand debugging,
where the performance cost (and latency impact) of measurement is
minor.
 
> For further discussion on this topic, please refer to same discussion in
> VFS:
> 
> https://lore.kernel.org/bpf/20250118033723.GV1977892@ZenIV/T/#m4c2fb2d904e839b34800daf8578dff0b9abd69a0
> 
> Thanks
> --breno



  reply	other threads:[~2025-04-17 13:38 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16 19:23 [PATCH net-next] udp: Add tracepoint for udp_sendmsg() Breno Leitao
2025-04-16 19:34 ` Willem de Bruijn
2025-04-17 11:31   ` Breno Leitao
2025-04-17 13:38     ` Willem de Bruijn [this message]
2025-04-16 23:16 ` David Ahern
2025-04-17 11:42   ` Breno Leitao
2025-04-17 15:55     ` David Ahern
2025-04-17 16:00       ` Breno Leitao
2025-04-18  4:57         ` David Ahern
2025-04-18 12:33           ` Steven Rostedt
2025-04-18 14:47             ` Steven Rostedt
2025-04-17  6:57 ` Paolo Abeni
2025-04-17 11:34   ` Breno Leitao
2025-04-17 13:17     ` Paolo Abeni
2025-04-17 15:37       ` Song Liu
2025-04-17 15:48         ` Willem de Bruijn
2025-04-17 20:00           ` Song Liu
2025-04-18 14:49             ` Willem de Bruijn
2025-05-27 13:45               ` Breno Leitao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=68010461348e6_159c5529499@willemb.c.googlers.com.notmuch \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).