Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45694aa7 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

perf tools: Rename perf_event_ops to perf_tool

To better reflect that it became the base class for all tools, that must
be in each tool struct and where common stuff will be put.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-qgpc4msetqlwr8y2k7537cxe@git.kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 743eb868
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -278,6 +278,7 @@ LIB_H += util/strbuf.h
LIB_H += util/strlist.h
LIB_H += util/strfilter.h
LIB_H += util/svghelper.h
LIB_H += util/tool.h
LIB_H += util/run-command.h
LIB_H += util/sigchain.h
LIB_H += util/symbol.h
+7 −6
Original line number Diff line number Diff line
@@ -27,11 +27,12 @@
#include "util/sort.h"
#include "util/hist.h"
#include "util/session.h"
#include "util/tool.h"

#include <linux/bitmap.h>

struct perf_annotate {
	struct perf_event_ops ops;
	struct perf_tool tool;
	char const *input_name;
	bool	   force, use_tui, use_stdio;
	bool	   full_paths;
@@ -79,13 +80,13 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
	return ret;
}

static int process_sample_event(struct perf_event_ops *ops,
static int process_sample_event(struct perf_tool *tool,
				union perf_event *event,
				struct perf_sample *sample,
				struct perf_evsel *evsel,
				struct machine *machine)
{
	struct perf_annotate *ann = container_of(ops, struct perf_annotate, ops);
	struct perf_annotate *ann = container_of(tool, struct perf_annotate, tool);
	struct addr_location al;

	if (perf_event__preprocess_sample(event, machine, &al, sample,
@@ -174,7 +175,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
	u64 total_nr_samples;

	session = perf_session__new(ann->input_name, O_RDONLY,
				    ann->force, false, &ann->ops);
				    ann->force, false, &ann->tool);
	if (session == NULL)
		return -ENOMEM;

@@ -185,7 +186,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
			goto out_delete;
	}

	ret = perf_session__process_events(session, &ann->ops);
	ret = perf_session__process_events(session, &ann->tool);
	if (ret)
		goto out_delete;

@@ -241,7 +242,7 @@ static const char * const annotate_usage[] = {
int cmd_annotate(int argc, const char **argv, const char *prefix __used)
{
	struct perf_annotate annotate = {
		.ops = {
		.tool = {
			.sample	= process_sample_event,
			.mmap	= perf_event__process_mmap,
			.comm	= perf_event__process_comm,
+6 −5
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
#include "util/hist.h"
#include "util/evsel.h"
#include "util/session.h"
#include "util/tool.h"
#include "util/sort.h"
#include "util/symbol.h"
#include "util/util.h"
@@ -31,7 +32,7 @@ static int hists__add_entry(struct hists *self,
	return -ENOMEM;
}

static int diff__process_sample_event(struct perf_event_ops *ops __used,
static int diff__process_sample_event(struct perf_tool *tool __used,
				      union perf_event *event,
				      struct perf_sample *sample,
				      struct perf_evsel *evsel __used,
@@ -57,7 +58,7 @@ static int diff__process_sample_event(struct perf_event_ops *ops __used,
	return 0;
}

static struct perf_event_ops event_ops = {
static struct perf_tool perf_diff = {
	.sample	= diff__process_sample_event,
	.mmap	= perf_event__process_mmap,
	.comm	= perf_event__process_comm,
@@ -147,13 +148,13 @@ static int __cmd_diff(void)
	int ret, i;
	struct perf_session *session[2];

	session[0] = perf_session__new(input_old, O_RDONLY, force, false, &event_ops);
	session[1] = perf_session__new(input_new, O_RDONLY, force, false, &event_ops);
	session[0] = perf_session__new(input_old, O_RDONLY, force, false, &perf_diff);
	session[1] = perf_session__new(input_new, O_RDONLY, force, false, &perf_diff);
	if (session[0] == NULL || session[1] == NULL)
		return -ENOMEM;

	for (i = 0; i < 2; ++i) {
		ret = perf_session__process_events(session[i], &event_ops);
		ret = perf_session__process_events(session[i], &perf_diff);
		if (ret)
			goto out_delete;
	}
+28 −27
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@

#include "perf.h"
#include "util/session.h"
#include "util/tool.h"
#include "util/debug.h"

#include "util/parse-options.h"
@@ -16,7 +17,7 @@
static char		const *input_name = "-";
static bool		inject_build_ids;

static int perf_event__repipe_synth(struct perf_event_ops *ops __used,
static int perf_event__repipe_synth(struct perf_tool *tool __used,
				    union perf_event *event,
				    struct machine *machine __used)
{
@@ -37,17 +38,17 @@ static int perf_event__repipe_synth(struct perf_event_ops *ops __used,
	return 0;
}

static int perf_event__repipe_op2_synth(struct perf_event_ops *ops,
static int perf_event__repipe_op2_synth(struct perf_tool *tool,
					union perf_event *event,
					struct perf_session *session __used)
{
	return perf_event__repipe_synth(ops, event, NULL);
	return perf_event__repipe_synth(tool, event, NULL);
}

static int perf_event__repipe_event_type_synth(struct perf_event_ops *ops,
static int perf_event__repipe_event_type_synth(struct perf_tool *tool,
					       union perf_event *event)
{
	return perf_event__repipe_synth(ops, event, NULL);
	return perf_event__repipe_synth(tool, event, NULL);
}

static int perf_event__repipe_tracing_data_synth(union perf_event *event,
@@ -62,45 +63,45 @@ static int perf_event__repipe_attr(union perf_event *event,
	return perf_event__repipe_synth(NULL, event, NULL);
}

static int perf_event__repipe(struct perf_event_ops *ops,
static int perf_event__repipe(struct perf_tool *tool,
			      union perf_event *event,
			      struct perf_sample *sample __used,
			      struct machine *machine)
{
	return perf_event__repipe_synth(ops, event, machine);
	return perf_event__repipe_synth(tool, event, machine);
}

static int perf_event__repipe_sample(struct perf_event_ops *ops,
static int perf_event__repipe_sample(struct perf_tool *tool,
				     union perf_event *event,
			      struct perf_sample *sample __used,
			      struct perf_evsel *evsel __used,
			      struct machine *machine)
{
	return perf_event__repipe_synth(ops, event, machine);
	return perf_event__repipe_synth(tool, event, machine);
}

static int perf_event__repipe_mmap(struct perf_event_ops *ops,
static int perf_event__repipe_mmap(struct perf_tool *tool,
				   union perf_event *event,
				   struct perf_sample *sample,
				   struct machine *machine)
{
	int err;

	err = perf_event__process_mmap(ops, event, sample, machine);
	perf_event__repipe(ops, event, sample, machine);
	err = perf_event__process_mmap(tool, event, sample, machine);
	perf_event__repipe(tool, event, sample, machine);

	return err;
}

static int perf_event__repipe_task(struct perf_event_ops *ops,
static int perf_event__repipe_task(struct perf_tool *tool,
				   union perf_event *event,
				   struct perf_sample *sample,
				   struct machine *machine)
{
	int err;

	err = perf_event__process_task(ops, event, sample, machine);
	perf_event__repipe(ops, event, sample, machine);
	err = perf_event__process_task(tool, event, sample, machine);
	perf_event__repipe(tool, event, sample, machine);

	return err;
}
@@ -130,7 +131,7 @@ static int dso__read_build_id(struct dso *self)
	return -1;
}

static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops,
static int dso__inject_build_id(struct dso *self, struct perf_tool *tool,
				struct machine *machine)
{
	u16 misc = PERF_RECORD_MISC_USER;
@@ -144,7 +145,7 @@ static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops,
	if (self->kernel)
		misc = PERF_RECORD_MISC_KERNEL;

	err = perf_event__synthesize_build_id(ops, self, misc, perf_event__repipe,
	err = perf_event__synthesize_build_id(tool, self, misc, perf_event__repipe,
					      machine);
	if (err) {
		pr_err("Can't synthesize build_id event for %s\n", self->long_name);
@@ -154,7 +155,7 @@ static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops,
	return 0;
}

static int perf_event__inject_buildid(struct perf_event_ops *ops,
static int perf_event__inject_buildid(struct perf_tool *tool,
				      union perf_event *event,
				      struct perf_sample *sample,
				      struct perf_evsel *evsel __used,
@@ -180,7 +181,7 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops,
		if (!al.map->dso->hit) {
			al.map->dso->hit = 1;
			if (map__load(al.map, NULL) >= 0) {
				dso__inject_build_id(al.map->dso, ops, machine);
				dso__inject_build_id(al.map->dso, tool, machine);
				/*
				 * If this fails, too bad, let the other side
				 * account this as unresolved.
@@ -193,11 +194,11 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops,
	}

repipe:
	perf_event__repipe(ops, event, sample, machine);
	perf_event__repipe(tool, event, sample, machine);
	return 0;
}

struct perf_event_ops inject_ops = {
struct perf_tool perf_inject = {
	.sample		= perf_event__repipe_sample,
	.mmap		= perf_event__repipe,
	.comm		= perf_event__repipe,
@@ -228,17 +229,17 @@ static int __cmd_inject(void)
	signal(SIGINT, sig_handler);

	if (inject_build_ids) {
		inject_ops.sample	= perf_event__inject_buildid;
		inject_ops.mmap		= perf_event__repipe_mmap;
		inject_ops.fork		= perf_event__repipe_task;
		inject_ops.tracing_data	= perf_event__repipe_tracing_data;
		perf_inject.sample	 = perf_event__inject_buildid;
		perf_inject.mmap	 = perf_event__repipe_mmap;
		perf_inject.fork	 = perf_event__repipe_task;
		perf_inject.tracing_data = perf_event__repipe_tracing_data;
	}

	session = perf_session__new(input_name, O_RDONLY, false, true, &inject_ops);
	session = perf_session__new(input_name, O_RDONLY, false, true, &perf_inject);
	if (session == NULL)
		return -ENOMEM;

	ret = perf_session__process_events(session, &inject_ops);
	ret = perf_session__process_events(session, &perf_inject);

	perf_session__delete(session);

+5 −4
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
#include "util/thread.h"
#include "util/header.h"
#include "util/session.h"
#include "util/tool.h"

#include "util/parse-options.h"
#include "util/trace-event.h"
@@ -303,7 +304,7 @@ static void process_raw_event(union perf_event *raw_event __used, void *data,
	}
}

static int process_sample_event(struct perf_event_ops *ops __used,
static int process_sample_event(struct perf_tool *tool __used,
				union perf_event *event,
				struct perf_sample *sample,
				struct perf_evsel *evsel __used,
@@ -325,7 +326,7 @@ static int process_sample_event(struct perf_event_ops *ops __used,
	return 0;
}

static struct perf_event_ops event_ops = {
static struct perf_tool perf_kmem = {
	.sample			= process_sample_event,
	.comm			= perf_event__process_comm,
	.ordered_samples	= true,
@@ -484,7 +485,7 @@ static int __cmd_kmem(void)
{
	int err = -EINVAL;
	struct perf_session *session = perf_session__new(input_name, O_RDONLY,
							 0, false, &event_ops);
							 0, false, &perf_kmem);
	if (session == NULL)
		return -ENOMEM;

@@ -495,7 +496,7 @@ static int __cmd_kmem(void)
		goto out_delete;

	setup_pager();
	err = perf_session__process_events(session, &event_ops);
	err = perf_session__process_events(session, &perf_kmem);
	if (err != 0)
		goto out_delete;
	sort_result();
Loading