public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Beau Belgrave <beaub@linux.microsoft.com>,
	sunliming <sunliming@kylinos.cn>
Subject: [for-linus][PATCH 07/15] selftests/user_events: Clear the events after perf self-test
Date: Thu, 15 Jun 2023 09:05:38 -0400	[thread overview]
Message-ID: <20230615133416.089967064@goodmis.org> (raw)
In-Reply-To: 20230615130531.200384328@goodmis.org

From: sunliming <sunliming@kylinos.cn>

When the self test is completed, perf self-test left the user events not to
be cleared. Clear the events by unregister and delete the event.

Link: https://lkml.kernel.org/r/20230606062027.1008398-4-sunliming@kylinos.cn

Acked-by: Beau Belgrave <beaub@linux.microsoft.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: sunliming <sunliming@kylinos.cn>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 .../testing/selftests/user_events/perf_test.c | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/tools/testing/selftests/user_events/perf_test.c b/tools/testing/selftests/user_events/perf_test.c
index a070258d4449..e97f24ab6e2f 100644
--- a/tools/testing/selftests/user_events/perf_test.c
+++ b/tools/testing/selftests/user_events/perf_test.c
@@ -81,6 +81,32 @@ static int get_offset(void)
 	return offset;
 }
 
+static int clear(int *check)
+{
+	struct user_unreg unreg = {0};
+
+	unreg.size = sizeof(unreg);
+	unreg.disable_bit = 31;
+	unreg.disable_addr = (__u64)check;
+
+	int fd = open(data_file, O_RDWR);
+
+	if (fd == -1)
+		return -1;
+
+	if (ioctl(fd, DIAG_IOCSUNREG, &unreg) == -1)
+		if (errno != ENOENT)
+			return -1;
+
+	if (ioctl(fd, DIAG_IOCSDEL, "__test_event") == -1)
+		if (errno != ENOENT)
+			return -1;
+
+	close(fd);
+
+	return 0;
+}
+
 FIXTURE(user) {
 	int data_fd;
 	int check;
@@ -93,6 +119,9 @@ FIXTURE_SETUP(user) {
 
 FIXTURE_TEARDOWN(user) {
 	close(self->data_fd);
+
+	if (clear(&self->check) != 0)
+		printf("WARNING: Clear didn't work!\n");
 }
 
 TEST_F(user, perf_write) {
-- 
2.39.2

  parent reply	other threads:[~2023-06-15 13:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-15 13:05 [for-linus][PATCH 00/15] tracing: Updates for 6.4 Steven Rostedt
2023-06-15 13:05 ` [for-linus][PATCH 01/15] tracing/rv/rtla: Update MAINTAINERS file to point to proper mailing list Steven Rostedt
2023-06-15 13:05 ` [for-linus][PATCH 02/15] tracing/user_events: Prevent same name but different args event Steven Rostedt
2023-06-15 13:05 ` [for-linus][PATCH 03/15] tracing/user_events: Handle matching arguments that is null from dyn_events Steven Rostedt
2023-06-15 13:05 ` [for-linus][PATCH 04/15] tracing: Modify print_fields() for fields output order Steven Rostedt
2023-06-15 13:05 ` [for-linus][PATCH 05/15] tracing/user_events: Fix the incorrect trace record for empty arguments events Steven Rostedt
2023-06-15 13:05 ` [for-linus][PATCH 06/15] selftests/user_events: Add ftrace self-test " Steven Rostedt
2023-06-15 13:05 ` Steven Rostedt [this message]
2023-06-15 13:05 ` [for-linus][PATCH 08/15] selftests/user_events: Add perf " Steven Rostedt
2023-06-15 13:05 ` [for-linus][PATCH 09/15] tracing/user_events: Remove user_ns walk for groups Steven Rostedt
2023-06-15 13:05 ` [for-linus][PATCH 10/15] tracing/user_events: Store register flags on events Steven Rostedt
2023-06-15 13:05 ` [for-linus][PATCH 11/15] tracing/user_events: Track refcount consistently via put/get Steven Rostedt
2023-06-15 13:05 ` [for-linus][PATCH 12/15] tracing/user_events: Add auto cleanup and future persist flag Steven Rostedt
2023-06-15 13:05 ` [for-linus][PATCH 13/15] selftests/user_events: Ensure auto cleanup works as expected Steven Rostedt
2023-06-15 13:05 ` [for-linus][PATCH 14/15] selftests/user_events: Adapt dyn_test to non-persist events Steven Rostedt
2023-06-15 13:05 ` [for-linus][PATCH 15/15] tracing/user_events: Document auto-cleanup and remove dyn_event refs 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=20230615133416.089967064@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=beaub@linux.microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mhiramat@kernel.org \
    --cc=sunliming@kylinos.cn \
    /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