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 2/3] libtracecmd: Do not free records at end of iterator
Date: Thu, 11 Jan 2024 17:15:37 -0500	[thread overview]
Message-ID: <20240111222201.154686-3-rostedt@goodmis.org> (raw)
In-Reply-To: <20240111222201.154686-1-rostedt@goodmis.org>

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

I'm not sure why the records that were saved in the "peek" were freed, as
they should be freed when the tracecmd_input is closed.

Remove the freeing of the "peek" records, as it should be unneeded.

This basically reverts:

  890855541 ("tracecmd library: Unlock records in tracecmd_iterate_events()")

And commits that simulated it.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 lib/trace-cmd/trace-input.c | 63 -------------------------------------
 1 file changed, 63 deletions(-)

diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 0dc3dbdc676a..bc937b0491d7 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -2854,19 +2854,6 @@ int tracecmd_iterate_events(struct tracecmd_input *handle,
 		}
 	} while (next_cpu >= 0 && ret == 0);
 
-	/* Need to unlock and free the records */
-	for (cpu = 0; cpu < handle->cpus; cpu++) {
-		int offset;
-
-		if (!records[cpu])
-			continue;
-
-		offset = (int)(records[cpu]->offset & (handle->page_size - 1));
-		free_next(handle, cpu);
-		/* Reset the buffer to read the cached record again */
-		kbuffer_read_at_offset(handle->cpu_data[cpu].kbuf, offset, NULL);
-	}
-
 	free(records);
 
 	return ret;
@@ -2909,25 +2896,6 @@ load_records(struct tracecmd_input *handle, int cpu,
 	return last_record;
 }
 
-static void free_last_record(struct tracecmd_input *handle, struct tep_record *record,
-			     int cpu)
-{
-	record->priv = handle->cpu_data[cpu].page;
-	tracecmd_free_record(record);
-}
-
-static void free_last_records(struct tracecmd_input *handle, struct tep_record *records,
-			      int cpu)
-{
-	struct tep_record *last_record;
-
-	while (records) {
-		last_record = records;
-		records = last_record->priv;
-		free_last_record(handle, last_record, cpu);
-	}
-}
-
 static void initialize_last_events(struct tracecmd_input *handle,
 				   struct tep_record **last_records,
 				   cpu_set_t *cpu_set, int cpu_size,
@@ -3062,20 +3030,6 @@ int tracecmd_iterate_events_reverse(struct tracecmd_input *handle,
 		}
 	} while (next_cpu >= 0 && ret == 0);
 
-	for (cpu = 0; cpu < max_cpus; cpu++) {
-		int offset;
-
-		/* Get the next record to set the index to. */
-		record = peek_last_event(handle, records, cpu);
-		if (!record)
-			continue;
-		/* Reset the buffer to read the cached record again */
-		offset = record->offset & (handle->page_size - 1);
-		free_last_records(handle, records[cpu], cpu);
-		/* Reset the buffer to read the cached record again */
-		kbuffer_read_at_offset(handle->cpu_data[cpu].kbuf, offset, NULL);
-	}
-
 	free(records);
 
 	return ret;
@@ -3164,23 +3118,6 @@ int tracecmd_iterate_events_multi(struct tracecmd_input **handles,
 
 	} while (next_cpu >= 0 && ret == 0);
 
-	/* Unlock and free the records */
-	for (cpu = 0; cpu < all_cpus; cpu++) {
-		int local_cpu;
-		int offset;
-
-		if (!records[cpu].record)
-			continue;
-
-		handle = records[cpu].handle;
-		local_cpu = cpu - handle->start_cpu;
-
-		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[local_cpu].kbuf, offset, NULL);
-	}
-
 	free(records);
 
 	return ret;
-- 
2.43.0


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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-11 22:15 [PATCH 0/3] libtracecmd: Fix iterators Steven Rostedt
2024-01-11 22:15 ` [PATCH 1/3] libtracecmd: Use cpu_data[cpu]->cpus and not ->max_cpu Steven Rostedt
2024-01-11 22:15 ` Steven Rostedt [this message]
2024-01-11 22:15 ` [PATCH 3/3] libtracecmd: Just save timestamps and not the records in iterators 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=20240111222201.154686-3-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.