Skip to contentSkip to conversation

perf: remove unused functions

PATCH New David Ahern 2 participants 8 messages Mar 13, 2013 – Mar 21, 2013 perf events

lore
Share & tools
lore
#0 lore raw

cover perf: remove unused functions

Hi Arnaldo:

Going through my backlog of perf cleanup patches. These remove unused functions and then makes a sole callee static.

David Ahern (4):
perf: remove unused print_event function
perf: remove unused print_trace_event function
perf: remove unused perf_session__remove_thread
perf: move machine__remove_thread and make static

 tools/perf/util/machine.c           |   22 ++++++++++-----------
 tools/perf/util/machine.h           |    1 -
 tools/perf/util/session.c           |   12 ------------
 tools/perf/util/session.h           |    1 -
 tools/perf/util/trace-event-parse.c |   37 -----------------------------------
 tools/perf/util/trace-event.h       |    4 ----
 6 files changed, 11 insertions(+), 66 deletions(-)
Signature · 1 line
1.7.10.1
#1 lore raw

PATCH 1/4 perf: remove unused print_event function

---
 tools/perf/util/trace-event-parse.c |   24 ------------------------
 tools/perf/util/trace-event.h       |    3 ---
 2 files changed, 27 deletions(-)
tools/perf/util/trace-event-parse.c +0 -24
index 3aabcd6..8450bec 100644
@@ -196,30 +196,6 @@ void print_trace_event(struct pevent *pevent, int cpu, void *data, int size)
 	event_format__print(event, cpu, data, size);
 }
 
