Skip to content

Commit 75d7ff9

Browse files
vdonnefortrostedt
authored andcommitted
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 <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/[email protected] Acked-by: Shuah Khan <[email protected]> Signed-off-by: Vincent Donnefort <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 21ff365 commit 75d7ff9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tools/testing/selftests/ring-buffer/map_test.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,22 @@ int tracefs_cpu_map(struct tracefs_cpu_map_desc *desc, int cpu)
9292
if (desc->cpu_fd < 0)
9393
return -ENODEV;
9494

95+
again:
9596
map = mmap(NULL, page_size, PROT_READ, MAP_SHARED, desc->cpu_fd, 0);
9697
if (map == MAP_FAILED)
9798
return -errno;
9899

99100
desc->meta = (struct trace_buffer_meta *)map;
100101

102+
/* the meta-page is bigger than the original mapping */
103+
if (page_size < desc->meta->meta_struct_len) {
104+
int meta_page_size = desc->meta->meta_page_size;
105+
106+
munmap(desc->meta, page_size);
107+
page_size = meta_page_size;
108+
goto again;
109+
}
110+
101111
return 0;
102112
}
103113

0 commit comments

Comments
 (0)