Skip to contentSkip to conversation

libtracecmd: Fix free_zpage() offset

PATCH New Steven Rostedt 1 participant 1 message Jan 11, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libtracecmd: Fix free_zpage() offset

From: "Steven Rostedt (Google)" <[email protected]>

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()")
---
 lib/trace-cmd/trace-input.c | 2 ++
 1 file changed, 2 insertions(+)
lib/trace-cmd/trace-input.c +2 -0
index 88bef83f4fe0..e0194f89e5db 100644
@@ -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)
Signature · 1 line
2.43.0