summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Donnefort <vdonnefort@google.com>2024-09-10 17:23:35 +0100
committerSteven Rostedt (Google) <rostedt@goodmis.org>2024-09-11 12:25:12 -0400
commit75d7ff9aa0ae1a8d1b3f9c8c87dde3a4fbe9a2cf (patch)
treef9561ef09e56e3554909b87cbab60508c7017dce
parent21ff365b5c88c0bf8447989aadb5d8fe401c9cfc (diff)
selftests/ring-buffer: Handle meta-page bigger than the system
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 Link: https://lore.kernel.org/20240910162335.2993310-3-vdonnefort@google.com Acked-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r--tools/testing/selftests/ring-buffer/map_test.c10
1 files changed, 10 insertions, 0 deletions
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;
}