public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-trace-kernel@vger.kernel.org
Subject: [bug report] tracing: Have function graph tracer option sleep-time be per instance
Date: Wed, 19 Nov 2025 10:31:17 +0300	[thread overview]
Message-ID: <aR1yRQxDmlfLZzoo@stanley.mountain> (raw)

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

                 reply	other threads:[~2025-11-19  7:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aR1yRQxDmlfLZzoo@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox