All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Cc: "Steven Rostedt (Google)" <rostedt@goodmis.org>
Subject: [PATCH 1/3] trace-cmd library: Fix tracecmd_iterate_events_multi() CPU clean up
Date: Thu, 28 Dec 2023 22:10:13 -0500	[thread overview]
Message-ID: <20231229031138.68313-2-rostedt@goodmis.org> (raw)
In-Reply-To: <20231229031138.68313-1-rostedt@goodmis.org>

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

In tracecmd_iterate_events_multi(), the clean up code at the end of the
function that unlocks and frees the remaining records, iterated the CPUs via
a for loop of 0 through all_cpus. But the kbuffer_read_at_offset() function,
expects the CPU passed in to be that of the handle and not of all the
handles.

That is, if there are two trace.dat files being read, and one has 4 CPUs and
the other has 2, the "all_cpus" variable will be 6. When iterating at the
clean up, when it gets passed 3 (4 CPUs is represented by 0-3) it will then
go to 4 and then 5 for the 2 CPUs trace.dat file. Passing in 4 or 5 to
kbuffer_read_at_offset() will fail. It needs to use the local CPU count of
the trace.dat file.

Fixes: 7f0a59aef63c1 ("trace-cmd library: Have tracecmd_iterate_events() start where it left off")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 lib/trace-cmd/trace-input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 42c8312f8395..bf070f057ed0 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -3143,7 +3143,7 @@ int tracecmd_iterate_events_multi(struct tracecmd_input **handles,
 		offset = (int)(records[cpu].record->offset & (handle->page_size - 1));
 		free_next(handle, local_cpu);
 		/* Reset the buffer to read the cached record again */
-		kbuffer_read_at_offset(handle->cpu_data[cpu].kbuf, offset, NULL);
+		kbuffer_read_at_offset(handle->cpu_data[local_cpu].kbuf, offset, NULL);
 	}
 
 	free(records);
-- 
2.42.0


  reply	other threads:[~2023-12-29  3:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-29  3:10 [PATCH 0/3] trace-cmd library: Fixes and add a reset Steven Rostedt
2023-12-29  3:10 ` Steven Rostedt [this message]
2023-12-29  3:10 ` [PATCH 2/3] trace-cmd library: Add back setting errno to zero in tracecmd_stack_tracer_status() Steven Rostedt
2023-12-29  3:10 ` [PATCH 3/3] trace-cmd library: Add tracecmd_iterate_reset() 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=20231229031138.68313-2-rostedt@goodmis.org \
    --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 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.