Skip to content

Commit 45694aa

Browse files
committed
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: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 743eb86 commit 45694aa

22 files changed

Lines changed: 301 additions & 277 deletions

‎tools/perf/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ LIB_H += util/strbuf.h
278278
LIB_H += util/strlist.h
279279
LIB_H += util/strfilter.h
280280
LIB_H += util/svghelper.h
281+
LIB_H += util/tool.h
281282
LIB_H += util/run-command.h
282283
LIB_H += util/sigchain.h
283284
LIB_H += util/symbol.h

‎tools/perf/builtin-annotate.c‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@
2727
#include "util/sort.h"
2828
#include "util/hist.h"
2929
#include "util/session.h"
30+
#include "util/tool.h"
3031

3132
#include <linux/bitmap.h>
3233

3334
struct perf_annotate {
34-
struct perf_event_ops ops;
35+
struct perf_tool tool;
3536
char const *input_name;
3637
bool force, use_tui, use_stdio;
3738
bool full_paths;
@@ -79,13 +80,13 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
7980
return ret;
8081
}
8182

82-
static int process_sample_event(struct perf_event_ops *ops,
83+
static int process_sample_event(struct perf_tool *tool,
8384
union perf_event *event,
8485
struct perf_sample *sample,
8586
struct perf_evsel *evsel,
8687
struct machine *machine)
8788
{
88-
struct perf_annotate *ann = container_of(ops, struct perf_annotate, ops);
89+
struct perf_annotate *ann = container_of(tool, struct perf_annotate, tool);
8990
struct addr_location al;
9091

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

176177
session = perf_session__new(ann->input_name, O_RDONLY,
177-
ann->force, false, &ann->ops);
178+
ann->force, false, &ann->tool);
178179
if (session == NULL)
179180
return -ENOMEM;
180181

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

188-
ret = perf_session__process_events(session, &ann->ops);
189+
ret = perf_session__process_events(session, &ann->tool);
189190
if (ret)
190191
goto out_delete;
191192

@@ -241,7 +242,7 @@ static const char * const annotate_usage[] = {
241242
int cmd_annotate(int argc, const char **argv, const char *prefix __used)
242243
{
243244
struct perf_annotate annotate = {
244-
.ops = {
245+
.tool = {
245246
.sample = process_sample_event,
246247
.mmap = perf_event__process_mmap,
247248
.comm = perf_event__process_comm,

‎tools/perf/builtin-diff.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "util/hist.h"
1212
#include "util/evsel.h"
1313
#include "util/session.h"
14+
#include "util/tool.h"
1415
#include "util/sort.h"
1516
#include "util/symbol.h"
1617
#include "util/util.h"
@@ -31,7 +32,7 @@ static int hists__add_entry(struct hists *self,
3132
return -ENOMEM;
3233
}
3334

34-
static int diff__process_sample_event(struct perf_event_ops *ops __used,
35+
static int diff__process_sample_event(struct perf_tool *tool __used,
3536
union perf_event *event,
3637
struct perf_sample *sample,
3738
struct perf_evsel *evsel __used,
@@ -57,7 +58,7 @@ static int diff__process_sample_event(struct perf_event_ops *ops __used,
5758
return 0;
5859
}
5960

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

150-
session[0] = perf_session__new(input_old, O_RDONLY, force, false, &event_ops);
151-
session[1] = perf_session__new(input_new, O_RDONLY, force, false, &event_ops);
151+
session[0] = perf_session__new(input_old, O_RDONLY, force, false, &perf_diff);
152+
session[1] = perf_session__new(input_new, O_RDONLY, force, false, &perf_diff);
152153
if (session[0] == NULL || session[1] == NULL)
153154
return -ENOMEM;
154155

155156
for (i = 0; i < 2; ++i) {
156-
ret = perf_session__process_events(session[i], &event_ops);
157+
ret = perf_session__process_events(session[i], &perf_diff);
157158
if (ret)
158159
goto out_delete;
159160
}

‎tools/perf/builtin-inject.c‎

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99

1010
#include "perf.h"
1111
#include "util/session.h"
12+
#include "util/tool.h"
1213
#include "util/debug.h"
1314

1415
#include "util/parse-options.h"
1516

1617
static char const *input_name = "-";
1718
static bool inject_build_ids;
1819

19-
static int perf_event__repipe_synth(struct perf_event_ops *ops __used,
20+
static int perf_event__repipe_synth(struct perf_tool *tool __used,
2021
union perf_event *event,
2122
struct machine *machine __used)
2223
{
@@ -37,17 +38,17 @@ static int perf_event__repipe_synth(struct perf_event_ops *ops __used,
3738
return 0;
3839
}
3940

40-
static int perf_event__repipe_op2_synth(struct perf_event_ops *ops,
41+
static int perf_event__repipe_op2_synth(struct perf_tool *tool,
4142
union perf_event *event,
4243
struct perf_session *session __used)
4344
{
44-
return perf_event__repipe_synth(ops, event, NULL);
45+
return perf_event__repipe_synth(tool, event, NULL);
4546
}
4647

47-
static int perf_event__repipe_event_type_synth(struct perf_event_ops *ops,
48+
static int perf_event__repipe_event_type_synth(struct perf_tool *tool,
4849
union perf_event *event)
4950
{
50-
return perf_event__repipe_synth(ops, event, NULL);
51+
return perf_event__repipe_synth(tool, event, NULL);
5152
}
5253

5354
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,
6263
return perf_event__repipe_synth(NULL, event, NULL);
6364
}
6465

65-
static int perf_event__repipe(struct perf_event_ops *ops,
66+
static int perf_event__repipe(struct perf_tool *tool,
6667
union perf_event *event,
6768
struct perf_sample *sample __used,
6869
struct machine *machine)
6970
{
70-
return perf_event__repipe_synth(ops, event, machine);
71+
return perf_event__repipe_synth(tool, event, machine);
7172
}
7273

73-
static int perf_event__repipe_sample(struct perf_event_ops *ops,
74+
static int perf_event__repipe_sample(struct perf_tool *tool,
7475
union perf_event *event,
7576
struct perf_sample *sample __used,
7677
struct perf_evsel *evsel __used,
7778
struct machine *machine)
7879
{
79-
return perf_event__repipe_synth(ops, event, machine);
80+
return perf_event__repipe_synth(tool, event, machine);
8081
}
8182

82-
static int perf_event__repipe_mmap(struct perf_event_ops *ops,
83+
static int perf_event__repipe_mmap(struct perf_tool *tool,
8384
union perf_event *event,
8485
struct perf_sample *sample,
8586
struct machine *machine)
8687
{
8788
int err;
8889

89-
err = perf_event__process_mmap(ops, event, sample, machine);
90-
perf_event__repipe(ops, event, sample, machine);
90+
err = perf_event__process_mmap(tool, event, sample, machine);
91+
perf_event__repipe(tool, event, sample, machine);
9192

9293
return err;
9394
}
9495

95-
static int perf_event__repipe_task(struct perf_event_ops *ops,
96+
static int perf_event__repipe_task(struct perf_tool *tool,
9697
union perf_event *event,
9798
struct perf_sample *sample,
9899
struct machine *machine)
99100
{
100101
int err;
101102

102-
err = perf_event__process_task(ops, event, sample, machine);
103-
perf_event__repipe(ops, event, sample, machine);
103+
err = perf_event__process_task(tool, event, sample, machine);
104+
perf_event__repipe(tool, event, sample, machine);
104105

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

133-
static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops,
134+
static int dso__inject_build_id(struct dso *self, struct perf_tool *tool,
134135
struct machine *machine)
135136
{
136137
u16 misc = PERF_RECORD_MISC_USER;
@@ -144,7 +145,7 @@ static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops,
144145
if (self->kernel)
145146
misc = PERF_RECORD_MISC_KERNEL;
146147

147-
err = perf_event__synthesize_build_id(ops, self, misc, perf_event__repipe,
148+
err = perf_event__synthesize_build_id(tool, self, misc, perf_event__repipe,
148149
machine);
149150
if (err) {
150151
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,
154155
return 0;
155156
}
156157

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

195196
repipe:
196-
perf_event__repipe(ops, event, sample, machine);
197+
perf_event__repipe(tool, event, sample, machine);
197198
return 0;
198199
}
199200

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

230231
if (inject_build_ids) {
231-
inject_ops.sample = perf_event__inject_buildid;
232-
inject_ops.mmap = perf_event__repipe_mmap;
233-
inject_ops.fork = perf_event__repipe_task;
234-
inject_ops.tracing_data = perf_event__repipe_tracing_data;
232+
perf_inject.sample = perf_event__inject_buildid;
233+
perf_inject.mmap = perf_event__repipe_mmap;
234+
perf_inject.fork = perf_event__repipe_task;
235+
perf_inject.tracing_data = perf_event__repipe_tracing_data;
235236
}
236237

237-
session = perf_session__new(input_name, O_RDONLY, false, true, &inject_ops);
238+
session = perf_session__new(input_name, O_RDONLY, false, true, &perf_inject);
238239
if (session == NULL)
239240
return -ENOMEM;
240241

241-
ret = perf_session__process_events(session, &inject_ops);
242+
ret = perf_session__process_events(session, &perf_inject);
242243

243244
perf_session__delete(session);
244245

‎tools/perf/builtin-kmem.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "util/thread.h"
88
#include "util/header.h"
99
#include "util/session.h"
10+
#include "util/tool.h"
1011

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

306-
static int process_sample_event(struct perf_event_ops *ops __used,
307+
static int process_sample_event(struct perf_tool *tool __used,
307308
union perf_event *event,
308309
struct perf_sample *sample,
309310
struct perf_evsel *evsel __used,
@@ -325,7 +326,7 @@ static int process_sample_event(struct perf_event_ops *ops __used,
325326
return 0;
326327
}
327328

328-
static struct perf_event_ops event_ops = {
329+
static struct perf_tool perf_kmem = {
329330
.sample = process_sample_event,
330331
.comm = perf_event__process_comm,
331332
.ordered_samples = true,
@@ -484,7 +485,7 @@ static int __cmd_kmem(void)
484485
{
485486
int err = -EINVAL;
486487
struct perf_session *session = perf_session__new(input_name, O_RDONLY,
487-
0, false, &event_ops);
488+
0, false, &perf_kmem);
488489
if (session == NULL)
489490
return -ENOMEM;
490491

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

497498
setup_pager();
498-
err = perf_session__process_events(session, &event_ops);
499+
err = perf_session__process_events(session, &perf_kmem);
499500
if (err != 0)
500501
goto out_delete;
501502
sort_result();

‎tools/perf/builtin-lock.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "util/debug.h"
1414
#include "util/session.h"
15+
#include "util/tool.h"
1516

1617
#include <sys/types.h>
1718
#include <sys/prctl.h>
@@ -845,7 +846,7 @@ static void dump_info(void)
845846
die("Unknown type of information\n");
846847
}
847848

848-
static int process_sample_event(struct perf_event_ops *ops __used,
849+
static int process_sample_event(struct perf_tool *tool __used,
849850
union perf_event *event,
850851
struct perf_sample *sample,
851852
struct perf_evsel *evsel __used,
@@ -864,7 +865,7 @@ static int process_sample_event(struct perf_event_ops *ops __used,
864865
return 0;
865866
}
866867

867-
static struct perf_event_ops eops = {
868+
static struct perf_tool eops = {
868869
.sample = process_sample_event,
869870
.comm = perf_event__process_comm,
870871
.ordered_samples = true,

0 commit comments

Comments
 (0)