Skip to contentSkip to conversation

tracing: Fix synthetic event parser

PATCH In review Masami Hiramatsu 4 participants 10 messages Oct 21, 2018 – Oct 28, 2018

Subsystems (3)
lore
Share & tools
lore

Masami Hiramatsu

author maintainer
#0 lore raw

cover tracing: Fix synthetic event parser

Hi,

I found another bug in synthetic event. This is a small fix, but confusingly, there is also a bug in a test case.

Steve, since the testcase bugfix ([2/2]) breaks the test result unless corresponding fix ([1/2]), I would like to ask you to send these fixes from your tree.
Shuah, could you give this your ack?

Thank you,

---

Masami Hiramatsu (2):
tracing: Return -ENOENT if there is no target synthetic event selftests/ftrace: Fix synthetic event test to delete event correctly

 kernel/trace/trace_events_hist.c                   |    4 +++-
 .../trigger-synthetic-event-createremove.tc        |   12 ++++++------
 2 files changed, 9 insertions(+), 7 deletions(-)

--
Masami Hiramatsu (Linaro) <[email protected]>

author maintainer
#1 lore raw

PATCH 1/2 tracing: Return -ENOENT if there is no target synthetic event

Return -ENOENT error if there is no target synthetic event. This notices an operation failure to user as below;

  # echo 'wakeup_latency u64 lat; pid_t pid;' > synthetic_events
  # echo '!wakeup' >> synthetic_events
  sh: write error: No such file or directory
Fixes 4b147936fa50 ('tracing: Add support for 'synthetic' events')
Cc Tom Zanussi <[email protected]>
Cc Steven Rostedt <[email protected]>
---
 kernel/trace/trace_events_hist.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +3 -1
index d239004aaf29..eb908ef2ecec 100644
@@ -1063,8 +1063,10 @@ static int create_synth_event(int argc, char **argv)
 		event = NULL;
 		ret = -EEXIST;
 		goto out;
