Skip to contentSkip to conversation

ring-buffer/selftest: Meta-page testing improvements

PATCH RESEND In review Vincent Donnefort 3 participants 13 messages Sep 10, 2024 – Sep 11, 2024

Subsystems (3)
lore
Share & tools
lore

Vincent Donnefort

author maintainer
#0 lore raw

cover ring-buffer/selftest: Meta-page testing improvements

Following the comments on the original patch [1] here's a set of 2 patches to improve the selftest.

[1] https://lore.kernel.org/all/[email protected]/

Vincent Donnefort (2):
ring-buffer/selftest: Verify the entire meta-page padding ring-buffer/selftest: Handle meta-page bigger than the system

 tools/testing/selftests/ring-buffer/map_test.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

base-commit: 2fcd5aff92aab479a9a89cfce2dbc9c6a9455b4f

Signature · 1 line
2.46.0.598.g6f2099f65c-goog
author maintainer
#1 lore raw

PATCH RESEND 1/2 ring-buffer/selftest: Verify the entire meta-page padding

Improve the ring-buffer meta-page test coverage by checking for the entire padding region to be 0 instead of just looking at the first 4 bytes.

tools/testing/selftests/ring-buffer/map_test.c +4 -4
index 4bb0192e43f3..ba12fd31de87 100644
@@ -231,15 +231,15 @@ TEST_F(map, data_mmap)
 
 	/* Verify meta-page padding */
 	if (desc->meta->meta_page_size > getpagesize()) {
-		void *addr;
-
 		data_len = desc->meta->meta_page_size;
 		data = mmap(NULL, data_len,
 			    PROT_READ, MAP_SHARED, desc->cpu_fd, 0);
 		ASSERT_NE(data, MAP_FAILED);
 
-		addr = (void *)((unsigned long)data + getpagesize());
-		ASSERT_EQ(*((int *)addr), 0);
+		for (int i = desc->meta->meta_struct_len;
+		     i < desc->meta->meta_page_size; i += sizeof(int))
+			ASSERT_EQ(*(int *)(data + i), 0);
+
 		munmap(data, data_len);
 	}
 }
Signature · 1 line
2.46.0.598.g6f2099f65c-goog
maintainer Acked-by on v1 1/2
#2 lore raw

Re: [PATCH RESEND 1/2] ring-buffer/selftest: Verify the entire meta-page padding

Shuah,

Can you take this through your tree?

-- Steve

Quoted 32 lines · On Tue, 10 Sep 2024 17:23:34 +0100 Vincent Donnefort <[email protected]>…

Improve the ring-buffer meta-page test coverage by checking for the entire padding region to be 0 instead of just looking at the first 4 bytes.

tools/testing/selftests/ring-buffer/map_test.c +4 -4
index 4bb0192e43f3..ba12fd31de87 100644
@@ -231,15 +231,15 @@ TEST_F(map, data_mmap)
 
 	/* Verify meta-page padding */
 	if (desc->meta->meta_page_size > getpagesize()) {
-		void *addr;
-
 		data_len = desc->meta->meta_page_size;
 		data = mmap(NULL, data_len,
 			    PROT_READ, MAP_SHARED, desc->cpu_fd, 0);
 		ASSERT_NE(data, MAP_FAILED);
 
-		addr = (void *)((unsigned long)data + getpagesize());
-		ASSERT_EQ(*((int *)addr), 0);
+		for (int i = desc->meta->meta_struct_len;
+		     i < desc->meta->meta_page_size; i += sizeof(int))
+			ASSERT_EQ(*(int *)(data + i), 0);
+
 		munmap(data, data_len);
 	}
 }
maintainer
#3 lore raw

Re: [PATCH RESEND 1/2] ring-buffer/selftest: Verify the entire meta-page padding

Quoted 6 lines · Steven Rostedt

Shuah,

Can you take this through your tree?

I can take this through my tree.

Quoted 14 lines

-- Steve

Quoted 7 lines · On Tue, 10 Sep 2024 17:23:34 +0100 Vincent Donnefort <[email protected]>…

Improve the ring-buffer meta-page test coverage by checking for the entire padding region to be 0 instead of just looking at the first 4 bytes.

Vincent,

