Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ftrace: Do not disabled function graph based on "disabled" field

The per CPU "disabled" value was the original way to disable tracing when
the tracing subsystem was first created. Today, the ring buffer
infrastructure has its own way to disable tracing. In fact, things have
changed so much since 2008 that many things ignore the disable flag.

Do not bother disabling the function graph tracer if the per CPU disabled
field is set. Just record as normal. If tracing is disabled in the ring
buffer it will not be recorded.

Also, when tracing is enabled again, it will not drop the return call of
the function.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: https://lore.kernel.org/20250505212235.715752008@goodmis.org
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+9 -29
+9 -29
kernel/trace/trace_functions_graph.c
··· 202 202 { 203 203 unsigned long *task_var = fgraph_get_task_var(gops); 204 204 struct trace_array *tr = gops->private; 205 - struct trace_array_cpu *data; 206 205 struct fgraph_times *ftimes; 207 206 unsigned int trace_ctx; 208 - long disabled; 209 207 int ret = 0; 210 - int cpu; 211 208 212 209 if (*task_var & TRACE_GRAPH_NOTRACE) 213 210 return 0; ··· 254 257 if (tracing_thresh) 255 258 return 1; 256 259 257 - preempt_disable_notrace(); 258 - cpu = raw_smp_processor_id(); 259 - data = per_cpu_ptr(tr->array_buffer.data, cpu); 260 - disabled = atomic_read(&data->disabled); 261 - if (likely(!disabled)) { 262 - trace_ctx = tracing_gen_ctx(); 263 - if (IS_ENABLED(CONFIG_FUNCTION_GRAPH_RETADDR) && 264 - tracer_flags_is_set(TRACE_GRAPH_PRINT_RETADDR)) { 265 - unsigned long retaddr = ftrace_graph_top_ret_addr(current); 266 - ret = __trace_graph_retaddr_entry(tr, trace, trace_ctx, retaddr); 267 - } else { 268 - ret = __graph_entry(tr, trace, trace_ctx, fregs); 269 - } 260 + trace_ctx = tracing_gen_ctx(); 261 + if (IS_ENABLED(CONFIG_FUNCTION_GRAPH_RETADDR) && 262 + tracer_flags_is_set(TRACE_GRAPH_PRINT_RETADDR)) { 263 + unsigned long retaddr = ftrace_graph_top_ret_addr(current); 264 + ret = __trace_graph_retaddr_entry(tr, trace, trace_ctx, retaddr); 265 + } else { 266 + ret = __graph_entry(tr, trace, trace_ctx, fregs); 270 267 } 271 - preempt_enable_notrace(); 272 268 273 269 return ret; 274 270 } ··· 341 351 { 342 352 unsigned long *task_var = fgraph_get_task_var(gops); 343 353 struct trace_array *tr = gops->private; 344 - struct trace_array_cpu *data; 345 354 struct fgraph_times *ftimes; 346 355 unsigned int trace_ctx; 347 356 u64 calltime, rettime; 348 - long disabled; 349 357 int size; 350 - int cpu; 351 358 352 359 rettime = trace_clock_local(); 353 360 ··· 363 376 364 377 calltime = ftimes->calltime; 365 378 366 - preempt_disable_notrace(); 367 - cpu = raw_smp_processor_id(); 368 - data = per_cpu_ptr(tr->array_buffer.data, cpu); 369 - disabled = atomic_read(&data->disabled); 370 - if (likely(!disabled)) { 371 - trace_ctx = tracing_gen_ctx(); 372 - __trace_graph_return(tr, trace, trace_ctx, calltime, rettime); 373 - } 374 - preempt_enable_notrace(); 379 + trace_ctx = tracing_gen_ctx(); 380 + __trace_graph_return(tr, trace, trace_ctx, calltime, rettime); 375 381 } 376 382 377 383 static void trace_graph_thresh_return(struct ftrace_graph_ret *trace,