Linux-Trace-Devel Archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: [PATCH] libtracecmd: Fix free_zpage() offset
Date: Thu, 11 Jan 2024 17:12:07 -0500	[thread overview]
Message-ID: <20240111171207.54d7cdbf@gandalf.local.home> (raw)

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

The offset exposed to the callers of libtracecmd is the uncompressed file
offset. The read_zpage() subtracts the fake uncompressed offset to get to
the compressed data offset.

The free_zpage() did not subtract the uncompressed offset so it was not
finding the cached compressed data it was looking for to free, and left the
page not freed.

Subtract the uncompressed file offset from the passed in offset to find the
cached node to free.

Fixes: add83e0c8b511 ("trace-cmd library: Fix tracecmd_read_at()")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 lib/trace-cmd/trace-input.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 88bef83f4fe0..e0194f89e5db 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -1384,6 +1384,8 @@ static void free_zpage(struct cpu_data *cpu_data, off_t offset)
 	struct trace_rbtree_node *node;
 	struct zchunk_cache *cache;
 
+	offset -= cpu_data->file_offset;
+
 	node = trace_rbtree_find(&cpu_data->compress.cache, (void *)&offset);
 
 	if (!node)
-- 
2.43.0


                 reply	other threads:[~2024-01-11 22:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240111171207.54d7cdbf@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).