-	} else if (delete_event)
+	} else if (delete_event) {
+		ret = -ENOENT;
 		goto out;
+	}
 
 	if (argc < 2) {
 		ret = -EINVAL;
author maintainer
#2 lore raw

PATCH 2/2 selftests/ftrace: Fix synthetic event test to delete event correctly

In reply to Masami Hiramatsu

Fix the synthetic event test case to remove event correctly. If redirecting command to synthetic_event file without append mode, it cleans up all existing events and execute (parse) the command. This means "delete event" always fails to find the target event.

Since previous synthetic event has a bug which doesn't return -ENOENT even if it fails to find the deleting event, this test passed. But fixing that bug, this test fails because this test itself has a bug.

This fixes that bug by trying to delete event right after adding an event, and use append mode redirection ('>>') instead of normal redirection ('>').

Fixes f06eec4d0f2c ('selftests: ftrace: Add inter-event hist triggers testcases')
Cc Rajvi Jingar <[email protected]>
Cc Tom Zanussi <[email protected]>
Cc Shuah Khan <[email protected]>
Cc Steven Rostedt (VMware) <[email protected]>
---
 .../trigger-synthetic-event-createremove.tc        |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-createremove.tc +6 -6
index cef11377dcbd..c604438df13b 100644
@@ -35,18 +35,18 @@ fi
 
 reset_trigger
 
-echo "Test create synthetic event with an error"
-echo 'wakeup_latency  u64 lat pid_t pid char' > synthetic_events > /dev/null
+echo "Test remove synthetic event"
+echo '!wakeup_latency  u64 lat pid_t pid char comm[16]' >> synthetic_events
 if [ -d events/synthetic/wakeup_latency ]; then
-    fail "Created wakeup_latency synthetic event with an invalid format"
+    fail "Failed to delete wakeup_latency synthetic event"
 fi
 
 reset_trigger
 
-echo "Test remove synthetic event"
-echo '!wakeup_latency  u64 lat pid_t pid char comm[16]' > synthetic_events
+echo "Test create synthetic event with an error"
+echo 'wakeup_latency  u64 lat pid_t pid char' > synthetic_events > /dev/null
 if [ -d events/synthetic/wakeup_latency ]; then
-    fail "Failed to delete wakeup_latency synthetic event"
+    fail "Created wakeup_latency synthetic event with an invalid format"
 fi
 
 do_reset
Acked-by Tested-by on the v1 series
#3 lore raw
In reply to Masami Hiramatsu

Hi Masami,

Quoted 10 lines · Masami Hiramatsu

Hi,

I found another bug in synthetic event. This is a small fix, but confusingly, there is also a bug in a test case.

Steve, since the testcase bugfix ([2/2]) breaks the test result unless corresponding fix ([1/2]), I would like to ask you to send these fixes from your tree.
Shuah, could you give this your ack?

Yes, I think the silent failing mode is confusing to users, and so these changes make more sense.

Thanks,

Tom

Quoted 17 lines

Thank you,

---

Masami Hiramatsu (2):
tracing: Return -ENOENT if there is no target synthetic event selftests/ftrace: Fix synthetic event test to delete event
correctly

 kernel/trace/trace_events_hist.c                   |    4 +++-
 .../trigger-synthetic-event-createremove.tc        |   12 ++++++--
----
 2 files changed, 9 insertions(+), 7 deletions(-)

--
Masami Hiramatsu (Linaro) <[email protected]>

maintainer
#4 lore raw
In reply to Masami Hiramatsu
Quoted 8 lines · On Mon, 22 Oct 2018 00:07:50 +0900 Masami Hiramatsu <[email protected]> wrote:

Hi,

I found another bug in synthetic event. This is a small fix, but confusingly, there is also a bug in a test case.

Steve, since the testcase bugfix ([2/2]) breaks the test result unless corresponding fix ([1/2]), I would like to ask you to send these fixes from your tree.

Hi Masami,

I'm currently in travel mode, but I'm letting you know that I'll be working on these today. It might take a bit to get out.

I'll add them on top of my linux-next code, and include them in the pull request I'm hoping to do on Tuesday.

-- Steve

maintainer
#5 lore raw
Quoted 2 lines · On Sun, 28 Oct 2018 04:01:35 -0400 Steven Rostedt <[email protected]> wrote:

I'll add them on top of my linux-next code, and include them in the pull request I'm hoping to do on Tuesday.

Bah, I think this is on a different branch, and that will make it go as a separate pull. Anyway, it probably will still be on Tuesday where I push it to Linus.

-- Steve

maintainer Acked-by
#6 lore raw
Quoted 12 lines · Steven Rostedt
Quoted 2 lines · On Sun, 28 Oct 2018 04:01:35 -0400 Steven Rostedt <[email protected]> wrote:

I'll add them on top of my linux-next code, and include them in the pull request I'm hoping to do on Tuesday.

Bah, I think this is on a different branch, and that will make it go as a separate pull. Anyway, it probably will still be on Tuesday where I push it to Linus.

-- Steve

Here it is

thanks,
-- Shuah

maintainer
#8 lore raw
In reply to Steven Rostedt
Quoted 14 lines · Steven Rostedt
Quoted 8 lines · On Mon, 22 Oct 2018 00:07:50 +0900 Masami Hiramatsu <[email protected]> wrote:

Hi,

I found another bug in synthetic event. This is a small fix, but confusingly, there is also a bug in a test case.

Steve, since the testcase bugfix ([2/2]) breaks the test result unless corresponding fix ([1/2]), I would like to ask you to send these fixes from your tree.

Hi Masami,

Quoted 8 lines

I'm currently in travel mode, but I'm letting you know that I'll be working on these today. It might take a bit to get out.

I'll add them on top of my linux-next code, and include them in the pull request I'm hoping to do on Tuesday.

-- Steve

Hi Steve,

Are there any dependencies on my pull request I sent to Linus? It hasn't been pulled in yet. If there is one, could please you mention that in your pull request for this.

thanks,
-- Shuah

maintainer
#9 lore raw
Quoted 5 lines · On Sun, 28 Oct 2018 11:33:35 -0600 Shuah Khan <[email protected]> wrote:

Hi Steve,

Are there any dependencies on my pull request I sent to Linus? It hasn't been pulled in yet. If there is one, could please you mention that in your pull request for this.

There's no dependency on the patches you took. But if you could ack the selftest one that would be awesome.

Thanks,

-- Steve