Skip to contentSkip to conversation

tracing: Final updates for 6.4

PATCH New Steven Rostedt 1 participant 4 messages Jun 23, 2023

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover tracing: Final updates for 6.4

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: 131966049074b8025a8cba0e99d3745311fcef5b

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 | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
author maintainer
#1 lore raw

PATCH 1/3 tracing/user_events: Fix incorrect return value for writing operation when events are disabled

From: sunliming <[email protected]>

The writing operation return the count of writes regardless of whether events are enabled or disabled. Switch it to return 0 to indicates that the event is disabled.

---
 kernel/trace/trace_events_user.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/trace_events_user.c +2 -1
index 8df0550415e7..902cae005df4 100644
@@ -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 0;
 
 	return ret;
 }
Signature · 1 line
2.39.2
author maintainer
#2 lore raw

PATCH 2/3 selftests/user_events: Enable the event before write_fault test in ftrace self-test

In reply to Steven Rostedt

From: sunliming <[email protected]>

The user_event has not been enabled in write_fault test in ftrace self-test, Just enable it.

---
 tools/testing/selftests/user_events/ftrace_test.c | 4 ++++
 1 file changed, 4 insertions(+)
tools/testing/selftests/user_events/ftrace_test.c +4 -0
index eb6904d89f14..88898749e5b7 100644
@@ -400,6 +400,10 @@ TEST_F(user, write_fault) {
 	ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSREG, &reg));
 	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));
 
Signature · 1 line
2.39.2
author maintainer
#3 lore raw

PATCH 3/3 selftests/user_events: Add test cases when event is disabled

In reply to Steven Rostedt

From: sunliming <[email protected]>

When user_events are disabled, its write operation should return zero. Add this test cases.

---
 tools/testing/selftests/user_events/ftrace_test.c | 3 +++
 1 file changed, 3 insertions(+)
tools/testing/selftests/user_events/ftrace_test.c +3 -0
index 88898749e5b7..f42a20520175 100644
@@ -324,6 +324,9 @@ TEST_F(user, write_events) {
 	io[0].iov_base = &reg.write_index;
 	io[0].iov_len = sizeof(reg.write_index);
 
+	/* Write should return zero when event is not enabled */
+	ASSERT_EQ(0, writev(self->data_fd, (const struct iovec *)io, 3));
+
 	/* Enable event */
 	self->enable_fd = open(enable_file, O_RDWR);
 	ASSERT_NE(-1, write(self->enable_fd, "1", sizeof("1")))
Signature · 1 line
2.39.2