All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Cc: Vincent Donnefort <vdonnefort@google.com>,
	"Steven Rostedt (Google)" <rostedt@goodmis.org>
Subject: [PATCH 2/7] libtracefs: Have tracefs_mmap_read() include subbuf meta data
Date: Tue,  9 Jan 2024 21:51:46 -0500	[thread overview]
Message-ID: <20240110030116.81837-3-rostedt@goodmis.org> (raw)
In-Reply-To: <20240110030116.81837-1-rostedt@goodmis.org>

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

The tracefs_cpu_read() returns tracefs_mmap_read() when the tcpu is mapped.
But tracefs_cpu_read() is supposed to return the amount that was read, which
includes the sub-buffer meta data. But kbuffer_read_buffer() only returns
the amount of data that was read and does not include the sub-buffer meta
data.

Fixes: 2ed14b59 ("libtracefs: Add ring buffer memory mapping APIs")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 src/tracefs-mmap.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/tracefs-mmap.c b/src/tracefs-mmap.c
index 0f90f51e9339..f481bda37eaf 100644
--- a/src/tracefs-mmap.c
+++ b/src/tracefs-mmap.c
@@ -207,5 +207,10 @@ __hidden int trace_mmap_read(void *mapping, void *buffer)
 		return ret;
 
 	/* Update the buffer */
-	return kbuffer_read_buffer(kbuf, buffer, tmap->map->subbuf_size);
+	ret = kbuffer_read_buffer(kbuf, buffer, tmap->map->subbuf_size);
+	if (ret <= 0)
+		return ret;
+
+	/* This needs to include the size of the meta data too */
+	return ret + kbuffer_start_of_data(kbuf);
 }
-- 
2.43.0


  parent reply	other threads:[~2024-01-10  3:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-10  2:51 [PATCH 0/7] libtracefs: More fixes for memory mapping ring buffer API Steven Rostedt
2024-01-10  2:51 ` [PATCH 1/7] libtracefs: Have mapping work with the other tracefs_cpu* functions Steven Rostedt
2024-01-10  2:51 ` Steven Rostedt [this message]
2024-01-10  2:51 ` [PATCH 3/7] libtracefs: Have nonblock tracefs_cpu reads set errno EAGAIN Steven Rostedt
2024-01-10  2:51 ` [PATCH 4/7] libtracefs: Fix tracefs_mmap() kbuf usage Steven Rostedt
2024-01-10  2:51 ` [PATCH 5/7] libtracefs: Call mmap ioctl if a refresh happens Steven Rostedt
2024-01-10  2:51 ` [PATCH 6/7] libtracefs: Add tracefs_mapped_is_supported() API Steven Rostedt
2024-01-10  2:51 ` [PATCH 7/7] libtracefs utest: Add tests to use mapping if supported Steven Rostedt

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=20240110030116.81837-3-rostedt@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=vdonnefort@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.