2012-03-15 19:09:15 +00:00
|
|
|
|
2012-06-15 06:31:39 +00:00
|
|
|
%option reentrant
|
|
|
|
%option bison-bridge
|
2012-03-15 19:09:15 +00:00
|
|
|
%option prefix="parse_events_"
|
2012-05-21 07:12:52 +00:00
|
|
|
%option stack
|
2015-04-22 19:10:17 +00:00
|
|
|
%option bison-locations
|
|
|
|
%option yylineno
|
2012-03-15 19:09:15 +00:00
|
|
|
|
|
|
|
%{
|
|
|
|
#include <errno.h>
|
|
|
|
#include "../perf.h"
|
|
|
|
#include "parse-events-bison.h"
|
2012-03-15 19:09:16 +00:00
|
|
|
#include "parse-events.h"
|
2012-03-15 19:09:15 +00:00
|
|
|
|
2012-06-15 06:31:39 +00:00
|
|
|
char *parse_events_get_text(yyscan_t yyscanner);
|
|
|
|
YYSTYPE *parse_events_get_lval(yyscan_t yyscanner);
|
|
|
|
|
|
|
|
static int __value(YYSTYPE *yylval, char *str, int base, int token)
|
2012-03-15 19:09:15 +00:00
|
|
|
{
|
2012-08-07 17:43:13 +00:00
|
|
|
u64 num;
|
2012-03-15 19:09:15 +00:00
|
|
|
|
|
|
|
errno = 0;
|
2012-08-07 17:43:13 +00:00
|
|
|
num = strtoull(str, NULL, base);
|
2012-03-15 19:09:15 +00:00
|
|
|
if (errno)
|
|
|
|
return PE_ERROR;
|
|
|
|
|
2012-06-15 06:31:39 +00:00
|
|
|
yylval->num = num;
|
2012-03-15 19:09:15 +00:00
|
|
|
return token;
|
|
|
|
}
|
|
|
|
|
2012-06-15 06:31:39 +00:00
|
|
|
static int value(yyscan_t scanner, int base)
|
2012-03-15 19:09:15 +00:00
|
|
|
{
|
2012-06-15 06:31:39 +00:00
|
|
|
YYSTYPE *yylval = parse_events_get_lval(scanner);
|
|
|
|
char *text = parse_events_get_text(scanner);
|
|
|
|
|
|
|
|
return __value(yylval, text, base, PE_VALUE);
|
2012-03-15 19:09:15 +00:00
|
|
|
}
|
|
|
|
|
2012-06-15 06:31:39 +00:00
|
|
|
static int raw(yyscan_t scanner)
|
2012-03-15 19:09:15 +00:00
|
|
|
{
|
2012-06-15 06:31:39 +00:00
|
|
|
YYSTYPE *yylval = parse_events_get_lval(scanner);
|
|
|
|
char *text = parse_events_get_text(scanner);
|
|
|
|
|
|
|
|
return __value(yylval, text + 1, 16, PE_RAW);
|
2012-03-15 19:09:15 +00:00
|
|
|
}
|
|
|
|
|
2012-06-15 06:31:39 +00:00
|
|
|
static int str(yyscan_t scanner, int token)
|
2012-03-15 19:09:15 +00:00
|
|
|
{
|
2012-06-15 06:31:39 +00:00
|
|
|
YYSTYPE *yylval = parse_events_get_lval(scanner);
|
|
|
|
char *text = parse_events_get_text(scanner);
|
|
|
|
|
|
|
|
yylval->str = strdup(text);
|
2012-03-15 19:09:15 +00:00
|
|
|
return token;
|
|
|
|
}
|
|
|
|
|
2015-04-22 19:10:17 +00:00
|
|
|
#define REWIND(__alloc) \
|
|
|
|
do { \
|
|
|
|
YYSTYPE *__yylval = parse_events_get_lval(yyscanner); \
|
|
|
|
char *text = parse_events_get_text(yyscanner); \
|
|
|
|
\
|
|
|
|
if (__alloc) \
|
|
|
|
__yylval->str = strdup(text); \
|
|
|
|
\
|
|
|
|
yycolumn -= strlen(text); \
|
|
|
|
yyless(0); \
|
|
|
|
} while (0)
|
|
|
|
|
2014-10-07 15:08:51 +00:00
|
|
|
static int pmu_str_check(yyscan_t scanner)
|
|
|
|
{
|
|
|
|
YYSTYPE *yylval = parse_events_get_lval(scanner);
|
|
|
|
char *text = parse_events_get_text(scanner);
|
|
|
|
|
|
|
|
yylval->str = strdup(text);
|
|
|
|
switch (perf_pmu__parse_check(text)) {
|
|
|
|
case PMU_EVENT_SYMBOL_PREFIX:
|
|
|
|
return PE_PMU_EVENT_PRE;
|
|
|
|
case PMU_EVENT_SYMBOL_SUFFIX:
|
|
|
|
return PE_PMU_EVENT_SUF;
|
|
|
|
case PMU_EVENT_SYMBOL:
|
|
|
|
return PE_KERNEL_PMU_EVENT;
|
|
|
|
default:
|
|
|
|
return PE_NAME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-15 06:31:39 +00:00
|
|
|
static int sym(yyscan_t scanner, int type, int config)
|
2012-03-15 19:09:15 +00:00
|
|
|
{
|
2012-06-15 06:31:39 +00:00
|
|
|
YYSTYPE *yylval = parse_events_get_lval(scanner);
|
|
|
|
|
|
|
|
yylval->num = (type << 16) + config;
|
2012-07-03 22:00:43 +00:00
|
|
|
return type == PERF_TYPE_HARDWARE ? PE_VALUE_SYM_HW : PE_VALUE_SYM_SW;
|
2012-03-15 19:09:15 +00:00
|
|
|
}
|
|
|
|
|
2012-06-15 06:31:39 +00:00
|
|
|
static int term(yyscan_t scanner, int type)
|
2012-03-15 19:09:16 +00:00
|
|
|
{
|
2012-06-15 06:31:39 +00:00
|
|
|
YYSTYPE *yylval = parse_events_get_lval(scanner);
|
|
|
|
|
|
|
|
yylval->num = type;
|
2012-03-15 19:09:16 +00:00
|
|
|
return PE_TERM;
|
|
|
|
}
|
|
|
|
|
2015-04-22 19:10:17 +00:00
|
|
|
#define YY_USER_ACTION \
|
|
|
|
do { \
|
|
|
|
yylloc->last_column = yylloc->first_column; \
|
|
|
|
yylloc->first_column = yycolumn; \
|
|
|
|
yycolumn += yyleng; \
|
|
|
|
} while (0);
|
|
|
|
|
2012-03-15 19:09:15 +00:00
|
|
|
%}
|
|
|
|
|
2012-05-21 07:12:52 +00:00
|
|
|
%x mem
|
2012-08-16 19:10:21 +00:00
|
|
|
%s config
|
|
|
|
%x event
|
|
|
|
|
|
|
|
group [^,{}/]*[{][^}]*[}][^,{}/]*
|
|
|
|
event_pmu [^,{}/]+[/][^/]*[/][^,{}/]*
|
|
|
|
event [^,{}/]+
|
perf tools: Enable passing bpf object file to --event
By introducing new rules in tools/perf/util/parse-events.[ly], this
patch enables 'perf record --event bpf_file.o' to select events by an
eBPF object file. It calls parse_events_load_bpf() to load that file,
which uses bpf__prepare_load() and finally calls bpf_object__open() for
the object files.
After applying this patch, commands like:
# perf record --event foo.o sleep
become possible.
However, at this point it is unable to link any useful things onto the
evsel list because the creating of probe points and BPF program
attaching have not been implemented. Before real events are possible to
be extracted, to avoid perf report error because of empty evsel list,
this patch link a dummy evsel. The dummy event related code will be
removed when probing and extracting code is ready.
Commiter notes:
Using it:
$ ls -la foo.o
ls: cannot access foo.o: No such file or directory
$ perf record --event foo.o sleep
libbpf: failed to open foo.o: No such file or directory
event syntax error: 'foo.o'
\___ BPF object file 'foo.o' is invalid
(add -v to see detail)
Run 'perf list' for a list of valid events
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-e, --event <event> event selector. use 'perf list' to list available events
$
$ file /tmp/build/perf/perf.o
/tmp/build/perf/perf.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
$ perf record --event /tmp/build/perf/perf.o sleep
libbpf: /tmp/build/perf/perf.o is not an eBPF object file
event syntax error: '/tmp/build/perf/perf.o'
\___ BPF object file '/tmp/build/perf/perf.o' is invalid
(add -v to see detail)
Run 'perf list' for a list of valid events
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-e, --event <event> event selector. use 'perf list' to list available events
$
$ file /tmp/foo.o
/tmp/foo.o: ELF 64-bit LSB relocatable, no machine, version 1 (SYSV), not stripped
$ perf record --event /tmp/foo.o sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.013 MB perf.data ]
$ perf evlist
/tmp/foo.o
$ perf evlist -v
/tmp/foo.o: type: 1, size: 112, config: 0x9, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
$
So, type 1 is PERF_TYPE_SOFTWARE, config 0x9 is PERF_COUNT_SW_DUMMY, ok.
$ perf report --stdio
Error:
The perf.data file has no samples!
# To display the perf.data header info, please use --header/--header-only options.
#
$
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kaixu Xia <xiakaixu@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1444826502-49291-4-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-14 12:41:14 +00:00
|
|
|
bpf_object .*\.(o|bpf)
|
2015-10-14 12:41:20 +00:00
|
|
|
bpf_source .*\.c
|
2012-05-21 07:12:52 +00:00
|
|
|
|
2012-03-15 19:09:15 +00:00
|
|
|
num_dec [0-9]+
|
|
|
|
num_hex 0x[a-fA-F0-9]+
|
|
|
|
num_raw_hex [a-fA-F0-9]+
|
2015-06-10 07:25:11 +00:00
|
|
|
name [a-zA-Z_*?][a-zA-Z0-9_*?.]*
|
|
|
|
name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.]*
|
perf tools: Add support for pinned modifier
This commit adds support for a new modifier "D", which requests that the
event, or group of events, be pinned to the PMU.
The "p" modifier is already taken for precise, and "P" may be used in
future to mean "fully precise".
So we use "D", which stands for pinneD - and looks like a padlock, or if
you're using the ":D" syntax perf smiles at you.
This is an oft-requested feature from our HW folks, who want to be able
to run a large number of events, but also want 100% accurate results for
instructions per cycle.
Comparison of results with and without pinning:
$ perf stat -e '{cycles,instructions}:D' -e cycles,instructions,...
79,590,480,683 cycles # 0.000 GHz
166,123,716,524 instructions # 2.09 insns per cycle
# 0.11 stalled cycles per insn
79,352,134,463 cycles # 0.000 GHz [11.11%]
165,178,301,818 instructions # 2.08 insns per cycle
# 0.11 stalled cycles per insn [11.13%]
As you can see although perf does a very good job of scaling the values
in the non-pinned case, there is some small discrepancy.
The patch is fairly straight forward, the one detail is that we need to
make sure we only request pinning for the group leader when we have a
group.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Tested-by: Jiri Olsa <jolsa@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1375795686-4226-1-git-send-email-michael@ellerman.id.au
[ Use perf_evsel__is_group_leader instead of open coded equivalent, as
suggested by Jiri Olsa ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2013-08-06 13:28:05 +00:00
|
|
|
/* If you add a modifier you need to update check_modifier() */
|
perf tools: Introduce 'P' modifier to request max precision
The 'P' will cause the event to get maximum possible detected precise
level.
Following record:
$ perf record -e cycles:P ...
will detect maximum precise level for 'cycles' event and use it.
Commiter note:
Testing it:
$ perf record -e cycles:P usleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.013 MB perf.data (9 samples) ]
$ perf evlist
cycles:P
$ perf evlist -v
cycles:P: size: 112, { sample_period, sample_freq }: 4000, sample_type:
IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1,
enable_on_exec: 1, task: 1, precise_ip: 2, sample_id_all: 1, mmap2: 1,
comm_exec: 1
$
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1444068369-20978-6-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-05 18:06:05 +00:00
|
|
|
modifier_event [ukhpPGHSDI]+
|
2012-06-29 07:22:54 +00:00
|
|
|
modifier_bp [rwx]{1,3}
|
2012-03-15 19:09:15 +00:00
|
|
|
|
|
|
|
%%
|
2012-06-15 06:31:40 +00:00
|
|
|
|
|
|
|
%{
|
|
|
|
{
|
|
|
|
int start_token;
|
|
|
|
|
2012-08-16 19:10:21 +00:00
|
|
|
start_token = parse_events_get_extra(yyscanner);
|
|
|
|
|
|
|
|
if (start_token == PE_START_TERMS)
|
|
|
|
BEGIN(config);
|
|
|
|
else if (start_token == PE_START_EVENTS)
|
|
|
|
BEGIN(event);
|
|
|
|
|
2012-06-15 06:31:40 +00:00
|
|
|
if (start_token) {
|
|
|
|
parse_events_set_extra(NULL, yyscanner);
|
2015-04-22 19:10:17 +00:00
|
|
|
/*
|
|
|
|
* The flex parser does not init locations variable
|
|
|
|
* via the scan_string interface, so we need do the
|
|
|
|
* init in here.
|
|
|
|
*/
|
|
|
|
yycolumn = 0;
|
2012-06-15 06:31:40 +00:00
|
|
|
return start_token;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
|
2012-08-16 19:10:21 +00:00
|
|
|
<event>{
|
|
|
|
|
|
|
|
{group} {
|
2015-04-22 19:10:17 +00:00
|
|
|
BEGIN(INITIAL);
|
|
|
|
REWIND(0);
|
2012-08-16 19:10:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{event_pmu} |
|
perf tools: Enable passing bpf object file to --event
By introducing new rules in tools/perf/util/parse-events.[ly], this
patch enables 'perf record --event bpf_file.o' to select events by an
eBPF object file. It calls parse_events_load_bpf() to load that file,
which uses bpf__prepare_load() and finally calls bpf_object__open() for
the object files.
After applying this patch, commands like:
# perf record --event foo.o sleep
become possible.
However, at this point it is unable to link any useful things onto the
evsel list because the creating of probe points and BPF program
attaching have not been implemented. Before real events are possible to
be extracted, to avoid perf report error because of empty evsel list,
this patch link a dummy evsel. The dummy event related code will be
removed when probing and extracting code is ready.
Commiter notes:
Using it:
$ ls -la foo.o
ls: cannot access foo.o: No such file or directory
$ perf record --event foo.o sleep
libbpf: failed to open foo.o: No such file or directory
event syntax error: 'foo.o'
\___ BPF object file 'foo.o' is invalid
(add -v to see detail)
Run 'perf list' for a list of valid events
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-e, --event <event> event selector. use 'perf list' to list available events
$
$ file /tmp/build/perf/perf.o
/tmp/build/perf/perf.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
$ perf record --event /tmp/build/perf/perf.o sleep
libbpf: /tmp/build/perf/perf.o is not an eBPF object file
event syntax error: '/tmp/build/perf/perf.o'
\___ BPF object file '/tmp/build/perf/perf.o' is invalid
(add -v to see detail)
Run 'perf list' for a list of valid events
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-e, --event <event> event selector. use 'perf list' to list available events
$
$ file /tmp/foo.o
/tmp/foo.o: ELF 64-bit LSB relocatable, no machine, version 1 (SYSV), not stripped
$ perf record --event /tmp/foo.o sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.013 MB perf.data ]
$ perf evlist
/tmp/foo.o
$ perf evlist -v
/tmp/foo.o: type: 1, size: 112, config: 0x9, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
$
So, type 1 is PERF_TYPE_SOFTWARE, config 0x9 is PERF_COUNT_SW_DUMMY, ok.
$ perf report --stdio
Error:
The perf.data file has no samples!
# To display the perf.data header info, please use --header/--header-only options.
#
$
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kaixu Xia <xiakaixu@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1444826502-49291-4-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-14 12:41:14 +00:00
|
|
|
{bpf_object} |
|
2015-10-14 12:41:20 +00:00
|
|
|
{bpf_source} |
|
2012-08-16 19:10:21 +00:00
|
|
|
{event} {
|
2015-04-22 19:10:17 +00:00
|
|
|
BEGIN(INITIAL);
|
|
|
|
REWIND(1);
|
2012-08-16 19:10:21 +00:00
|
|
|
return PE_EVENT_NAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
<<EOF>> {
|
2015-04-22 19:10:17 +00:00
|
|
|
BEGIN(INITIAL);
|
|
|
|
REWIND(0);
|
2012-08-16 19:10:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-09-27 16:29:58 +00:00
|
|
|
<config>{
|
perf tools: Add term support for parse_events_error
Allowing event's term processing to report back error, like:
$ perf record -e 'cpu/even=0x1/' ls
event syntax error: 'cpu/even=0x1/'
\___ unknown term
valid terms: pc,any,inv,edge,cmask,event,in_tx,ldlat,umask,in_tx_cp,offcore_rsp,config,config1,config2,name,period,branch_type
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1429729824-13932-7-git-send-email-jolsa@kernel.org
[ Renamed 'error' variables to 'err', not to clash with util.h error() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-22 19:10:21 +00:00
|
|
|
/*
|
perf tools: Show proper error message for wrong terms of hw/sw events
Show proper error message and show valid terms when wrong config terms
is specified for hw/sw type perf events.
This patch makes the original error format function formats_error_string()
more generic, which only outputs the static config terms for hw/sw perf
events, and prepends pmu formats for pmu events.
Before this patch:
$ perf record -e 'cpu-clock/freqx=200/' -a sleep 1
invalid or unsupported event: 'cpu-clock/freqx=200/'
Run 'perf list' for a list of valid events
usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-e, --event <event> event selector. use 'perf list' to list available events
After this patch:
$ perf record -e 'cpu-clock/freqx=200/' -a sleep 1
event syntax error: 'cpu-clock/freqx=200/'
\___ unknown term
valid terms: config,config1,config2,name,period,freq,branch_type,time,call-graph,stack-size
Run 'perf list' for a list of valid events
usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-e, --event <event> event selector. use 'perf list' to list available events
Signed-off-by: He Kuang <hekuang@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1443412336-120050-2-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-09-28 03:52:14 +00:00
|
|
|
* Please update parse_events_formats_error_string any time
|
perf tools: Add term support for parse_events_error
Allowing event's term processing to report back error, like:
$ perf record -e 'cpu/even=0x1/' ls
event syntax error: 'cpu/even=0x1/'
\___ unknown term
valid terms: pc,any,inv,edge,cmask,event,in_tx,ldlat,umask,in_tx_cp,offcore_rsp,config,config1,config2,name,period,branch_type
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1429729824-13932-7-git-send-email-jolsa@kernel.org
[ Renamed 'error' variables to 'err', not to clash with util.h error() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-22 19:10:21 +00:00
|
|
|
* new static term is added.
|
|
|
|
*/
|
2013-09-27 16:29:58 +00:00
|
|
|
config { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG); }
|
|
|
|
config1 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG1); }
|
|
|
|
config2 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG2); }
|
|
|
|
name { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NAME); }
|
|
|
|
period { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); }
|
2015-08-09 06:45:23 +00:00
|
|
|
freq { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ); }
|
2013-09-27 16:29:58 +00:00
|
|
|
branch_type { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); }
|
2015-08-04 08:30:19 +00:00
|
|
|
time { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_TIME); }
|
perf callchain: Per-event type selection support
This patchkit adds the ability to set callgraph mode (fp, dwarf, lbr) per
event. This in term can reduce sampling overhead and the size of the
perf.data.
Here is an example.
perf record -e 'cpu/cpu-cycles,period=1000,call-graph=fp,time=1/,cpu/instructions,call-graph=lbr/' sleep 1
perf evlist -v
cpu/cpu-cycles,period=1000,call-graph=fp,time=1/: type: 4, size: 112,
config: 0x3c, { sample_period, sample_freq }: 1000, sample_type:
IP|TID|TIME|CALLCHAIN|PERIOD|IDENTIFIER, read_format: ID, disabled: 1,
inherit: 1, mmap: 1, comm: 1, enable_on_exec: 1, task: 1, sample_id_all:
1, exclude_guest: 1, mmap2: 1, comm_exec: 1
cpu/instructions,call-graph=lbr/: type: 4, size: 112, config: 0xc0, {
sample_period, sample_freq }: 4000, sample_type:
IP|TID|TIME|CALLCHAIN|PERIOD|BRANCH_STACK|IDENTIFIER, read_format: ID,
disabled: 1, inherit: 1, freq: 1, enable_on_exec: 1, sample_id_all: 1,
exclude_guest: 1
Signed-off-by: Kan Liang <kan.liang@intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1439289050-40510-1-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-08-11 10:30:47 +00:00
|
|
|
call-graph { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CALLGRAPH); }
|
|
|
|
stack-size { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_STACKSIZE); }
|
perf tools: Enable pre-event inherit setting by config terms
This patch allows perf record setting event's attr.inherit bit by
config terms like:
# perf record -e cycles/no-inherit/ ...
# perf record -e cycles/inherit/ ...
So user can control inherit bit for each event separately.
In following example, a.out fork()s in main then do some complex
CPU intensive computations in both of its children.
Basic result with and without inherit:
# perf record -e cycles -e instructions ./a.out
[ perf record: Woken up 9 times to write data ]
[ perf record: Captured and wrote 2.205 MB perf.data (47920 samples) ]
# perf report --stdio
# ...
# Samples: 23K of event 'cycles'
# Event count (approx.): 23641752891
...
# Samples: 24K of event 'instructions'
# Event count (approx.): 30428312415
# perf record -i -e cycles -e instructions ./a.out
[ perf record: Woken up 5 times to write data ]
[ perf record: Captured and wrote 1.111 MB perf.data (24019 samples) ]
...
# Samples: 12K of event 'cycles'
# Event count (approx.): 11699501775
...
# Samples: 12K of event 'instructions'
# Event count (approx.): 15058023559
Cancel inherit for one event when globally enable:
# perf record -e cycles/no-inherit/ -e instructions ./a.out
[ perf record: Woken up 7 times to write data ]
[ perf record: Captured and wrote 1.660 MB perf.data (36004 samples) ]
...
# Samples: 12K of event 'cycles/no-inherit/'
# Event count (approx.): 11895759282
...
# Samples: 24K of event 'instructions'
# Event count (approx.): 30668000441
Enable inherit for one event when globally disable:
# perf record -i -e cycles/inherit/ -e instructions ./a.out
[ perf record: Woken up 7 times to write data ]
[ perf record: Captured and wrote 1.654 MB perf.data (35868 samples) ]
...
# Samples: 23K of event 'cycles/inherit/'
# Event count (approx.): 23285400229
...
# Samples: 11K of event 'instructions'
# Event count (approx.): 14969050259
Committer note:
One can check if the bit was set, in addition to seeing the result in
the perf.data file size as above by doing one of:
# perf record -e cycles -e instructions -a usleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.911 MB perf.data (63 samples) ]
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|ID|CPU|PERIOD, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
instructions: size: 112, config: 0x1, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|ID|CPU|PERIOD, read_format: ID, disabled: 1, inherit: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
#
So, the inherit bit was set in both, now, if we disable it globally using
--no-inherit:
# perf record --no-inherit -e cycles -e instructions -a usleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.910 MB perf.data (56 samples) ]
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|ID|CPU|PERIOD, read_format: ID, disabled: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
instructions: size: 112, config: 0x1, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|ID|CPU|PERIOD, read_format: ID, disabled: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
No inherit bit set, then disabling it and setting just on the cycles event:
# perf record --no-inherit -e cycles/inherit/ -e instructions -a usleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.909 MB perf.data (48 samples) ]
# perf evlist -v
cycles/inherit/: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|ID|CPU|PERIOD, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
instructions: size: 112, config: 0x1, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|ID|CPU|PERIOD, read_format: ID, disabled: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
#
We can see it as well in by using a more verbose level of debug messages in
the tool that sets up the perf_event_attr, 'perf record' in this case:
[root@zoo ~]# perf record -vv --no-inherit -e cycles/inherit/ -e instructions -a usleep 1
------------------------------------------------------------
perf_event_attr:
size 112
{ sample_period, sample_freq } 4000
sample_type IP|TID|TIME|ID|CPU|PERIOD
read_format ID
disabled 1
inherit 1
mmap 1
comm 1
freq 1
task 1
sample_id_all 1
exclude_guest 1
mmap2 1
comm_exec 1
------------------------------------------------------------
sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8
sys_perf_event_open: pid -1 cpu 1 group_fd -1 flags 0x8
sys_perf_event_open: pid -1 cpu 2 group_fd -1 flags 0x8
sys_perf_event_open: pid -1 cpu 3 group_fd -1 flags 0x8
------------------------------------------------------------
perf_event_attr:
size 112
config 0x1
{ sample_period, sample_freq } 4000
sample_type IP|TID|TIME|ID|CPU|PERIOD
read_format ID
disabled 1
freq 1
sample_id_all 1
exclude_guest 1
------------------------------------------------------------
sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8
<SNIP>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1446029705-199659-2-git-send-email-wangnan0@huawei.com
[ s/u64/bool/ for the perf_evsel_config_term inherit field - jolsa]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-28 10:55:02 +00:00
|
|
|
inherit { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_INHERIT); }
|
|
|
|
no-inherit { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOINHERIT); }
|
2013-09-27 16:29:58 +00:00
|
|
|
, { return ','; }
|
|
|
|
"/" { BEGIN(INITIAL); return '/'; }
|
|
|
|
{name_minus} { return str(yyscanner, PE_NAME); }
|
|
|
|
}
|
|
|
|
|
|
|
|
<mem>{
|
|
|
|
{modifier_bp} { return str(yyscanner, PE_MODIFIER_BP); }
|
|
|
|
: { return ':'; }
|
2014-05-29 15:26:51 +00:00
|
|
|
"/" { return '/'; }
|
2013-09-27 16:29:58 +00:00
|
|
|
{num_dec} { return value(yyscanner, 10); }
|
|
|
|
{num_hex} { return value(yyscanner, 16); }
|
|
|
|
/*
|
|
|
|
* We need to separate 'mem:' scanner part, in order to get specific
|
|
|
|
* modifier bits parsed out. Otherwise we would need to handle PE_NAME
|
|
|
|
* and we'd need to parse it manually. During the escape from <mem>
|
|
|
|
* state we need to put the escaping char back, so we dont miss it.
|
|
|
|
*/
|
|
|
|
. { unput(*yytext); BEGIN(INITIAL); }
|
|
|
|
/*
|
|
|
|
* We destroy the scanner after reaching EOF,
|
|
|
|
* but anyway just to be sure get back to INIT state.
|
|
|
|
*/
|
|
|
|
<<EOF>> { BEGIN(INITIAL); }
|
|
|
|
}
|
|
|
|
|
2012-06-15 06:31:39 +00:00
|
|
|
cpu-cycles|cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES); }
|
|
|
|
stalled-cycles-frontend|idle-cycles-frontend { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND); }
|
|
|
|
stalled-cycles-backend|idle-cycles-backend { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND); }
|
|
|
|
instructions { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS); }
|
|
|
|
cache-references { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_REFERENCES); }
|
|
|
|
cache-misses { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES); }
|
|
|
|
branch-instructions|branches { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS); }
|
|
|
|
branch-misses { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES); }
|
|
|
|
bus-cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES); }
|
|
|
|
ref-cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES); }
|
|
|
|
cpu-clock { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK); }
|
|
|
|
task-clock { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK); }
|
|
|
|
page-faults|faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS); }
|
|
|
|
minor-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN); }
|
|
|
|
major-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MAJ); }
|
|
|
|
context-switches|cs { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES); }
|
|
|
|
cpu-migrations|migrations { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS); }
|
|
|
|
alignment-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_ALIGNMENT_FAULTS); }
|
|
|
|
emulation-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_EMULATION_FAULTS); }
|
2013-08-31 18:50:52 +00:00
|
|
|
dummy { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_DUMMY); }
|
2012-03-15 19:09:15 +00:00
|
|
|
|
2014-10-07 15:08:51 +00:00
|
|
|
/*
|
|
|
|
* We have to handle the kernel PMU event cycles-ct/cycles-t/mem-loads/mem-stores separately.
|
|
|
|
* Because the prefix cycles is mixed up with cpu-cycles.
|
|
|
|
* loads and stores are mixed up with cache event
|
|
|
|
*/
|
|
|
|
cycles-ct { return str(yyscanner, PE_KERNEL_PMU_EVENT); }
|
|
|
|
cycles-t { return str(yyscanner, PE_KERNEL_PMU_EVENT); }
|
|
|
|
mem-loads { return str(yyscanner, PE_KERNEL_PMU_EVENT); }
|
|
|
|
mem-stores { return str(yyscanner, PE_KERNEL_PMU_EVENT); }
|
|
|
|
|
2012-03-15 19:09:15 +00:00
|
|
|
L1-dcache|l1-d|l1d|L1-data |
|
|
|
|
L1-icache|l1-i|l1i|L1-instruction |
|
|
|
|
LLC|L2 |
|
|
|
|
dTLB|d-tlb|Data-TLB |
|
|
|
|
iTLB|i-tlb|Instruction-TLB |
|
|
|
|
branch|branches|bpu|btb|bpc |
|
2012-06-15 06:31:39 +00:00
|
|
|
node { return str(yyscanner, PE_NAME_CACHE_TYPE); }
|
2012-03-15 19:09:15 +00:00
|
|
|
|
|
|
|
load|loads|read |
|
|
|
|
store|stores|write |
|
|
|
|
prefetch|prefetches |
|
|
|
|
speculative-read|speculative-load |
|
|
|
|
refs|Reference|ops|access |
|
2012-06-15 06:31:39 +00:00
|
|
|
misses|miss { return str(yyscanner, PE_NAME_CACHE_OP_RESULT); }
|
2012-03-15 19:09:15 +00:00
|
|
|
|
2012-05-21 07:12:52 +00:00
|
|
|
mem: { BEGIN(mem); return PE_PREFIX_MEM; }
|
2012-06-15 06:31:39 +00:00
|
|
|
r{num_raw_hex} { return raw(yyscanner); }
|
|
|
|
{num_dec} { return value(yyscanner, 10); }
|
|
|
|
{num_hex} { return value(yyscanner, 16); }
|
2012-03-15 19:09:15 +00:00
|
|
|
|
2012-06-15 06:31:39 +00:00
|
|
|
{modifier_event} { return str(yyscanner, PE_MODIFIER_EVENT); }
|
perf tools: Enable passing bpf object file to --event
By introducing new rules in tools/perf/util/parse-events.[ly], this
patch enables 'perf record --event bpf_file.o' to select events by an
eBPF object file. It calls parse_events_load_bpf() to load that file,
which uses bpf__prepare_load() and finally calls bpf_object__open() for
the object files.
After applying this patch, commands like:
# perf record --event foo.o sleep
become possible.
However, at this point it is unable to link any useful things onto the
evsel list because the creating of probe points and BPF program
attaching have not been implemented. Before real events are possible to
be extracted, to avoid perf report error because of empty evsel list,
this patch link a dummy evsel. The dummy event related code will be
removed when probing and extracting code is ready.
Commiter notes:
Using it:
$ ls -la foo.o
ls: cannot access foo.o: No such file or directory
$ perf record --event foo.o sleep
libbpf: failed to open foo.o: No such file or directory
event syntax error: 'foo.o'
\___ BPF object file 'foo.o' is invalid
(add -v to see detail)
Run 'perf list' for a list of valid events
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-e, --event <event> event selector. use 'perf list' to list available events
$
$ file /tmp/build/perf/perf.o
/tmp/build/perf/perf.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
$ perf record --event /tmp/build/perf/perf.o sleep
libbpf: /tmp/build/perf/perf.o is not an eBPF object file
event syntax error: '/tmp/build/perf/perf.o'
\___ BPF object file '/tmp/build/perf/perf.o' is invalid
(add -v to see detail)
Run 'perf list' for a list of valid events
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-e, --event <event> event selector. use 'perf list' to list available events
$
$ file /tmp/foo.o
/tmp/foo.o: ELF 64-bit LSB relocatable, no machine, version 1 (SYSV), not stripped
$ perf record --event /tmp/foo.o sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.013 MB perf.data ]
$ perf evlist
/tmp/foo.o
$ perf evlist -v
/tmp/foo.o: type: 1, size: 112, config: 0x9, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
$
So, type 1 is PERF_TYPE_SOFTWARE, config 0x9 is PERF_COUNT_SW_DUMMY, ok.
$ perf report --stdio
Error:
The perf.data file has no samples!
# To display the perf.data header info, please use --header/--header-only options.
#
$
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kaixu Xia <xiakaixu@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1444826502-49291-4-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-14 12:41:14 +00:00
|
|
|
{bpf_object} { return str(yyscanner, PE_BPF_OBJECT); }
|
2015-10-14 12:41:20 +00:00
|
|
|
{bpf_source} { return str(yyscanner, PE_BPF_SOURCE); }
|
2014-10-07 15:08:51 +00:00
|
|
|
{name} { return pmu_str_check(yyscanner); }
|
2012-08-16 19:10:21 +00:00
|
|
|
"/" { BEGIN(config); return '/'; }
|
2012-03-15 19:09:15 +00:00
|
|
|
- { return '-'; }
|
2012-08-16 19:10:21 +00:00
|
|
|
, { BEGIN(event); return ','; }
|
2012-03-15 19:09:15 +00:00
|
|
|
: { return ':'; }
|
2012-08-16 19:10:21 +00:00
|
|
|
"{" { BEGIN(event); return '{'; }
|
2012-08-08 10:14:14 +00:00
|
|
|
"}" { return '}'; }
|
2012-03-15 19:09:15 +00:00
|
|
|
= { return '='; }
|
2012-07-03 22:00:39 +00:00
|
|
|
\n { }
|
2013-09-27 16:29:58 +00:00
|
|
|
. { }
|
2012-05-21 07:12:52 +00:00
|
|
|
|
2012-03-15 19:09:15 +00:00
|
|
|
%%
|
|
|
|
|
2012-09-10 22:15:03 +00:00
|
|
|
int parse_events_wrap(void *scanner __maybe_unused)
|
2012-03-15 19:09:15 +00:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|