Skip to content

Commit 3b10ea7

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: User visible changes: * Add period data column and make it default in 'perf script' (Jiri Olsa) Infrastructure changes: * Move exit stuff from perf_evsel__delete to perf_evsel__exit, delete should be just a front end for exit + free (Arnaldo Carvalho de Melo) * Add missing 'struct option' forward declaration (Arnaldo Carvalho de Melo) * No need to drag util/cgroup.h into evsel.h (Arnaldo Carvalho de Melo) Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents 691286b + e8564b7 commit 3b10ea7

File tree

7 files changed

+30
-11
lines changed

7 files changed

+30
-11
lines changed

tools/perf/Documentation/perf-script.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ OPTIONS
115115
-f::
116116
--fields::
117117
Comma separated list of fields to print. Options are:
118-
comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, srcline.
118+
comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, srcline, period.
119119
Field list can be prepended with the type, trace, sw or hw,
120120
to indicate to which event type the field list applies.
121121
e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace

tools/perf/builtin-record.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "util/parse-events.h"
1616

1717
#include "util/callchain.h"
18+
#include "util/cgroup.h"
1819
#include "util/header.h"
1920
#include "util/event.h"
2021
#include "util/evlist.h"

tools/perf/builtin-script.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ enum perf_output_field {
4444
PERF_OUTPUT_ADDR = 1U << 10,
4545
PERF_OUTPUT_SYMOFFSET = 1U << 11,
4646
PERF_OUTPUT_SRCLINE = 1U << 12,
47+
PERF_OUTPUT_PERIOD = 1U << 13,
4748
};
4849

4950
struct output_option {
@@ -63,6 +64,7 @@ struct output_option {
6364
{.str = "addr", .field = PERF_OUTPUT_ADDR},
6465
{.str = "symoff", .field = PERF_OUTPUT_SYMOFFSET},
6566
{.str = "srcline", .field = PERF_OUTPUT_SRCLINE},
67+
{.str = "period", .field = PERF_OUTPUT_PERIOD},
6668
};
6769

6870
/* default set to maintain compatibility with current format */
@@ -80,7 +82,8 @@ static struct {
8082
.fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
8183
PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
8284
PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP |
83-
PERF_OUTPUT_SYM | PERF_OUTPUT_DSO,
85+
PERF_OUTPUT_SYM | PERF_OUTPUT_DSO |
86+
PERF_OUTPUT_PERIOD,
8487

8588
.invalid_fields = PERF_OUTPUT_TRACE,
8689
},
@@ -91,7 +94,8 @@ static struct {
9194
.fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
9295
PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
9396
PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP |
94-
PERF_OUTPUT_SYM | PERF_OUTPUT_DSO,
97+
PERF_OUTPUT_SYM | PERF_OUTPUT_DSO |
98+
PERF_OUTPUT_PERIOD,
9599

96100
.invalid_fields = PERF_OUTPUT_TRACE,
97101
},
@@ -110,7 +114,8 @@ static struct {
110114
.fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
111115
PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
112116
PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP |
113-
PERF_OUTPUT_SYM | PERF_OUTPUT_DSO,
117+
PERF_OUTPUT_SYM | PERF_OUTPUT_DSO |
118+
PERF_OUTPUT_PERIOD,
114119

115120
.invalid_fields = PERF_OUTPUT_TRACE,
116121
},
@@ -229,6 +234,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
229234
PERF_OUTPUT_CPU))
230235
return -EINVAL;
231236

237+
if (PRINT_FIELD(PERIOD) &&
238+
perf_evsel__check_stype(evsel, PERF_SAMPLE_PERIOD, "PERIOD",
239+
PERF_OUTPUT_PERIOD))
240+
return -EINVAL;
241+
232242
return 0;
233243
}
234244

@@ -448,6 +458,9 @@ static void process_event(union perf_event *event, struct perf_sample *sample,
448458

449459
print_sample_start(sample, thread, evsel);
450460

461+
if (PRINT_FIELD(PERIOD))
462+
printf("%10" PRIu64 " ", sample->period);
463+
451464
if (PRINT_FIELD(EVNAME)) {
452465
const char *evname = perf_evsel__name(evsel);
453466
printf("%s: ", evname ? evname : "[unknown]");
@@ -1543,7 +1556,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
15431556
"comma separated output fields prepend with 'type:'. "
15441557
"Valid types: hw,sw,trace,raw. "
15451558
"Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
1546-
"addr,symoff", parse_output_fields),
1559+
"addr,symoff,period", parse_output_fields),
15471560
OPT_BOOLEAN('a', "all-cpus", &system_wide,
15481561
"system-wide collection from all CPUs"),
15491562
OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",

tools/perf/builtin-stat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
#include "perf.h"
4545
#include "builtin.h"
46+
#include "util/cgroup.h"
4647
#include "util/util.h"
4748
#include "util/parse-options.h"
4849
#include "util/parse-events.h"

tools/perf/util/evlist.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist,
117117
void *ucontext));
118118
int perf_evlist__start_workload(struct perf_evlist *evlist);
119119

120+
struct option;
121+
120122
int perf_evlist__parse_mmap_pages(const struct option *opt,
121123
const char *str,
122124
int unset);

tools/perf/util/evsel.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <sys/resource.h>
1717
#include "asm/bug.h"
1818
#include "callchain.h"
19+
#include "cgroup.h"
1920
#include "evsel.h"
2021
#include "evlist.h"
2122
#include "util.h"
@@ -850,17 +851,17 @@ void perf_evsel__exit(struct perf_evsel *evsel)
850851
assert(list_empty(&evsel->node));
851852
perf_evsel__free_fd(evsel);
852853
perf_evsel__free_id(evsel);
854+
close_cgroup(evsel->cgrp);
855+
zfree(&evsel->group_name);
856+
if (evsel->tp_format)
857+
pevent_free_format(evsel->tp_format);
858+
zfree(&evsel->name);
853859
perf_evsel__object.fini(evsel);
854860
}
855861

856862
void perf_evsel__delete(struct perf_evsel *evsel)
857863
{
858864
perf_evsel__exit(evsel);
859-
close_cgroup(evsel->cgrp);
860-
zfree(&evsel->group_name);
861-
if (evsel->tp_format)
862-
pevent_free_format(evsel->tp_format);
863-
zfree(&evsel->name);
864865
free(evsel);
865866
}
866867

tools/perf/util/evsel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <linux/perf_event.h>
88
#include <linux/types.h>
99
#include "xyarray.h"
10-
#include "cgroup.h"
1110
#include "symbol.h"
1211

1312
struct perf_counts_values {
@@ -42,6 +41,8 @@ struct perf_sample_id {
4241
u64 period;
4342
};
4443

44+
struct cgroup_sel;
45+
4546
/** struct perf_evsel - event selector
4647
*
4748
* @name - Can be set to retain the original event name passed by the user,

0 commit comments

Comments
 (0)