diff mbox series

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

Message ID 20240910162335.2993310-2-vdonnefort@google.com (mailing list archive)
State Accepted
Commit 21ff365b5c88c0bf8447989aadb5d8fe401c9cfc
Headers show
Series [RESEND,1/2] ring-buffer/selftest: Verify the entire meta-page padding | expand

Commit Message

Vincent Donnefort Sept. 10, 2024, 4:23 p.m. UTC
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.

Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: linux-kselftest@vger.kernel.org
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>

Comments

Steven Rostedt Sept. 10, 2024, 4:45 p.m. UTC | #1
Shuah,

Can you take this through your tree?

Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>

-- Steve


On Tue, 10 Sep 2024 17:23:34 +0100
Vincent Donnefort <vdonnefort@google.com> wrote:

> 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.
> 
> Cc: Shuah Khan <skhan@linuxfoundation.org>
> Cc: linux-kselftest@vger.kernel.org
> Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
> 
> diff --git a/tools/testing/selftests/ring-buffer/map_test.c b/tools/testing/selftests/ring-buffer/map_test.c
> index 4bb0192e43f3..ba12fd31de87 100644
> --- a/tools/testing/selftests/ring-buffer/map_test.c
> +++ b/tools/testing/selftests/ring-buffer/map_test.c
> @@ -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);
>  	}
>  }
Shuah Khan Sept. 10, 2024, 6:49 p.m. UTC | #2
On 9/10/24 10:45, Steven Rostedt wrote:
> 
> Shuah,
> 
> Can you take this through your tree?
> 
> Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>

I can take this through my tree.

> 
> -- Steve
> 
> 
> On Tue, 10 Sep 2024 17:23:34 +0100
> Vincent Donnefort <vdonnefort@google.com> wrote:
> 
>> 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.
>>
>> Cc: Shuah Khan <skhan@linuxfoundation.org>
>> Cc: linux-kselftest@vger.kernel.org
>> Signed-off-by: Vincent Donnefort <vdonnefort@google.com>

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
Vincent Donnefort Sept. 11, 2024, 7:52 a.m. UTC | #3
On Tue, Sep 10, 2024 at 12:49:58PM -0600, Shuah Khan wrote:
> On 9/10/24 10:45, Steven Rostedt wrote:
> > 
> > Shuah,
> > 
> > Can you take this through your tree?
> > 
> > Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> 
> I can take this through my tree.
> 
> > 
> > -- Steve
> > 
> > 
> > On Tue, 10 Sep 2024 17:23:34 +0100
> > Vincent Donnefort <vdonnefort@google.com> wrote:
> > 
> > > 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.
> > > 
> > > Cc: Shuah Khan <skhan@linuxfoundation.org>
> > > Cc: linux-kselftest@vger.kernel.org
> > > Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
> 
> 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.
Shuah Khan Sept. 11, 2024, 4:05 p.m. UTC | #4
On 9/11/24 01:52, Vincent Donnefort wrote:
> On Tue, Sep 10, 2024 at 12:49:58PM -0600, Shuah Khan wrote:
>> On 9/10/24 10:45, Steven Rostedt wrote:
>>>
>>> Shuah,
>>>
>>> Can you take this through your tree?
>>>
>>> Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
>>
>> I can take this through my tree.
>>
>>>
>>> -- Steve
>>>
>>>
>>> On Tue, 10 Sep 2024 17:23:34 +0100
>>> Vincent Donnefort <vdonnefort@google.com> wrote:
>>>
>>>> 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.
>>>>
>>>> Cc: Shuah Khan <skhan@linuxfoundation.org>
>>>> Cc: linux-kselftest@vger.kernel.org
>>>> Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
>>
>> 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.

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

Acked-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah
Steven Rostedt Sept. 11, 2024, 4:20 p.m. UTC | #5
On Wed, 11 Sep 2024 08:52:11 +0100
Vincent Donnefort <vdonnefort@google.com> wrote:

> > 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
diff mbox series

Patch

diff --git a/tools/testing/selftests/ring-buffer/map_test.c b/tools/testing/selftests/ring-buffer/map_test.c
index 4bb0192e43f3..ba12fd31de87 100644
--- a/tools/testing/selftests/ring-buffer/map_test.c
+++ b/tools/testing/selftests/ring-buffer/map_test.c
@@ -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);
 	}
 }