Can you please rebase these on linux-kselftest next branch and resend. This patch doesn't apply.

Also please fix the subject to say:

selfttests/ring-buffer

author maintainer
#4 lore raw

Re: [PATCH RESEND 1/2] ring-buffer/selftest: Verify the entire meta-page padding

Quoted 25 lines · Shuah Khan
Quoted 6 lines · Steven Rostedt

Shuah,

Can you take this through your tree?

I can take this through my tree.

Quoted 14 lines

-- Steve

Quoted 7 lines · On Tue, 10 Sep 2024 17:23:34 +0100 Vincent Donnefort <[email protected]>…

Improve the ring-buffer meta-page test coverage by checking for the entire padding region to be 0 instead of just looking at the first 4 bytes.

Quoted 8 lines

Vincent,

Can you please rebase these on linux-kselftest next branch and resend. This patch doesn't apply.

Also please fix the subject to say:

selfttests/ring-buffer

Will do, but it depends linux-trace/ring-buffer/for-next which hasn't make it yet to linux-next.

maintainer Acked-by
#5 lore raw

Re: [PATCH RESEND 1/2] ring-buffer/selftest: Verify the entire meta-page padding

Quoted 31 lines · Vincent Donnefort
Quoted 30 lines · Shuah Khan
Quoted 6 lines · Steven Rostedt

Shuah,

Can you take this through your tree?

I can take this through my tree.

Quoted 14 lines

-- Steve

Quoted 7 lines · On Tue, 10 Sep 2024 17:23:34 +0100 Vincent Donnefort <[email protected]>…

Improve the ring-buffer meta-page test coverage by checking for the entire padding region to be 0 instead of just looking at the first 4 bytes.

Vincent,

Can you please rebase these on linux-kselftest next branch and resend. This patch doesn't apply.

Quoted 6 lines
Quoted 3 lines

Also please fix the subject to say:

selfttests/ring-buffer

Will do, but it depends linux-trace/ring-buffer/for-next which hasn't make it yet to linux-next.

In which case it has to go through tracing tree.

Steve, This is yours to take due to the dependency on linux-trace/ring-buffer/for-next

thanks,
-- Shuah

maintainer
#6 lore raw

Re: [PATCH RESEND 1/2] ring-buffer/selftest: Verify the entire meta-page padding

In reply to Vincent Donnefort
Quoted 4 lines · On Wed, 11 Sep 2024 08:52:11 +0100 Vincent Donnefort <[email protected]>…
Quoted 1 line

selfttests/ring-buffer

Will do, but it depends linux-trace/ring-buffer/for-next which hasn't make it yet to linux-next.

Ah, I missed that you updated the selftest in one of your other patches.

That should have been a separate patch, as it works with the current upstream code (just tested it against 6.11-rc7). That's my fault for missing it in the review.

And after applying these changes on top of it, 6.11-rc7 still works as well.

But since it's in for-next, might as well keep it there as the merge window is about to open.

-- Steve

author maintainer
#7 lore raw

PATCH RESEND 2/2 ring-buffer/selftest: Handle meta-page bigger than the system

In reply to Vincent Donnefort

Handle the case where the meta-page content is bigger than the system page-size. This prepares the ground for extending features covered by the meta-page.

tools/testing/selftests/ring-buffer/map_test.c +10 -0
index ba12fd31de87..d10a847130fb 100644
@@ -92,12 +92,22 @@ int tracefs_cpu_map(struct tracefs_cpu_map_desc *desc, int cpu)
 	if (desc->cpu_fd < 0)
 		return -ENODEV;
 
+again:
 	map = mmap(NULL, page_size, PROT_READ, MAP_SHARED, desc->cpu_fd, 0);
 	if (map == MAP_FAILED)
 		return -errno;
 
 	desc->meta = (struct trace_buffer_meta *)map;
 
