public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vincent Donnefort <vdonnefort@google.com>
To: rostedt@goodmis.org
Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org,
	 linux-trace-kernel@vger.kernel.org,
	mathieu.desnoyers@efficios.com,  kernel-team@android.com,
	david@redhat.com,  Vincent Donnefort <vdonnefort@google.com>
Subject: [PATCH 2/2] ring-buffer/selftest: Handle meta-page bigger than the system
Date: Wed, 28 Aug 2024 16:40:40 +0100	[thread overview]
Message-ID: <20240828154040.2803428-2-vdonnefort@google.com> (raw)
In-Reply-To: <20240828154040.2803428-1-vdonnefort@google.com>

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.

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;
 }
 
-- 
2.46.0.295.g3b9ea8a38a-goog


  reply	other threads:[~2024-08-28 15:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-28 10:46 [PATCH v2] ring-buffer: Align meta-page to sub-buffers for improved TLB usage Vincent Donnefort
2024-07-15 18:59 ` Steven Rostedt
2024-08-21 15:56 ` Steven Rostedt
2024-08-28 15:40   ` [PATCH 1/2] ring-buffer/selftest: Verify the entire meta-page padding Vincent Donnefort
2024-08-28 15:40     ` Vincent Donnefort [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-09-10 14:43 [PATCH 0/2] ring-buffer/selftest: Meta-page testing improvements Vincent Donnefort
2024-09-10 14:43 ` [PATCH 2/2] ring-buffer/selftest: Handle meta-page bigger than the system Vincent Donnefort

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240828154040.2803428-2-vdonnefort@google.com \
    --to=vdonnefort@google.com \
    --cc=david@redhat.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox