linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] function_graph: Enable funcgraph-args and funcgraph-retaddr to work simultaneously
@ 2025-12-02  8:32 Dan Carpenter
  2026-01-02 18:56 ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2025-12-02  8:32 UTC (permalink / raw)
  To: pengdonglin; +Cc: linux-trace-kernel

Hello pengdonglin,

Commit f83ac7544fbf ("function_graph: Enable funcgraph-args and
funcgraph-retaddr to work simultaneously") from Nov 25, 2025
(linux-next), leads to the following Smatch static checker warning:

kernel/trace/trace_functions_graph.c:1033 print_graph_entry_nested() warn: unsigned 'call->depth' is never less than zero.
kernel/trace/trace_functions_graph.c:975 print_graph_entry_leaf() warn: unsigned 'call->depth' is never less than zero.
kernel/trace/trace.h:1130 ftrace_graph_ignore_func() warn: unsigned 'trace->depth' is never less than zero.

kernel/trace/trace_functions_graph.c
    1012 static enum print_line_t
    1013 print_graph_entry_nested(struct trace_iterator *iter,
    1014                          struct ftrace_graph_ent_entry *entry,
    1015                          struct trace_seq *s, int cpu, u32 flags)
    1016 {
    1017         struct ftrace_graph_ent *call = &entry->graph_ent;
    1018         struct fgraph_data *data = iter->private;
    1019         struct trace_array *tr = iter->tr;
    1020         unsigned long func;
    1021         int args_size;
    1022         int i;
    1023 
    1024         if (data) {
    1025                 struct fgraph_cpu_data *cpu_data;
    1026                 int cpu = iter->cpu;
    1027 
    1028                 cpu_data = per_cpu_ptr(data->cpu_data, cpu);
    1029                 cpu_data->depth = call->depth;
    1030 
    1031                 /* Save this function pointer to see if the exit matches */
    1032                 if (call->depth < FTRACE_RETFUNC_DEPTH &&
--> 1033                     !WARN_ON_ONCE(call->depth < 0))
                                           ^^^^^^^^^^^^^^^
The patch changed call->depth from int to unsigned long.

    1034                         cpu_data->enter_funcs[call->depth] = call->func;
    1035         }
    1036 
    1037         /* No time */
    1038         print_graph_duration(tr, 0, s, flags | FLAGS_FILL_FULL);

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bug report] function_graph: Enable funcgraph-args and funcgraph-retaddr to work simultaneously
  2025-12-02  8:32 [bug report] function_graph: Enable funcgraph-args and funcgraph-retaddr to work simultaneously Dan Carpenter
@ 2026-01-02 18:56 ` Steven Rostedt
  2026-01-02 18:58   ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2026-01-02 18:56 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: pengdonglin, linux-trace-kernel

On Tue, 2 Dec 2025 11:32:26 +0300
Dan Carpenter <dan.carpenter@linaro.org> wrote:

I just noticed this email.

> Hello pengdonglin,
> 
> Commit f83ac7544fbf ("function_graph: Enable funcgraph-args and
> funcgraph-retaddr to work simultaneously") from Nov 25, 2025
> (linux-next), leads to the following Smatch static checker warning:
> 
> kernel/trace/trace_functions_graph.c:1033 print_graph_entry_nested() warn: unsigned 'call->depth' is never less than zero.
> kernel/trace/trace_functions_graph.c:975 print_graph_entry_leaf() warn: unsigned 'call->depth' is never less than zero.
> kernel/trace/trace.h:1130 ftrace_graph_ignore_func() warn: unsigned 'trace->depth' is never less than zero.
> 
> kernel/trace/trace_functions_graph.c
>     1012 static enum print_line_t
>     1013 print_graph_entry_nested(struct trace_iterator *iter,
>     1014                          struct ftrace_graph_ent_entry *entry,
>     1015                          struct trace_seq *s, int cpu, u32 flags)
>     1016 {
>     1017         struct ftrace_graph_ent *call = &entry->graph_ent;
>     1018         struct fgraph_data *data = iter->private;
>     1019         struct trace_array *tr = iter->tr;
>     1020         unsigned long func;
>     1021         int args_size;
>     1022         int i;
>     1023 
>     1024         if (data) {
>     1025                 struct fgraph_cpu_data *cpu_data;
>     1026                 int cpu = iter->cpu;
>     1027 
>     1028                 cpu_data = per_cpu_ptr(data->cpu_data, cpu);
>     1029                 cpu_data->depth = call->depth;
>     1030 
>     1031                 /* Save this function pointer to see if the exit matches */
>     1032                 if (call->depth < FTRACE_RETFUNC_DEPTH &&
> --> 1033                     !WARN_ON_ONCE(call->depth < 0))  
>                                            ^^^^^^^^^^^^^^^
> The patch changed call->depth from int to unsigned long.

Yep, I'm fixing this with:

			!WARN_ON_ONCE((long)call->depth < 0))

Thanks!

-- Steve

> 
>     1034                         cpu_data->enter_funcs[call->depth] = call->func;
>     1035         }
>     1036 
>     1037         /* No time */
>     1038         print_graph_duration(tr, 0, s, flags | FLAGS_FILL_FULL);
> 
> regards,
> dan carpenter


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bug report] function_graph: Enable funcgraph-args and funcgraph-retaddr to work simultaneously
  2026-01-02 18:56 ` Steven Rostedt
@ 2026-01-02 18:58   ` Steven Rostedt
  0 siblings, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2026-01-02 18:58 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: pengdonglin, linux-trace-kernel

On Fri, 2 Jan 2026 13:56:30 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> >     1031                 /* Save this function pointer to see if the exit matches */
> >     1032                 if (call->depth < FTRACE_RETFUNC_DEPTH &&  
> > --> 1033                     !WARN_ON_ONCE(call->depth < 0))    
> >                                            ^^^^^^^^^^^^^^^
> > The patch changed call->depth from int to unsigned long.  
> 
> Yep, I'm fixing this with:
> 
> 			!WARN_ON_ONCE((long)call->depth < 0))
> 

Thinking about this more. I think it is more robust to change depth to
"long" from "unsigned long" in case there's other locations that expect
depth to be signed.

-- Steve

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-01-02 18:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-02  8:32 [bug report] function_graph: Enable funcgraph-args and funcgraph-retaddr to work simultaneously Dan Carpenter
2026-01-02 18:56 ` Steven Rostedt
2026-01-02 18:58   ` Steven Rostedt

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).