Skip to contentSkip to conversation

perf tools: Move event synthesizing routines to separate .c file

tip: perf/urgent tip-bot2 for Arnaldo Carvalho de Melo 1 participant 1 message Sep 20, 2019 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

tip-bot2 for Arnaldo Carvalho de Melo

author merge bot Applied
#1 lore raw

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     055c67ed39887c5563e9540470a4617c1b772aec
Gitweb:        https://git.kernel.org/tip/055c67ed39887c5563e9540470a4617c1b772aec
Author:        Arnaldo Carvalho de Melo <[email protected]>
AuthorDate:    Wed, 18 Sep 2019 16:08:52 -03:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Fri, 20 Sep 2019 10:28:21 -03:00

perf tools: Move event synthesizing routines to separate .c file

For better grouping, in time we may end up making most of these static, i.e. generalizing the 'perf record' synthesizing code so that based on the target it can do the right thing and call the needed synthesizers.

---
 tools/perf/builtin-record.c        |    9 +-
 tools/perf/util/Build              |    1 +-
 tools/perf/util/cs-etm.c           |    1 +-
 tools/perf/util/event.c            | 1108 +----------------
 tools/perf/util/evsel.c            |  278 +----
 tools/perf/util/header.c           |  393 +------
 tools/perf/util/header.h           |   18 +-
 tools/perf/util/machine.c          |   25 +-
 tools/perf/util/namespaces.c       |   18 +-
 tools/perf/util/namespaces.h       |    2 +-
 tools/perf/util/session.c          |   71 +-
 tools/perf/util/stat.c             |   43 +-
 tools/perf/util/synthetic-events.c | 1884 +++++++++++++++++++++++++++-
 13 files changed, 1928 insertions(+), 1923 deletions(-)
 create mode 100644 tools/perf/util/synthetic-events.c
tools/perf/builtin-record.c +0 -9
index 907d4d4..4bd11c9 100644
@@ -1181,15 +1181,6 @@ static void workload_exec_failed_signal(int signo __maybe_unused,
 static void snapshot_sig_handler(int sig);
 static void alarm_sig_handler(int sig);
 
-int __weak
-perf_event__synth_time_conv(const struct perf_event_mmap_page *pc __maybe_unused,
-			    struct perf_tool *tool __maybe_unused,
-			    perf_event__handler_t process __maybe_unused,
-			    struct machine *machine __maybe_unused)
-{
-	return 0;
-}
-
 static const struct perf_event_mmap_page *
 perf_evlist__pick_pc(struct evlist *evlist)
 {
tools/perf/util/Build +1 -0
index 0b4d8e0..fd89d6a 100644
@@ -86,6 +86,7 @@ perf-y += stat-display.o
 perf-y += record.o
 perf-y += srcline.o
 perf-y += srccode.o
+perf-y += synthetic-events.o
 perf-y += data.o
 perf-y += tsc.o
 perf-y += cloexec.o
tools/perf/util/cs-etm.c +1 -0
index f87b9c1..6021974 100644
@@ -35,6 +35,7 @@
 #include "thread.h"
 #include "thread-stack.h"
 #include <tools/libc_compat.h>
+#include "util/synthetic-events.h"
 
 #define MAX_TIMESTAMP (~0ULL)
 
tools/perf/util/event.c +1 -1107

1,150 lines not on this page · raw message

tools/perf/util/evsel.c +0 -278

290 lines not on this page · raw message

tools/perf/util/header.c +3 -390

448 lines not on this page · raw message

tools/perf/util/header.h +18 -0
index 999dac4..ca53a92 100644
@@ -92,6 +92,24 @@ struct perf_header {
 	struct perf_env 	env;
 };
 
+struct feat_fd {
+	struct perf_header *ph;
+	int		   fd;
+	void		   *buf;	/* Either buf != NULL or fd >= 0 */
+	ssize_t		   offset;
+	size_t		   size;
+	struct evsel	   *events;
+};
+
+struct perf_header_feature_ops {
+	int	   (*write)(struct feat_fd *ff, struct evlist *evlist);
+	void	   (*print)(struct feat_fd *ff, FILE *fp);
+	int	   (*process)(struct feat_fd *ff, void *data);
+	const char *name;
+	bool	   full_only;
+	bool	   synthesize;
+};
+
 struct evlist;
 struct perf_session;
 struct perf_tool;
tools/perf/util/machine.c +0 -25
index 132de5c..0535338 100644
@@ -20,7 +20,6 @@
 #include "symbol.h"
 #include "sort.h"
 #include "strlist.h"
-#include "util/synthetic-events.h"
 #include "target.h"
 #include "thread.h"
 #include "util.h"
@@ -2610,30 +2609,6 @@ int machines__for_each_thread(struct machines *machines,
 	return rc;
 }
 
-int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
-				  struct target *target, struct perf_thread_map *threads,
-				  perf_event__handler_t process, bool data_mmap,
-				  unsigned int nr_threads_synthesize)
-{
-	if (target__has_task(target))
-		return perf_event__synthesize_thread_map(tool, threads, process, machine, data_mmap);
-	else if (target__has_cpu(target))
-		return perf_event__synthesize_threads(tool, process,
-						      machine, data_mmap,
-						      nr_threads_synthesize);
-	/* command specified */
-	return 0;
-}
-
-int machine__synthesize_threads(struct machine *machine, struct target *target,
-				struct perf_thread_map *threads, bool data_mmap,
-				unsigned int nr_threads_synthesize)
-{
-	return __machine__synthesize_threads(machine, NULL, target, threads,
-					     perf_event__process, data_mmap,
-					     nr_threads_synthesize);
-}
-
 pid_t machine__get_current_tid(struct machine *machine, int cpu)
 {
 	int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS);
tools/perf/util/namespaces.c +18 -0
index 99be15d..285d6f3 100644
@@ -17,8 +17,26 @@
 #include <string.h>
 #include <unistd.h>
 #include <asm/bug.h>
+#include <linux/kernel.h>
 #include <linux/zalloc.h>
 
+static const char *perf_ns__names[] = {
+	[NET_NS_INDEX]		= "net",
+	[UTS_NS_INDEX]		= "uts",
+	[IPC_NS_INDEX]		= "ipc",
+	[PID_NS_INDEX]		= "pid",
+	[USER_NS_INDEX]		= "user",
+	[MNT_NS_INDEX]		= "mnt",
+	[CGROUP_NS_INDEX]	= "cgroup",
+};
+
+const char *perf_ns__name(unsigned int id)
+{
+	if (id >= ARRAY_SIZE(perf_ns__names))
+		return "UNKNOWN";
+	return perf_ns__names[id];
+}
+
 struct namespaces *namespaces__new(struct perf_record_namespaces *event)
 {
 	struct namespaces *namespaces;
tools/perf/util/namespaces.h +2 -0
index 40edef5..4b33f68 100644
@@ -66,4 +66,6 @@ static inline void __nsinfo__zput(struct nsinfo **nsip)
 
 #define nsinfo__zput(nsi) __nsinfo__zput(&nsi)
 
+const char *perf_ns__name(unsigned int id);
+
 #endif  /* __PERF_NAMESPACES_H */
tools/perf/util/session.c +0 -71

80 lines not on this page · raw message

tools/perf/util/stat.c +0 -43

52 lines not on this page · raw message

tools/perf/util/synthetic-events.c new file +1884 -0

858 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.