linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] tracing: Have function graph tracer option sleep-time be per instance
@ 2025-11-19  7:31 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2025-11-19  7:31 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-kernel

Hello Steven Rostedt,

Commit 5abb6ccb58f0 ("tracing: Have function graph tracer option
sleep-time be per instance") from Nov 14, 2025 (linux-next), leads to
the following Smatch static checker warning:

    kernel/trace/trace_functions_graph.c:1649 func_graph_set_flag()
    warn: unsigned 'fgraph_no_sleep_time' is never less than zero.

    kernel/trace/trace_functions_graph.c:1671 func_graph_set_flag()
    warn: unsigned 'fgraph_no_sleep_time' is never less than zero.

kernel/trace/trace_functions_graph.c
    1637 static int
    1638 func_graph_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
    1639 {
    1640 /*
    1641  * The function profiler gets updated even if function graph
    1642  * isn't the current tracer. Handle it separately.
    1643  */
    1644 #ifdef CONFIG_FUNCTION_PROFILER
    1645         if (bit == TRACE_GRAPH_SLEEP_TIME && (tr->flags & TRACE_ARRAY_FL_GLOBAL) &&
    1646             !!set == fprofile_no_sleep_time) {
    1647                 if (set) {
    1648                         fgraph_no_sleep_time--;
--> 1649                         if (WARN_ON_ONCE(fgraph_no_sleep_time < 0))
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^
Impossible.  Unsigned.

    1650                                 fgraph_no_sleep_time = 0;
    1651                         fprofile_no_sleep_time = false;
    1652                 } else {
    1653                         fgraph_no_sleep_time++;
    1654                         fprofile_no_sleep_time = true;
    1655                 }
    1656         }
    1657 #endif
    1658 
    1659         /* Do nothing if the current tracer is not this tracer */
    1660         if (tr->current_trace != &graph_trace)
    1661                 return 0;
    1662 
    1663         /* Do nothing if already set. */
    1664         if (!!set == !!(tr->current_trace_flags->val & bit))
    1665                 return 0;
    1666 
    1667         switch (bit) {
    1668         case TRACE_GRAPH_SLEEP_TIME:
    1669                 if (set) {
    1670                         fgraph_no_sleep_time--;
    1671                         if (WARN_ON_ONCE(fgraph_no_sleep_time < 0))
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^
Same.

    1672                                 fgraph_no_sleep_time = 0;
    1673                 } else {
    1674                         fgraph_no_sleep_time++;
    1675                 }
    1676                 break;
    1677 
    1678         case TRACE_GRAPH_PRINT_IRQS:
    1679                 if (set)
    1680                         ftrace_graph_skip_irqs--;
    1681                 else
    1682                         ftrace_graph_skip_irqs++;
    1683                 if (WARN_ON_ONCE(ftrace_graph_skip_irqs < 0))
    1684                         ftrace_graph_skip_irqs = 0;
    1685                 break;
    1686 
    1687         case TRACE_GRAPH_ARGS:
    1688                 return ftrace_graph_trace_args(tr, set);
    1689         }
    1690 
    1691         return 0;
    1692 }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-11-19  7:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-19  7:31 [bug report] tracing: Have function graph tracer option sleep-time be per instance Dan Carpenter

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