* [GIT PULL] ftrace: Updates for v6.14
@ 2025-01-20 0:31 Steven Rostedt
2025-01-21 23:22 ` pr-tracker-bot
2025-02-17 11:49 ` Heiko Carstens
0 siblings, 2 replies; 5+ messages in thread
From: Steven Rostedt @ 2025-01-20 0:31 UTC (permalink / raw)
To: Linus Torvalds
Cc: LKML, Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Sven Schnelle
Linus,
ftrace updates for v6.14:
- Have fprobes built on top of function graph infrastructure
The fprobe logic is an optimized kprobe that uses ftrace to attach to
functions when a probe is needed at the start or end of the function. The
fprobe and kretprobe logic implements a similar method as the function
graph tracer to trace the end of the function. That is to hijack the
return address and jump to a trampoline to do the trace when the function
exits. To do this, a shadow stack needs to be created to store the
original return address. Fprobes and function graph do this slightly
differently. Fprobes (and kretprobes) has slots per callsite that are
reserved to save the return address. This is fine when just a few points
are traced. But users of fprobes, such as BPF programs, are starting to add
many more locations, and this method does not scale.
The function graph tracer was created to trace all functions in the
kernel. In order to do this, when function graph tracing is started, every
task gets its own shadow stack to hold the return address that is going to
be traced. The function graph tracer has been updated to allow multiple
users to use its infrastructure. Now have fprobes be one of those users.
This will also allow for the fprobe and kretprobe methods to trace the
return address to become obsolete. With new technologies like CFI that
need to know about these methods of hijacking the return address, going
toward a solution that has only one method of doing this will make the
kernel less complex.
- Cleanup with guard() and free() helpers
There were several places in the code that had a lot of "goto out" in the
error paths to either unlock a lock or free some memory that was
allocated. But this is error prone. Convert the code over to use the
guard() and free() helpers that let the compiler unlock locks or free
memory when the function exits.
- Remove disabling of interrupts in the function graph tracer
When function graph tracer was first introduced, it could race with
interrupts and NMIs. To prevent that race, it would disable interrupts and
not trace NMIs. But the code has changed to allow NMIs and also
interrupts. This change was done a long time ago, but the disabling of
interrupts was never removed. Remove the disabling of interrupts in the
function graph tracer is it is not needed. This greatly improves its
performance.
- Allow the :mod: command to enable tracing module functions on the kernel
command line.
The function tracer already has a way to enable functions to be traced in
modules by writing ":mod:<module>" into set_ftrace_filter. That will
enable either all the functions for the module if it is loaded, or if it
is not, it will cache that command, and when the module is loaded that
matches <module>, its functions will be enabled. This also allows init
functions to be traced. But currently events do not have that feature.
Because enabling function tracing can be done very early at boot up
(before scheduling is enabled), the commands that can be done when
function tracing is started is limited. Having the ":mod:" command to
trace module functions as they are loaded is very useful. Update the
kernel command line function filtering to allow it.
Please pull the latest ftrace-v6.14 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
ftrace-v6.14
Tag SHA1: 4df2b00c6c7d7a0a0b2cfe423637c0371d3a9128
Head SHA1: 31f505dc70331243fbb54af868c14bb5f44a15bc
Masami Hiramatsu (Google) (20):
fgraph: Get ftrace recursion lock in function_graph_enter
fgraph: Pass ftrace_regs to entryfunc
fgraph: Replace fgraph_ret_regs with ftrace_regs
fgraph: Pass ftrace_regs to retfunc
fprobe: Use ftrace_regs in fprobe entry handler
fprobe: Use ftrace_regs in fprobe exit handler
tracing: Add ftrace_partial_regs() for converting ftrace_regs to pt_regs
tracing: Add ftrace_fill_perf_regs() for perf event
tracing/fprobe: Enable fprobe events with CONFIG_DYNAMIC_FTRACE_WITH_ARGS
bpf: Enable kprobe_multi feature if CONFIG_FPROBE is enabled
ftrace: Add CONFIG_HAVE_FTRACE_GRAPH_FUNC
fprobe: Rewrite fprobe on function-graph tracer
fprobe: Add fprobe_header encoding feature
tracing/fprobe: Remove nr_maxactive from fprobe
selftests: ftrace: Remove obsolate maxactive syntax check
selftests/ftrace: Add a test case for repeating register/unregister fprobe
Documentation: probes: Update fprobe on function-graph tracer
ftrace: Add ftrace_get_symaddr to convert fentry_ip to symaddr
bpf: Use ftrace_get_symaddr() for kprobe_multi probes
tracing: Adopt __free() and guard() for trace_fprobe.c
Steven Rostedt (5):
fgraph: Remove unnecessary disabling of interrupts and recursion
ftrace: Do not disable interrupts in profiler
ftrace: Remove unneeded goto jumps
ftrace: Switch ftrace.c code over to use guard()
ftrace: Implement :mod: cache filtering on kernel command line
Sven Schnelle (1):
s390/tracing: Enable HAVE_FTRACE_GRAPH_FUNC
----
Documentation/trace/fprobe.rst | 42 +-
arch/arm64/Kconfig | 2 +
arch/arm64/include/asm/Kbuild | 1 +
arch/arm64/include/asm/ftrace.h | 51 +-
arch/arm64/kernel/asm-offsets.c | 12 -
arch/arm64/kernel/entry-ftrace.S | 32 +-
arch/arm64/kernel/ftrace.c | 78 ++-
arch/loongarch/Kconfig | 4 +-
arch/loongarch/include/asm/fprobe.h | 12 +
arch/loongarch/include/asm/ftrace.h | 32 +-
arch/loongarch/kernel/asm-offsets.c | 12 -
arch/loongarch/kernel/ftrace_dyn.c | 10 +-
arch/loongarch/kernel/mcount.S | 17 +-
arch/loongarch/kernel/mcount_dyn.S | 14 +-
arch/powerpc/Kconfig | 1 +
arch/powerpc/include/asm/ftrace.h | 13 +
arch/powerpc/kernel/trace/ftrace.c | 8 +-
arch/powerpc/kernel/trace/ftrace_64_pg.c | 16 +-
arch/riscv/Kconfig | 3 +-
arch/riscv/include/asm/Kbuild | 1 +
arch/riscv/include/asm/ftrace.h | 45 +-
arch/riscv/kernel/ftrace.c | 17 +-
arch/riscv/kernel/mcount.S | 24 +-
arch/s390/Kconfig | 4 +-
arch/s390/include/asm/fprobe.h | 10 +
arch/s390/include/asm/ftrace.h | 37 +-
arch/s390/kernel/asm-offsets.c | 6 -
arch/s390/kernel/entry.h | 1 -
arch/s390/kernel/ftrace.c | 48 +-
arch/s390/kernel/mcount.S | 23 +-
arch/x86/Kconfig | 4 +-
arch/x86/include/asm/Kbuild | 1 +
arch/x86/include/asm/ftrace.h | 54 +-
arch/x86/kernel/ftrace.c | 47 +-
arch/x86/kernel/ftrace_32.S | 13 +-
arch/x86/kernel/ftrace_64.S | 17 +-
include/asm-generic/fprobe.h | 46 ++
include/linux/fprobe.h | 62 +-
include/linux/ftrace.h | 116 +++-
include/linux/ftrace_regs.h | 2 +
kernel/trace/Kconfig | 22 +-
kernel/trace/bpf_trace.c | 28 +-
kernel/trace/fgraph.c | 65 +-
kernel/trace/fprobe.c | 664 +++++++++++++++------
kernel/trace/ftrace.c | 203 ++++---
kernel/trace/trace.c | 8 +
kernel/trace/trace.h | 8 +-
kernel/trace/trace_fprobe.c | 270 +++++----
kernel/trace/trace_functions_graph.c | 47 +-
kernel/trace/trace_irqsoff.c | 6 +-
kernel/trace/trace_probe_tmpl.h | 2 +-
kernel/trace/trace_sched_wakeup.c | 6 +-
kernel/trace/trace_selftest.c | 11 +-
lib/test_fprobe.c | 51 +-
samples/fprobe/fprobe_example.c | 4 +-
.../test.d/dynevent/add_remove_fprobe_repeat.tc | 19 +
.../ftrace/test.d/dynevent/fprobe_syntax_errors.tc | 4 +-
57 files changed, 1504 insertions(+), 852 deletions(-)
create mode 100644 arch/loongarch/include/asm/fprobe.h
create mode 100644 arch/s390/include/asm/fprobe.h
create mode 100644 include/asm-generic/fprobe.h
create mode 100644 tools/testing/selftests/ftrace/test.d/dynevent/add_remove_fprobe_repeat.tc
---------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [GIT PULL] ftrace: Updates for v6.14
2025-01-20 0:31 [GIT PULL] ftrace: Updates for v6.14 Steven Rostedt
@ 2025-01-21 23:22 ` pr-tracker-bot
2025-02-17 11:49 ` Heiko Carstens
1 sibling, 0 replies; 5+ messages in thread
From: pr-tracker-bot @ 2025-01-21 23:22 UTC (permalink / raw)
To: Steven Rostedt
Cc: Linus Torvalds, LKML, Masami Hiramatsu, Mark Rutland,
Mathieu Desnoyers, Sven Schnelle
The pull request you sent on Sun, 19 Jan 2025 19:31:34 -0500:
> git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git ftrace-v6.14
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/2e04247f7cce8b8cd8381a29078701691fec684d
Thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [GIT PULL] ftrace: Updates for v6.14
2025-01-20 0:31 [GIT PULL] ftrace: Updates for v6.14 Steven Rostedt
2025-01-21 23:22 ` pr-tracker-bot
@ 2025-02-17 11:49 ` Heiko Carstens
2025-02-17 18:38 ` Steven Rostedt
1 sibling, 1 reply; 5+ messages in thread
From: Heiko Carstens @ 2025-02-17 11:49 UTC (permalink / raw)
To: Steven Rostedt, Masami Hiramatsu
Cc: Linus Torvalds, LKML, Mark Rutland, Mathieu Desnoyers,
Sven Schnelle, Vasily Gorbik, Alexander Gordeev
Hi Steven, Masami,
On Sun, Jan 19, 2025 at 07:31:34PM -0500, Steven Rostedt wrote:
> ftrace updates for v6.14:
>
> - Have fprobes built on top of function graph infrastructure
this seems to cause a regression:
When I run tools/testing/selftests/ftrace/ftracetest I now end up with all
functions being enabled for ftrace after the test suite ran:
$ wc -l /sys/kernel/debug/tracing/enabled_functions
50779 /sys/kernel/debug/tracing/enabled_functions
$ cat /sys/kernel/debug/tracing/enabled_functions
...
down (1)
down_interruptible (1)
down_killable (1)
$ cat /sys/kernel/debug/tracing/current_tracer
nop
Bisected to commit 4346ba160409 ("fprobe: Rewrite fprobe on function-graph
tracer"). Before this commit there were no ftrace enabled functions after the
test suite finished:
$ wc -l /sys/kernel/debug/tracing/enabled_functions
0 /sys/kernel/debug/tracing/enabled_functions
This is on s390 with defconfig.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [GIT PULL] ftrace: Updates for v6.14
2025-02-17 11:49 ` Heiko Carstens
@ 2025-02-17 18:38 ` Steven Rostedt
2025-02-18 16:26 ` Steven Rostedt
0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2025-02-17 18:38 UTC (permalink / raw)
To: Heiko Carstens
Cc: Masami Hiramatsu, Linus Torvalds, LKML, Mark Rutland,
Mathieu Desnoyers, Sven Schnelle, Vasily Gorbik,
Alexander Gordeev
On Mon, 17 Feb 2025 12:49:18 +0100
Heiko Carstens <hca@linux.ibm.com> wrote:
> $ cat /sys/kernel/debug/tracing/current_tracer
> nop
>
> Bisected to commit 4346ba160409 ("fprobe: Rewrite fprobe on function-graph
> tracer"). Before this commit there were no ftrace enabled functions after the
> test suite finished:
>
> $ wc -l /sys/kernel/debug/tracing/enabled_functions
> 0 /sys/kernel/debug/tracing/enabled_functions
>
> This is on s390 with defconfig.
Thanks, I can reproduce it on x86 (I didn't check that commit though).
I'll take a look.
-- Steve
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [GIT PULL] ftrace: Updates for v6.14
2025-02-17 18:38 ` Steven Rostedt
@ 2025-02-18 16:26 ` Steven Rostedt
0 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2025-02-18 16:26 UTC (permalink / raw)
To: Heiko Carstens
Cc: Masami Hiramatsu, Linus Torvalds, LKML, Mark Rutland,
Mathieu Desnoyers, Sven Schnelle, Vasily Gorbik,
Alexander Gordeev
On Mon, 17 Feb 2025 13:38:30 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:
> On Mon, 17 Feb 2025 12:49:18 +0100
> Heiko Carstens <hca@linux.ibm.com> wrote:
>
> > $ cat /sys/kernel/debug/tracing/current_tracer
> > nop
> >
> > Bisected to commit 4346ba160409 ("fprobe: Rewrite fprobe on function-graph
> > tracer"). Before this commit there were no ftrace enabled functions after the
> > test suite finished:
> >
> > $ wc -l /sys/kernel/debug/tracing/enabled_functions
> > 0 /sys/kernel/debug/tracing/enabled_functions
> >
> > This is on s390 with defconfig.
>
> Thanks, I can reproduce it on x86 (I didn't check that commit though).
>
> I'll take a look.
I think I found 3 different bugs in the accounting of what is registered
and what is not. I'll post a patch series shortly. Two in the function
graph tracer subops accounting, and one in the fprobe accounting.
-- Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-02-18 16:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-20 0:31 [GIT PULL] ftrace: Updates for v6.14 Steven Rostedt
2025-01-21 23:22 ` pr-tracker-bot
2025-02-17 11:49 ` Heiko Carstens
2025-02-17 18:38 ` Steven Rostedt
2025-02-18 16:26 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®