diff mbox series

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

Message ID 20240910162335.2993310-3-vdonnefort@google.com (mailing list archive)
State Accepted
Commit 75d7ff9aa0ae1a8d1b3f9c8c87dde3a4fbe9a2cf
Headers show
Series ring-buffer/selftest: Meta-page testing improvements | expand

Commit Message

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

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:35 +0100
Vincent Donnefort <vdonnefort@google.com> wrote:

> 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.
> 
> 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 ba12fd31de87..d10a847130fb 100644
> --- a/tools/testing/selftests/ring-buffer/map_test.c
> +++ b/tools/testing/selftests/ring-buffer/map_test.c
> @@ -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;
>  }
>
Shuah Khan Sept. 10, 2024, 6:50 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>

Yes I can take it through my tree.

> 
> -- Steve
> 
> On Tue, 10 Sep 2024 17:23:35 +0100
> Vincent Donnefort <vdonnefort@google.com> wrote:
> 
>> 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.
>>
>> 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

thanks,
-- Shuah
Shuah Khan Sept. 11, 2024, 4:07 p.m. UTC | #3
On 9/10/24 12:50, 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>
> 
> Yes I can take it through my tree.
> 
>>
>> -- Steve
>>
>> On Tue, 10 Sep 2024 17:23:35 +0100
>> Vincent Donnefort <vdonnefort@google.com> wrote:
>>
>>> 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.
>>>
>>> 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

Once this is fixed:

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:21 p.m. UTC | #4
On Wed, 11 Sep 2024 10:07:40 -0600
Shuah Khan <skhan@linuxfoundation.org> wrote:

> Once this is fixed:
> 
> 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, I'll add it to my for-next queue.

-- 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 ba12fd31de87..d10a847130fb 100644
--- a/tools/testing/selftests/ring-buffer/map_test.c
+++ b/tools/testing/selftests/ring-buffer/map_test.c
@@ -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;
 }