perf/core improvements and fixes:

User visible:
 
 o Add period data column and make it default in 'perf script' (Jiri Olsa)
 
 Infrastructure:
 
 * 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 <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJUQXIwAAoJENZQFvNTUqpAlHEP/30UONOpCo+zrr56v0jXanSA
 shPTHaqfAN58t3pwjs47C2y7sU+Pm0SjS5Myskl45LvKdVCQ7bqLCwTldgLxJHwP
 sYN5T3/UO0ESRX12XZCN/w9tLDdwE5aalrnt5nXKY7fEmZG7efadYj4xD2iU8OjH
 y5Jfx2VOVyT80HX+fFwCdaIS4kipvI3Y4LvOq6EbYtxWN0Jf0V4RjKnfmfZfIDcl
 ISUMwkddAUNEqh5dzE2q0IdZjHUpqCXisPMtEFuOMxpFn9iwDeWw1aKSGRPNukzA
 4diEr2oejA/+fIZB6r5NglatzhSyvPCuOaoCk2U4fxyKAVECG7D1yEKtg+hlXnRe
 ZaIDSq4SK0yordwnH3t0yamn90vmsGuAxnAnEq5mFRpG9ZseC9gJzHr590iAFW/D
 yvUEgW1rPNJRkI83GwufKeLayQU9z1HBE4nCPIDeocTU3obTFN5Er1nfGS+EsF61
 AlI8bB+I4z3IujT97oh+rhhD/Lc1VEVsdjrqT6aljfItT/m5CmQTQCGFyr5W/mfj
 5douWi6AESjRwwnaHxqFIR3nMaYnTR9luFqero8tXtSsk4X2se4JqPW7tjXATiTt
 Qwjdd/o8/6PCSzyu1RG0slItLxNBdLqmsEgITTtIeVKEmMQebElm6SXg0FMyP3QC
 iGUT6iXqfyFv9s09YbMC
 =WYLZ
 -----END PGP SIGNATURE-----

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 <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Ingo Molnar 2014-10-18 09:04:02 +02:00
commit 3b10ea7f92
7 changed files with 30 additions and 11 deletions

View File

@ -115,7 +115,7 @@ OPTIONS
-f::
--fields::
Comma separated list of fields to print. Options are:
comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, srcline.
comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, srcline, period.
Field list can be prepended with the type, trace, sw or hw,
to indicate to which event type the field list applies.
e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace

View File

@ -15,6 +15,7 @@
#include "util/parse-events.h"
#include "util/callchain.h"
#include "util/cgroup.h"
#include "util/header.h"
#include "util/event.h"
#include "util/evlist.h"

View File

@ -44,6 +44,7 @@ enum perf_output_field {
PERF_OUTPUT_ADDR = 1U << 10,
PERF_OUTPUT_SYMOFFSET = 1U << 11,
PERF_OUTPUT_SRCLINE = 1U << 12,
PERF_OUTPUT_PERIOD = 1U << 13,
};
struct output_option {
@ -63,6 +64,7 @@ struct output_option {
{.str = "addr", .field = PERF_OUTPUT_ADDR},
{.str = "symoff", .field = PERF_OUTPUT_SYMOFFSET},
{.str = "srcline", .field = PERF_OUTPUT_SRCLINE},
{.str = "period", .field = PERF_OUTPUT_PERIOD},
};
/* default set to maintain compatibility with current format */
@ -80,7 +82,8 @@ static struct {
.fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP |
PERF_OUTPUT_SYM | PERF_OUTPUT_DSO,
PERF_OUTPUT_SYM | PERF_OUTPUT_DSO |
PERF_OUTPUT_PERIOD,
.invalid_fields = PERF_OUTPUT_TRACE,
},
@ -91,7 +94,8 @@ static struct {
.fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP |
PERF_OUTPUT_SYM | PERF_OUTPUT_DSO,
PERF_OUTPUT_SYM | PERF_OUTPUT_DSO |
PERF_OUTPUT_PERIOD,
.invalid_fields = PERF_OUTPUT_TRACE,
},
@ -110,7 +114,8 @@ static struct {
.fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP |
PERF_OUTPUT_SYM | PERF_OUTPUT_DSO,
PERF_OUTPUT_SYM | PERF_OUTPUT_DSO |
PERF_OUTPUT_PERIOD,
.invalid_fields = PERF_OUTPUT_TRACE,
},
@ -229,6 +234,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
PERF_OUTPUT_CPU))
return -EINVAL;
if (PRINT_FIELD(PERIOD) &&
perf_evsel__check_stype(evsel, PERF_SAMPLE_PERIOD, "PERIOD",
PERF_OUTPUT_PERIOD))
return -EINVAL;
return 0;
}
@ -448,6 +458,9 @@ static void process_event(union perf_event *event, struct perf_sample *sample,
print_sample_start(sample, thread, evsel);
if (PRINT_FIELD(PERIOD))
printf("%10" PRIu64 " ", sample->period);
if (PRINT_FIELD(EVNAME)) {
const char *evname = perf_evsel__name(evsel);
printf("%s: ", evname ? evname : "[unknown]");
@ -1543,7 +1556,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
"comma separated output fields prepend with 'type:'. "
"Valid types: hw,sw,trace,raw. "
"Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
"addr,symoff", parse_output_fields),
"addr,symoff,period", parse_output_fields),
OPT_BOOLEAN('a', "all-cpus", &system_wide,
"system-wide collection from all CPUs"),
OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",

View File

@ -43,6 +43,7 @@
#include "perf.h"
#include "builtin.h"
#include "util/cgroup.h"
#include "util/util.h"
#include "util/parse-options.h"
#include "util/parse-events.h"

View File

@ -117,6 +117,8 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist,
void *ucontext));
int perf_evlist__start_workload(struct perf_evlist *evlist);
struct option;
int perf_evlist__parse_mmap_pages(const struct option *opt,
const char *str,
int unset);

View File

@ -16,6 +16,7 @@
#include <sys/resource.h>
#include "asm/bug.h"
#include "callchain.h"
#include "cgroup.h"
#include "evsel.h"
#include "evlist.h"
#include "util.h"
@ -850,17 +851,17 @@ void perf_evsel__exit(struct perf_evsel *evsel)
assert(list_empty(&evsel->node));
perf_evsel__free_fd(evsel);
perf_evsel__free_id(evsel);
close_cgroup(evsel->cgrp);
zfree(&evsel->group_name);
if (evsel->tp_format)
pevent_free_format(evsel->tp_format);
zfree(&evsel->name);
perf_evsel__object.fini(evsel);
}
void perf_evsel__delete(struct perf_evsel *evsel)
{
perf_evsel__exit(evsel);
close_cgroup(evsel->cgrp);
zfree(&evsel->group_name);
if (evsel->tp_format)
pevent_free_format(evsel->tp_format);
zfree(&evsel->name);
free(evsel);
}

View File

@ -7,7 +7,6 @@
#include <linux/perf_event.h>
#include <linux/types.h>
#include "xyarray.h"
#include "cgroup.h"
#include "symbol.h"
struct perf_counts_values {
@ -42,6 +41,8 @@ struct perf_sample_id {
u64 period;
};
struct cgroup_sel;
/** struct perf_evsel - event selector
*
* @name - Can be set to retain the original event name passed by the user,