* [for-linus][PATCH 1/3] tracing/user_events: Fix incorrect return value for writing operation when events are disabled
2023-06-28 12:54 [for-linus][PATCH 0/3] tracing: Final updates for 6.4+ Steven Rostedt
@ 2023-06-28 12:54 ` Steven Rostedt
2023-06-28 12:54 ` [for-linus][PATCH 2/3] selftests/user_events: Enable the event before write_fault test in ftrace self-test Steven Rostedt
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2023-06-28 12:54 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mark Rutland, Andrew Morton, Beau Belgrave,
sunliming
From: sunliming <sunliming@kylinos.cn>
The writing operation return the count of writes regardless of whether events
are enabled or disabled. Switch it to return -EBADF to indicates that the event
is disabled.
Link: https://lkml.kernel.org/r/20230626111344.19136-2-sunliming@kylinos.cn
Acked-by: Beau Belgrave <beaub@linux.microsoft.com>
Signed-off-by: sunliming <sunliming@kylinos.cn>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
kernel/trace/trace_events_user.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
index 8df0550415e7..09f7d9167b8e 100644
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -2096,7 +2096,8 @@ static ssize_t user_events_write_core(struct file *file, struct iov_iter *i)
if (unlikely(faulted))
return -EFAULT;
- }
+ } else
+ return -EBADF;
return ret;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* [for-linus][PATCH 2/3] selftests/user_events: Enable the event before write_fault test in ftrace self-test
2023-06-28 12:54 [for-linus][PATCH 0/3] tracing: Final updates for 6.4+ Steven Rostedt
2023-06-28 12:54 ` [for-linus][PATCH 1/3] tracing/user_events: Fix incorrect return value for writing operation when events are disabled Steven Rostedt
@ 2023-06-28 12:54 ` Steven Rostedt
2023-06-28 12:54 ` [for-linus][PATCH 3/3] selftests/user_events: Add test cases when event is disabled Steven Rostedt
2023-06-28 14:06 ` [for-linus][PATCH 0/3] tracing: Final updates for 6.4+ Steven Rostedt
3 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2023-06-28 12:54 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mark Rutland, Andrew Morton, Beau Belgrave,
sunliming
From: sunliming <sunliming@kylinos.cn>
The user_event has not be enabled in write_fault test in ftrace
self-test, Just enable it.
Link: https://lkml.kernel.org/r/20230626111344.19136-3-sunliming@kylinos.cn
Acked-by: Beau Belgrave <beaub@linux.microsoft.com>
Signed-off-by: sunliming <sunliming@kylinos.cn>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
tools/testing/selftests/user_events/ftrace_test.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/testing/selftests/user_events/ftrace_test.c b/tools/testing/selftests/user_events/ftrace_test.c
index eb6904d89f14..88898749e5b7 100644
--- a/tools/testing/selftests/user_events/ftrace_test.c
+++ b/tools/testing/selftests/user_events/ftrace_test.c
@@ -400,6 +400,10 @@ TEST_F(user, write_fault) {
ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSREG, ®));
ASSERT_EQ(0, reg.write_index);
+ /* Enable event */
+ self->enable_fd = open(enable_file, O_RDWR);
+ ASSERT_NE(-1, write(self->enable_fd, "1", sizeof("1")))
+
/* Write should work normally */
ASSERT_NE(-1, writev(self->data_fd, (const struct iovec *)io, 2));
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* [for-linus][PATCH 3/3] selftests/user_events: Add test cases when event is disabled
2023-06-28 12:54 [for-linus][PATCH 0/3] tracing: Final updates for 6.4+ Steven Rostedt
2023-06-28 12:54 ` [for-linus][PATCH 1/3] tracing/user_events: Fix incorrect return value for writing operation when events are disabled Steven Rostedt
2023-06-28 12:54 ` [for-linus][PATCH 2/3] selftests/user_events: Enable the event before write_fault test in ftrace self-test Steven Rostedt
@ 2023-06-28 12:54 ` Steven Rostedt
2023-06-28 14:06 ` [for-linus][PATCH 0/3] tracing: Final updates for 6.4+ Steven Rostedt
3 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2023-06-28 12:54 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mark Rutland, Andrew Morton, Beau Belgrave,
sunliming
From: sunliming <sunliming@kylinos.cn>
When user_events are disabled, it's write operation should return -EBADF.
Add this test cases.
Link: https://lkml.kernel.org/r/20230626111344.19136-4-sunliming@kylinos.cn
Acked-by: Beau Belgrave <beaub@linux.microsoft.com>
Signed-off-by: sunliming <sunliming@kylinos.cn>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
tools/testing/selftests/user_events/ftrace_test.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/testing/selftests/user_events/ftrace_test.c b/tools/testing/selftests/user_events/ftrace_test.c
index 88898749e5b7..5beb0aef1d81 100644
--- a/tools/testing/selftests/user_events/ftrace_test.c
+++ b/tools/testing/selftests/user_events/ftrace_test.c
@@ -324,6 +324,10 @@ TEST_F(user, write_events) {
io[0].iov_base = ®.write_index;
io[0].iov_len = sizeof(reg.write_index);
+ /* Write should return -EBADF when event is not enabled */
+ ASSERT_EQ(-1, writev(self->data_fd, (const struct iovec *)io, 3));
+ ASSERT_EQ(EBADF, errno);
+
/* Enable event */
self->enable_fd = open(enable_file, O_RDWR);
ASSERT_NE(-1, write(self->enable_fd, "1", sizeof("1")))
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [for-linus][PATCH 0/3] tracing: Final updates for 6.4+
2023-06-28 12:54 [for-linus][PATCH 0/3] tracing: Final updates for 6.4+ Steven Rostedt
` (2 preceding siblings ...)
2023-06-28 12:54 ` [for-linus][PATCH 3/3] selftests/user_events: Add test cases when event is disabled Steven Rostedt
@ 2023-06-28 14:06 ` Steven Rostedt
3 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2023-06-28 14:06 UTC (permalink / raw)
To: linux-kernel; +Cc: Masami Hiramatsu, Mark Rutland, Andrew Morton
On Wed, 28 Jun 2023 08:54:48 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> The user events write currently returns the size of what was suppose to be
> written when tracing is disabled and nothing was written. Instead, behave like
> trace_marker and return -EBADF, as that is what is returned if a file is opened
> for read only,
I accidentally sent this before it was ready to go (I was editing the
change log from the previous one) I didn't finish the above paragraph,
and was suppose to delete the below one.
That's because I was about to rush to a talk at EOSS, and hit save and
exit forgetting that sends the emails out! (I'm using quilt)
I'll finish it properly for when I do the proper pull request.
-- Steve
>
> Before user events become an ABI, fix the return value of the write
> operation when tracing is disabled. It should not return an error, but
> simply report it wrote zero bytes. Just like any other write operation
> that doesn't write but does not "fail".
>
> This also includes test cases for this use case.
>
> git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
> trace/urgent
>
> Head SHA1: e155047e53d25f09d055c08ae9d6c269520e90d8
>
>
> sunliming (3):
> tracing/user_events: Fix incorrect return value for writing operation when events are disabled
> selftests/user_events: Enable the event before write_fault test in ftrace self-test
> selftests/user_events: Add test cases when event is disabled
>
> ----
> kernel/trace/trace_events_user.c | 3 ++-
> tools/testing/selftests/user_events/ftrace_test.c | 8 ++++++++
> 2 files changed, 10 insertions(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 5+ messages in thread