ftrace: Changes for v6.17
Linus,
ftrace changes for v6.17:
- Keep track of when fgraph_ops are registered or not
Keep accounting of when fgraph_ops are registered as if a fgraph_ops is registered twice it can mess up the accounting and it will not work as expected later. Trigger a warning if something registers it twice as to catch bugs before they are found by things just not working as expected.
- Make DYNAMIC_FTRACE always enabled for architectures that support it
As static ftrace (where all functions are always traced) is very expensive and only exists to help architectures support ftrace, do not make it an option. As soon as an architecture supports DYNAMIC_FTRACE make it use it. This simplifies the code.
- Remove redundant config HAVE_FTRACE_MCOUNT_RECORD
The CONFIG_HAVE_FTRACE_MCOUNT was added to help simplify the DYNAMIC_FTRACE work, but now every architecture that implements DYNAMIC_FTRACE also has HAVE_FTRACE_MCOUNT set too, making it redundant with the HAVE_DYNAMIC_FTRACE.
- Make pid_ptr string size match the comment
In print_graph_proc() the pid_ptr string is of size 11, but the comment says /* sign + log10(MAX_INT) + '\0' */ which is actually 12.
Please pull the latest ftrace-v6.17 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
ftrace-v6.17
Tag SHA1: 58cc39c90ea0e6a1213b565a4859ed6f2a9a0b1a Head SHA1: 4d6d0a6263babf7c43faa55de4fa3c6637dec624
Artem Sadovnikov (1):
fgraph: Make pid_str size match the comment
Steven Rostedt (3):
fgraph: Keep track of when fgraph_ops are registered or not
ftrace: Make DYNAMIC_FTRACE always enabled for architectures that support it
tracing: Remove redundant config HAVE_FTRACE_MCOUNT_RECORD
----
Documentation/trace/ftrace-design.rst | 12 ++++-------- arch/arm/Kconfig | 1 - arch/arm64/Kconfig | 1 - arch/csky/Kconfig | 1 - arch/loongarch/Kconfig | 1 - arch/microblaze/Kconfig | 1 - arch/mips/Kconfig | 1 - arch/parisc/Kconfig | 1 - arch/powerpc/Kconfig | 1 - arch/riscv/Kconfig | 1 - arch/s390/Kconfig | 1 - arch/sh/Kconfig | 1 - arch/sparc/Kconfig | 1 - arch/x86/Kconfig | 1 - include/asm-generic/vmlinux.lds.h | 2 +- include/linux/ftrace.h | 2 +- include/linux/kernel.h | 6 +++--- include/linux/module.h | 2 +- kernel/module/main.c | 2 +- kernel/trace/Kconfig | 20 +++++--------------- kernel/trace/fgraph.c | 16 +++++++++++++--- kernel/trace/ftrace.c | 4 ---- kernel/trace/trace_functions_graph.c | 2 +- scripts/recordmcount.pl | 2 +- 24 files changed, 31 insertions(+), 52 deletions(-)
---------------------------
Quoted 3 lines · Steven Rostedt
In
print_graph_proc()thepid_ptrstring is of size 11, but the comment says /* sign +log10(MAX_INT)+ '\0' */ which is actually 12.
Lol. Quoting the ancient Greeks: "Math is hard, let's go shopping".
That said, the comment is garbage anyway.
Because "sign + log10(MAX_INT) + '\0'" really is just 11 - if you round or truncate.
So somebody may have actually done the math "correctly", but the math was just stated wrongly.
Much better to actually write things out properly instead of trying to be fancy.
Becasue might be more legible to actually write it out and let the compiler do things, ie just do
// This includes the sign and the terminating '\0' #define MAX_INT_CHARACTERS sizeof("-2147483648")
which doesn't require people to know - or think they know - logarithms.
Random rule for the day: don't ask people to do more than third-grade math.
Linus
Quoted 11 lines · On Wed, 30 Jul 2025 16:15:21 -0700 Linus Torvalds…
Quoted 3 lines · Steven Rostedt
In
print_graph_proc()thepid_ptrstring is of size 11, but the comment says /* sign +log10(MAX_INT)+ '\0' */ which is actually 12.Lol. Quoting the ancient Greeks: "Math is hard, let's go shopping".
That said, the comment is garbage anyway.
Because "sign +
log10(MAX_INT)+ '\0'" really is just 11 - if you round or truncate.
I'm confused, sizeof("-2147483648") is equal to 12.
$ echo '
#include <stdio.h>
int main (int argc, char **argv)
{
printf("%ld\n", sizeof("-2147483648"));
return 0;
}' > maxchar.c$ gcc -o maxchar maxchar.c $ ./maxchar 12
Quoted 6 lines
So somebody may have actually done the math "correctly", but the math was just stated wrongly.
Much better to actually write things out properly instead of trying to be fancy.
Quoted 7 lines
Becasue might be more legible to actually write it out and let the compiler do things, ie just do
// This includes the sign and the terminating '\0' #define MAX_INT_CHARACTERS sizeof("-2147483648")which doesn't require people to know - or think they know - logarithms.
Hmm, should we add that to a header file?
-- Steve
Quoted 4 lines · On Thu, 31 Jul 2025 07:53:18 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 2 lines
Because "sign +
log10(MAX_INT)+ '\0'" really is just 11 - if you round or truncate.I'm confused,
sizeof("-2147483648")is equal to 12.
Never mind, I just realized you meant rounding or truncating the "log10(MAX_INT)".
-- Steve
The pull request you sent on Tue, 29 Jul 2025 14:42:26 -0400:
The pull request you sent on Tue, 29 Jul 2025 14:42:26 -0400:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.gitftrace-v6.17
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/90a871f74b70027779a4f312c0c74b6a89e22412
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html