+	/* the meta-page is bigger than the original mapping */
+	if (page_size < desc->meta->meta_struct_len) {
+		int meta_page_size = desc->meta->meta_page_size;
+
+		munmap(desc->meta, page_size);
+		page_size = meta_page_size;
+		goto again;
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.46.0.598.g6f2099f65c-goog
maintainer Acked-by on v1 2/2
#8 lore raw

Re: [PATCH RESEND 2/2] ring-buffer/selftest: Handle meta-page bigger than the system

Shuah,

Can you take this through your tree?

-- Steve

Quoted 35 lines · On Tue, 10 Sep 2024 17:23:35 +0100 Vincent Donnefort <[email protected]>…

Handle the case where the meta-page content is bigger than the system page-size. This prepares the ground for extending features covered by the meta-page.

tools/testing/selftests/ring-buffer/map_test.c +10 -0
index ba12fd31de87..d10a847130fb 100644
@@ -92,12 +92,22 @@ int tracefs_cpu_map(struct tracefs_cpu_map_desc *desc, int cpu)
 	if (desc->cpu_fd < 0)
 		return -ENODEV;
 
+again:
 	map = mmap(NULL, page_size, PROT_READ, MAP_SHARED, desc->cpu_fd, 0);
 	if (map == MAP_FAILED)
 		return -errno;
 
 	desc->meta = (struct trace_buffer_meta *)map;
 
+	/* the meta-page is bigger than the original mapping */
+	if (page_size < desc->meta->meta_struct_len) {
+		int meta_page_size = desc->meta->meta_page_size;
+
+		munmap(desc->meta, page_size);
+		page_size = meta_page_size;
+		goto again;
+	}
+
 	return 0;
 }
 
maintainer
#9 lore raw

Re: [PATCH RESEND 2/2] ring-buffer/selftest: Handle meta-page bigger than the system

Quoted 6 lines · Steven Rostedt

Shuah,

Can you take this through your tree?

Yes I can take it through my tree.

Quoted 13 lines

-- Steve

Quoted 7 lines · On Tue, 10 Sep 2024 17:23:35 +0100 Vincent Donnefort <[email protected]>…

Handle the case where the meta-page content is bigger than the system page-size. This prepares the ground for extending features covered by the meta-page.

Vincent,

Can you please rebase these on linux-kselftest next branch and resend. This patch doesn't apply.

Also please fix the subject to say:

selfttests/ring-buffer

thanks,
-- Shuah

maintainer Acked-by
#10 lore raw

Re: [PATCH RESEND 2/2] ring-buffer/selftest: Handle meta-page bigger than the system

Quoted 24 lines · Shuah Khan
Quoted 6 lines · Steven Rostedt

Shuah,

Can you take this through your tree?

Yes I can take it through my tree.

Quoted 13 lines

-- Steve

Quoted 7 lines · On Tue, 10 Sep 2024 17:23:35 +0100 Vincent Donnefort <[email protected]>…

Handle the case where the meta-page content is bigger than the system page-size. This prepares the ground for extending features covered by the meta-page.

Quoted 8 lines

Vincent,

Can you please rebase these on linux-kselftest next branch and resend. This patch doesn't apply.

Also please fix the subject to say:

selfttests/ring-buffer

Once this is fixed:

Steve, This is yours to take due to the dependency on linux-trace/ring-buffer/for-next

thanks,
-- Shuah

maintainer
#11 lore raw

Re: [PATCH RESEND 2/2] ring-buffer/selftest: Handle meta-page bigger than the system

Quoted 5 lines · On Wed, 11 Sep 2024 10:07:40 -0600 Shuah Khan <[email protected]> wrote:

Once this is fixed:

Steve, This is yours to take due to the dependency on linux-trace/ring-buffer/for-next

Thanks, I'll add it to my for-next queue.

-- Steve

maintainer
#12 lore raw
In reply to Vincent Donnefort
Quoted 9 lines · On Tue, 10 Sep 2024 17:23:33 +0100 Vincent Donnefort <[email protected]>…

Following the comments on the original patch [1] here's a set of 2 patches to improve the selftest.

[1] https://lore.kernel.org/all/[email protected]/

Vincent Donnefort (2):
ring-buffer/selftest: Verify the entire meta-page padding ring-buffer/selftest: Handle meta-page bigger than the system

Quoted 5 lines
 tools/testing/selftests/ring-buffer/map_test.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

base-commit: 2fcd5aff92aab479a9a89cfce2dbc9c6a9455b4f

Ah, you just Cc'd the patches. OK, I can work with that.

-- Steve