linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>, <zanussi@kernel.org>,
	Zheng Yejian <zhengyejian1@huawei.com>
Subject: [for-next][PATCH 17/25] tracing/hist: Fix issue of losting command info in error_log
Date: Sat, 10 Dec 2022 08:58:07 -0500	[thread overview]
Message-ID: <20221210135825.860445357@goodmis.org> (raw)
In-Reply-To: 20221210135750.425719934@goodmis.org

From: Zheng Yejian <zhengyejian1@huawei.com>

When input some constructed invalid 'trigger' command, command info
in 'error_log' are lost [1].

The root cause is that there is a path that event_hist_trigger_parse()
is recursely called once and 'last_cmd' which save origin command is
cleared, then later calling of hist_err() will no longer record origin
command info:

  event_hist_trigger_parse() {
    last_cmd_set()  // <1> 'last_cmd' save origin command here at first
    create_actions() {
      onmatch_create() {
        action_create() {
          trace_action_create() {
            trace_action_create_field_var() {
              create_field_var_hist() {
                event_hist_trigger_parse() {  // <2> recursely called once
                  hist_err_clear()  // <3> 'last_cmd' is cleared here
                }
                hist_err()  // <4> No longer find origin command!!!

Since 'glob' is empty string while running into the recurse call, we
can trickly check it and bypass the call of hist_err_clear() to solve it.

[1]
 # cd /sys/kernel/tracing
 # echo "my_synth_event int v1; int v2; int v3;" >> synthetic_events
 # echo 'hist:keys=pid' >> events/sched/sched_waking/trigger
 # echo "hist:keys=next_pid:onmatch(sched.sched_waking).my_synth_event(\
pid,pid1)" >> events/sched/sched_switch/trigger
 # cat error_log
[  8.405018] hist:sched:sched_switch: error: Couldn't find synthetic event
  Command:
hist:keys=next_pid:onmatch(sched.sched_waking).my_synth_event(pid,pid1)
                                                          ^
[  8.816902] hist:sched:sched_switch: error: Couldn't find field
  Command:
hist:keys=next_pid:onmatch(sched.sched_waking).my_synth_event(pid,pid1)
                          ^
[  8.816902] hist:sched:sched_switch: error: Couldn't parse field variable
  Command:
hist:keys=next_pid:onmatch(sched.sched_waking).my_synth_event(pid,pid1)
                          ^
[  8.999880] : error: Couldn't find field
  Command:
           ^
[  8.999880] : error: Couldn't parse field variable
  Command:
           ^
[  8.999880] : error: Couldn't find field
  Command:
           ^
[  8.999880] : error: Couldn't create histogram for field
  Command:
           ^

Link: https://lore.kernel.org/linux-trace-kernel/20221207135326.3483216-1-zhengyejian1@huawei.com

Cc: <mhiramat@kernel.org>
Cc: <zanussi@kernel.org>
Fixes: f404da6e1d46 ("tracing: Add 'last error' error facility for hist triggers")
Signed-off-by: Zheng Yejian <zhengyejian1@huawei.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace_events_hist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 8264b28d5a57..fcaf226b7744 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -6576,7 +6576,7 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,
 	if (se)
 		se->ref++;
  out:
-	if (ret == 0)
+	if (ret == 0 && glob[0])
 		hist_err_clear();
 
 	return ret;
-- 
2.35.1



  parent reply	other threads:[~2022-12-10 13:59 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-10 13:57 [for-next][PATCH 00/25] tracing: Updates for 6.2 Steven Rostedt
2022-12-10 13:57 ` [for-next][PATCH 01/25] tracing/user_events: Fix call print_fmt leak Steven Rostedt
2022-12-10 13:57 ` [for-next][PATCH 02/25] tracing: Update MAINTAINERS file for new patchwork and mailing list Steven Rostedt
2022-12-10 13:57 ` [for-next][PATCH 03/25] ftrace/x86: Add back ftrace_expected for ftrace bug reports Steven Rostedt
2022-12-10 13:57 ` [for-next][PATCH 04/25] tracing: Allow multiple hitcount values in histograms Steven Rostedt
2022-12-10 13:57 ` [for-next][PATCH 05/25] tracing: Add .percent suffix option to histogram values Steven Rostedt
2022-12-10 13:57 ` [for-next][PATCH 06/25] tracing: Add .graph suffix option to histogram value Steven Rostedt
2022-12-10 13:57 ` [for-next][PATCH 07/25] tracing: Add nohitcount option for suppressing display of raw hitcount Steven Rostedt
2022-12-10 13:57 ` [for-next][PATCH 08/25] tracing: docs: Update histogram doc for .percent/.graph and nohitcount Steven Rostedt
2022-12-10 13:57 ` [for-next][PATCH 09/25] trace/kprobe: remove duplicated calls of ring_buffer_event_data Steven Rostedt
2022-12-10 13:58 ` [for-next][PATCH 10/25] tracing/probes: Handle system names with hyphens Steven Rostedt
2022-12-10 13:58 ` [for-next][PATCH 11/25] tracing: Fix complicated dependency of CONFIG_TRACER_MAX_TRACE Steven Rostedt
2022-12-10 13:58 ` [for-next][PATCH 12/25] x86/mm/kmmio: Switch to arch_spin_lock() Steven Rostedt
2022-12-10 13:58 ` [for-next][PATCH 13/25] x86/mm/kmmio: Use rcu_read_lock_sched_notrace() Steven Rostedt
2022-12-10 17:47   ` Paul E. McKenney
2022-12-10 18:34     ` Steven Rostedt
2022-12-10 21:34       ` Paul E. McKenney
2022-12-10 22:32         ` Steven Rostedt
2022-12-11  5:52           ` Paul E. McKenney
2022-12-10 23:30       ` Thomas Gleixner
2022-12-10 23:55         ` Steven Rostedt
2022-12-12 10:51           ` Thomas Gleixner
2022-12-12 15:42             ` Steven Rostedt
2022-12-10 13:58 ` [for-next][PATCH 14/25] tracing/hist: Fix wrong return value in parse_action_params() Steven Rostedt
2022-12-10 13:58 ` [for-next][PATCH 15/25] tracing/hist: Fix out-of-bound write on action_data.var_ref_idx Steven Rostedt
2022-12-10 13:58 ` [for-next][PATCH 16/25] tracing: Fix issue of missing one synthetic field Steven Rostedt
2022-12-10 13:58 ` Steven Rostedt [this message]
2022-12-10 13:58 ` [for-next][PATCH 18/25] ring-buffer: Handle resize in early boot up Steven Rostedt
2022-12-10 13:58 ` [for-next][PATCH 19/25] tracing: remove unnecessary trace_trigger ifdef Steven Rostedt
2022-12-10 13:58 ` [for-next][PATCH 20/25] tracing/osnoise: Make osnoise_options static Steven Rostedt
2022-12-10 13:58 ` [for-next][PATCH 21/25] tracing: Fix some checker warnings Steven Rostedt
2022-12-10 13:58 ` [for-next][PATCH 22/25] Documentation/osnoise: Escape underscore of NO_ prefix Steven Rostedt
2022-12-10 13:58 ` [for-next][PATCH 23/25] tracing/osnoise: Add PANIC_ON_STOP option Steven Rostedt
2022-12-10 13:58 ` [for-next][PATCH 24/25] tracing/osnoise: Add preempt and/or irq disabled options Steven Rostedt
2022-12-10 13:58 ` [for-next][PATCH 25/25] Documentation/osnoise: Add osnoise/options documentation Steven Rostedt

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=20221210135825.860445357@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=zanussi@kernel.org \
    --cc=zhengyejian1@huawei.com \
    /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;
as well as URLs for NNTP newsgroup(s).