Skip to contentSkip to conversation

ftrace: Fix function graph notrace setting

GIT PULL Merged Steven Rostedt 2 participants 2 messages Feb 8, 2025 Tracing

lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

Linus,

function graph fix of notrace functions:

When the function graph tracer was restructured to use the global section of the meta data in the shadow stack, the bit logic was changed. There's a TRACE_GRAPH_NOTRACE_BIT that is the bit number in the mask that tells if the function graph tracer is currently in the "notrace" mode. The TRACE_GRAPH_NOTRACE is the mask with that bit set. But when the code was restructured, the TRACE_GRAPH_NOTRACE_BIT was used when it should have been the TRACE_GRAPH_NOTRACE mask. This made notrace not work properly.

Please pull the latest ftrace-v6.14-rc1 tree, which can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
ftrace-v6.14-rc1

Tag SHA1: 9f1894050febeedc75e6cbaef2bd02ea6094a9d9 Head SHA1: c8c9b1d2d5b4377c72a979f5a26e842a869aefc9

Steven Rostedt (1):
fgraph: Fix set_graph_notrace with setting TRACE_GRAPH_NOTRACE_BIT

----

 kernel/trace/trace_functions_graph.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---------------------------
commit c8c9b1d2d5b4377c72a979f5a26e842a869aefc9
Author: Steven Rostedt <[email protected]>
Date:   Sat Feb 8 00:15:11 2025 -0500

fgraph: Fix set_graph_notrace with setting TRACE_GRAPH_NOTRACE_BIT

The code was restructured where the function graph notrace code, that would not trace a function and all its children is done by setting a NOTRACE flag when the function that is not to be traced is hit.

There's a TRACE_GRAPH_NOTRACE_BIT which defines the bit in the flags and a TRACE_GRAPH_NOTRACE which is the mask with that bit set. But the restructuring used TRACE_GRAPH_NOTRACE_BIT when it should have used TRACE_GRAPH_NOTRACE.

For example:

# cd /sys/kernel/tracing
# echo set_track_prepare stack_trace_save > set_graph_notrace # echo function_graph > current_tracer
# cat trace
[..]
0) | __slab_free() {
0) | free_to_partial_list() {
0) | arch_stack_walk() {
0) | __unwind_start() {
0) 0.501 us | get_stack_info();

Where a non filter trace looks like:

# echo > set_graph_notrace
# cat trace
0) | free_to_partial_list() {
0) | set_track_prepare() {
0) | stack_trace_save() {
0) | arch_stack_walk() {
0) | __unwind_start() {

Where the filter should look like:

# cat trace
0) | free_to_partial_list() {
0) | _raw_spin_lock_irqsave() {
0) 0.350 us | preempt_count_add();
0) 0.351 us | do_raw_spin_lock();
0) 2.440 us | }

Cc Masami Hiramatsu <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Mathieu Desnoyers <[email protected]>
Fixes b84214890a9bc ("function_graph: Move graph notrace bit to shadow stack global var")
kernel/trace/trace_functions_graph.c +1 -1
index 54d850997c0a..136c750b0b4d 100644
@@ -198,7 +198,7 @@ int trace_graph_entry(struct ftrace_graph_ent *trace,
 	 * returning from the function.
 	 */
 	if (ftrace_graph_notrace_addr(trace->func)) {
-		*task_var |= TRACE_GRAPH_NOTRACE_BIT;
+		*task_var |= TRACE_GRAPH_NOTRACE;
 		/*
 		 * Need to return 1 to have the return called
 		 * that will clear the NOTRACE bit.
merge bot Merged
#1 lore raw
The pull request you sent on Sat, 8 Feb 2025 09:39:27 -0500:

The pull request you sent on Sat, 8 Feb 2025 09:39:27 -0500:

Quoted 1 line

git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git ftrace-v6.14-rc1

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/a0df483fe303e0c87a6d4a4f60213d5f8703c5ae

Thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html