-void print_event(struct pevent *pevent, int cpu, void *data, int size,
-		 unsigned long long nsecs, char *comm)
-{
-	struct pevent_record record;
-	struct trace_seq s;
-	int pid;
-
-	pevent->latency_format = latency_format;
-
-	record.ts = nsecs;
-	record.cpu = cpu;
-	record.size = size;
-	record.data = data;
-	pid = pevent_data_pid(pevent, &record);
-
-	if (!pevent_pid_is_registered(pevent, pid))
-		pevent_register_comm(pevent, comm, pid);
-
-	trace_seq_init(&s);
-	pevent_print_event(pevent, &s, &record);
-	trace_seq_do_printf(&s);
-	printf("\n");
-}
-
 void parse_proc_kallsyms(struct pevent *pevent,
 			 char *file, unsigned int size __maybe_unused)
 {
tools/perf/util/trace-event.h +0 -3
index a55fd37..99f621f 100644
@@ -34,9 +34,6 @@ void print_trace_event(struct pevent *pevent, int cpu, void *data, int size);
 void event_format__print(struct event_format *event,
 			 int cpu, void *data, int size);
 
-void print_event(struct pevent *pevent, int cpu, void *data, int size,
-		 unsigned long long nsecs, char *comm);
-
 int parse_ftrace_file(struct pevent *pevent, char *buf, unsigned long size);
 int parse_event_file(struct pevent *pevent,
 		     char *buf, unsigned long size, char *sys);
Signature · 1 line
1.7.10.1
#2 lore raw

PATCH 2/4 perf: remove unused print_trace_event function

In reply to David Ahern
---
 tools/perf/util/trace-event-parse.c |   13 -------------
 tools/perf/util/trace-event.h       |    1 -
 2 files changed, 14 deletions(-)
tools/perf/util/trace-event-parse.c +0 -13
index 8450bec..4454835 100644
@@ -183,19 +183,6 @@ void event_format__print(struct event_format *event,
 	trace_seq_do_printf(&s);
 }
 
-void print_trace_event(struct pevent *pevent, int cpu, void *data, int size)
-{
-	int type = trace_parse_common_type(pevent, data);
-	struct event_format *event = pevent_find_event(pevent, type);
-
-	if (!event) {
-		warning("ug! no event found for type %d", type);
-		return;
-	}
-
-	event_format__print(event, cpu, data, size);
-}
-
 void parse_proc_kallsyms(struct pevent *pevent,
 			 char *file, unsigned int size __maybe_unused)
 {
tools/perf/util/trace-event.h +0 -1
index 99f621f..28ccde8 100644
@@ -30,7 +30,6 @@ enum {
 int bigendian(void);
 
 struct pevent *read_trace_init(int file_bigendian, int host_bigendian);
-void print_trace_event(struct pevent *pevent, int cpu, void *data, int size);
 void event_format__print(struct event_format *event,
 			 int cpu, void *data, int size);
 
Signature · 1 line
1.7.10.1
#3 lore raw

[tip:perf/core] perf tools: Remove unused tracing functions

perf tools: Remove unused tracing functions
Commit-ID:  eba7181d56da7e8198f0c70e3d7074bab47a5910
Gitweb:     http://git.kernel.org/tip/eba7181d56da7e8198f0c70e3d7074bab47a5910
Author:     David Ahern <[email protected]>
AuthorDate: Tue, 12 Mar 2013 23:07:26 -0600
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 15 Mar 2013 13:06:07 -0300

perf tools: Remove unused tracing functions

Leftovers from before libtraceevent integration.

---
 tools/perf/util/trace-event-parse.c | 37 -------------------------------------
 tools/perf/util/trace-event.h       |  4 ----
 2 files changed, 41 deletions(-)
tools/perf/util/trace-event-parse.c +0 -37
index 3aabcd6..4454835 100644
@@ -183,43 +183,6 @@ void event_format__print(struct event_format *event,
 	trace_seq_do_printf(&s);
 }
 
-void print_trace_event(struct pevent *pevent, int cpu, void *data, int size)
-{
-	int type = trace_parse_common_type(pevent, data);
-	struct event_format *event = pevent_find_event(pevent, type);
-
-	if (!event) {
-		warning("ug! no event found for type %d", type);
-		return;
-	}
-
-	event_format__print(event, cpu, data, size);
-}
-
-void print_event(struct pevent *pevent, int cpu, void *data, int size,
-		 unsigned long long nsecs, char *comm)
-{
-	struct pevent_record record;
-	struct trace_seq s;
-	int pid;
-
-	pevent->latency_format = latency_format;
-
-	record.ts = nsecs;
-	record.cpu = cpu;
-	record.size = size;
-	record.data = data;
-	pid = pevent_data_pid(pevent, &record);
-
-	if (!pevent_pid_is_registered(pevent, pid))
-		pevent_register_comm(pevent, comm, pid);
-
-	trace_seq_init(&s);
-	pevent_print_event(pevent, &s, &record);
-	trace_seq_do_printf(&s);
-	printf("\n");
-}
-
 void parse_proc_kallsyms(struct pevent *pevent,
 			 char *file, unsigned int size __maybe_unused)
 {
tools/perf/util/trace-event.h +0 -4
index a55fd37..28ccde8 100644
@@ -30,13 +30,9 @@ enum {
 int bigendian(void);
 
 struct pevent *read_trace_init(int file_bigendian, int host_bigendian);
-void print_trace_event(struct pevent *pevent, int cpu, void *data, int size);
 void event_format__print(struct event_format *event,
 			 int cpu, void *data, int size);
 
-void print_event(struct pevent *pevent, int cpu, void *data, int size,
-		 unsigned long long nsecs, char *comm);
-
 int parse_ftrace_file(struct pevent *pevent, char *buf, unsigned long size);
 int parse_event_file(struct pevent *pevent,
 		     char *buf, unsigned long size, char *sys);
#4 lore raw

PATCH 3/4 perf: remove unused perf_session__remove_thread

In reply to David Ahern
---
 tools/perf/util/session.c |   12 ------------
 tools/perf/util/session.h |    1 -
 2 files changed, 13 deletions(-)
tools/perf/util/session.c +0 -12
index bd85280b..ab265c2 100644
@@ -1365,18 +1365,6 @@ size_t perf_session__fprintf(struct perf_session *session, FILE *fp)
 	return machine__fprintf(&session->machines.host, fp);
 }
 
-void perf_session__remove_thread(struct perf_session *session,
-				 struct thread *th)
-{
-	/*
-	 * FIXME: This one makes no sense, we need to remove the thread from
-	 * the machine it belongs to, perf_session can have many machines, so
-	 * doing it always on ->machines.host is wrong.  Fix when auditing all
-	 * the 'perf kvm' code.
-	 */
-	machine__remove_thread(&session->machines.host, th);
-}
-
 struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
 					      unsigned int type)
 {
tools/perf/util/session.h +0 -1
index b5c0847..6b51d47 100644
@@ -72,7 +72,6 @@ void perf_event__attr_swap(struct perf_event_attr *attr);
 int perf_session__create_kernel_maps(struct perf_session *self);
 
 void perf_session__set_id_hdr_size(struct perf_session *session);
-void perf_session__remove_thread(struct perf_session *self, struct thread *th);
 
 static inline
 struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid)
Signature · 1 line
1.7.10.1
#5 lore raw

[tip:perf/core] perf session: Remove unused perf_session__remove_thread method

perf session: Remove unused perf_session__remove_thread method
Commit-ID:  c1ad050caad5fbff13fd2f54f49e184bd71de90d
Gitweb:     http://git.kernel.org/tip/c1ad050caad5fbff13fd2f54f49e184bd71de90d
Author:     David Ahern <[email protected]>
AuthorDate: Tue, 12 Mar 2013 23:07:27 -0600
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 15 Mar 2013 13:06:08 -0300

perf session: Remove unused perf_session__remove_thread method

Should have been removed on this changeset, that removed the last user of it:

743eb868657bdb1b26c7b24077ca21c67c82c777

perf tools: Resolve machine earlier and pass it to perf_event_ops

---
 tools/perf/util/session.c | 12 ------------
 tools/perf/util/session.h |  1 -
 2 files changed, 13 deletions(-)
tools/perf/util/session.c +0 -12
index bd85280b..ab265c2 100644
@@ -1365,18 +1365,6 @@ size_t perf_session__fprintf(struct perf_session *session, FILE *fp)
 	return machine__fprintf(&session->machines.host, fp);
 }
 
-void perf_session__remove_thread(struct perf_session *session,
-				 struct thread *th)
-{
-	/*
-	 * FIXME: This one makes no sense, we need to remove the thread from
-	 * the machine it belongs to, perf_session can have many machines, so
-	 * doing it always on ->machines.host is wrong.  Fix when auditing all
-	 * the 'perf kvm' code.
-	 */
-	machine__remove_thread(&session->machines.host, th);
-}
-
 struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
 					      unsigned int type)
 {
tools/perf/util/session.h +0 -1
index b5c0847..6b51d47 100644
@@ -72,7 +72,6 @@ void perf_event__attr_swap(struct perf_event_attr *attr);
 int perf_session__create_kernel_maps(struct perf_session *self);
 
 void perf_session__set_id_hdr_size(struct perf_session *session);
-void perf_session__remove_thread(struct perf_session *self, struct thread *th);
 
 static inline
 struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid)
#6 lore raw

PATCH 4/4 perf: move machine__remove_thread and make static

In reply to David Ahern
---
 tools/perf/util/machine.c |   22 +++++++++++-----------
 tools/perf/util/machine.h |    1 -
 2 files changed, 11 insertions(+), 12 deletions(-)
tools/perf/util/machine.c +11 -11
index efdb38e..c5e3b12 100644
@@ -1003,6 +1003,17 @@ int machine__process_fork_event(struct machine *machine, union perf_event *event
 	return 0;
 }
 
+static void machine__remove_thread(struct machine *machine, struct thread *th)
+{
+	machine->last_match = NULL;
+	rb_erase(&th->rb_node, &machine->threads);
+	/*
+	 * We may have references to this thread, for instance in some hist_entry
+	 * instances, so just move them to a separate list.
+	 */
+	list_add_tail(&th->node, &machine->dead_threads);
+}
+
 int machine__process_exit_event(struct machine *machine, union perf_event *event)
 {
 	struct thread *thread = machine__find_thread(machine, event->fork.tid);
@@ -1039,17 +1050,6 @@ int machine__process_event(struct machine *machine, union perf_event *event)
 	return ret;
 }
 
-void machine__remove_thread(struct machine *machine, struct thread *th)
-{
-	machine->last_match = NULL;
-	rb_erase(&th->rb_node, &machine->threads);
-	/*
-	 * We may have references to this thread, for instance in some hist_entry
-	 * instances, so just move them to a separate list.
-	 */
-	list_add_tail(&th->node, &machine->dead_threads);
-}
-
 static bool symbol__match_parent_regex(struct symbol *sym)
 {
 	if (sym->name && !regexec(&parent_regex, sym->name, 0, NULL, 0))
tools/perf/util/machine.h +0 -1
index 5ac5892..e0b2c00 100644
@@ -97,7 +97,6 @@ static inline bool machine__is_host(struct machine *machine)
 }
 
 struct thread *machine__findnew_thread(struct machine *machine, pid_t pid);
-void machine__remove_thread(struct machine *machine, struct thread *th);
 
 size_t machine__fprintf(struct machine *machine, FILE *fp);
 
Signature · 1 line
1.7.10.1
#7 lore raw

[tip:perf/core] perf machine: Move machine__remove_thread and make static

perf machine: Move machine__remove_thread and make static
Commit-ID:  ed8996a6d59b9eb00a50d7d30887ba9f28eb4bb0
Gitweb:     http://git.kernel.org/tip/ed8996a6d59b9eb00a50d7d30887ba9f28eb4bb0
Author:     David Ahern <[email protected]>
AuthorDate: Tue, 12 Mar 2013 23:07:28 -0600
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 15 Mar 2013 13:06:08 -0300

perf machine: Move machine__remove_thread and make static

As the now only user, machine__process_exit_event, that is what tools use to process PERF_RECORD_EXIT events, is on the same object file.

---
 tools/perf/util/machine.c | 22 +++++++++++-----------
 tools/perf/util/machine.h |  1 -
 2 files changed, 11 insertions(+), 12 deletions(-)
tools/perf/util/machine.c +11 -11
index efdb38e..c5e3b12 100644
@@ -1003,6 +1003,17 @@ int machine__process_fork_event(struct machine *machine, union perf_event *event
 	return 0;
 }
 
+static void machine__remove_thread(struct machine *machine, struct thread *th)
+{
+	machine->last_match = NULL;
+	rb_erase(&th->rb_node, &machine->threads);
+	/*
+	 * We may have references to this thread, for instance in some hist_entry
+	 * instances, so just move them to a separate list.
+	 */
+	list_add_tail(&th->node, &machine->dead_threads);
+}
+
 int machine__process_exit_event(struct machine *machine, union perf_event *event)
 {
 	struct thread *thread = machine__find_thread(machine, event->fork.tid);
@@ -1039,17 +1050,6 @@ int machine__process_event(struct machine *machine, union perf_event *event)
 	return ret;
 }
 
-void machine__remove_thread(struct machine *machine, struct thread *th)
-{
-	machine->last_match = NULL;
-	rb_erase(&th->rb_node, &machine->threads);
-	/*
-	 * We may have references to this thread, for instance in some hist_entry
-	 * instances, so just move them to a separate list.
-	 */
-	list_add_tail(&th->node, &machine->dead_threads);
-}
-
 static bool symbol__match_parent_regex(struct symbol *sym)
 {
 	if (sym->name && !regexec(&parent_regex, sym->name, 0, NULL, 0))
tools/perf/util/machine.h +0 -1
index 5ac5892..e0b2c00 100644
@@ -97,7 +97,6 @@ static inline bool machine__is_host(struct machine *machine)
 }
 
 struct thread *machine__findnew_thread(struct machine *machine, pid_t pid);
-void machine__remove_thread(struct machine *machine, struct thread *th);
 
 size_t machine__fprintf(struct machine *machine, FILE *fp);