perf tool: Adding ratios support
cover perf tool: Adding ratios support
hi,
adding support to predefine event ratios formulas so they could be used easily in perf.
The formulas are handed in the config file with following format:
set {
events = {cycles,instructions,branch-instructions}:u cpi {
formula = cycles / instructions
desc = cycles per instruction
}
branch-rate {
formula = branch-instructions / instructions desc = branch rate
}
}
The 'set' defines set of counter that share same events. Each 'set' defines:
events - event string that would go into stat/record -e option
counters - any number of counters based on above events
Each counter (cpi/branch-rate) defines
formula - formula with that produce the counter number
event names and numbers could be used
desc - text description of the counter
The formula can currently contain any event from the set::events plus any number (int). There'll be support in future for outside values runtime and other if needed.
My current thinking is to have generic formulas file(s) for architectural events and add arch-specific ones once when we have the support for non-architectural events (already sent RFC, v2 is on its way..).
Example:
With following formula.conf config file:
---
cpi {
events = {cycles,instructions}:u
CPI {
formula = cycles / instructions
desc = cycles per instruction
}
}
branch {
events = {instructions,branch-instructions,branch-misses}:u branch-rate {
formula = branch-instructions / instructions desc = branch rate
}
branch-miss-rate {
formula = branch-misses / instructions desc = branch misprediction rate
}
branch-miss-ratio{
formula = branch-misses / branch-instructions desc = branch misprediction ratio
}
}
---
You'll get following result:
$ perf stat -f formula.conf:branch kill
usage: kill [ -s signal | -p ] [ -a ] pid ...
kill -l [ signal ]Performance counter stats for 'kill':
184,195 instructions # 0.00 insns per cycle
40,907 branch-instructions
4,815 branch-misses # 11.77% of all branches
0.000655767 seconds time elapsed
0.22208529 branch-rate # branch rate
0.02614077 branch-miss-rate # branch misprediction rate
0.11770602 branch-miss-ratio # branch misprediction ratio
$ perf stat -f formula.conf:cpi kill
usage: kill [ -s signal | -p ] [ -a ] pid ...
kill -l [ signal ]Performance counter stats for 'kill':
356,635 cycles # 0.000 GHz
187,191 instructions # 0.52 insns per cycle0.001907600 seconds time elapsed
1.90519309 CPI # cycles per instruction
Available also at:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/linux.git
perf/ratios2
thanks for any ideas,
jirka
--- tools/perf/Makefile | 11 +++ tools/perf/builtin-stat.c | 61 ++++++++++++++- tools/perf/formula.conf | 28 +++++++ tools/perf/tests/evsel-roundtrip-name.c | 4 +- tools/perf/tests/hists_link.c | 4 +- tools/perf/tests/parse-events.c | 2 +- tools/perf/util/evlist.c | 13 ++++ tools/perf/util/evlist.h | 4 + tools/perf/util/formula.c | 387 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/formula.h | 113 +++++++++++++++++++++++++++ tools/perf/util/formula.l | 119 ++++++++++++++++++++++++++++ tools/perf/util/formula.y | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/parse-events.c | 5 +- tools/perf/util/parse-events.h | 3 +- 14 files changed, 991 insertions(+), 11 deletions(-)
PATCH 1/4 perf tool: Remove unused 'unset' parameter from parse_events
The 'unset' parameter is option callback leftover with no use, removing.
--- tools/perf/tests/evsel-roundtrip-name.c | 4 ++-- tools/perf/tests/hists_link.c | 4 ++-- tools/perf/tests/parse-events.c | 2 +- tools/perf/util/parse-events.c | 5 ++--- tools/perf/util/parse-events.h | 3 +-- 5 files changed, 8 insertions(+), 10 deletions(-)
tools/perf/tests/evsel-roundtrip-name.c +2 -2
@@ -22,7 +22,7 @@ static int perf_evsel__roundtrip_cache_name_test(void)for (i =0 ; i <PERF_COUNT_HW_CACHE_RESULT_MAX ; i++) {__perf_evsel__hw_cache_type_op_res_name (type, op, i, name,sizeof (name)); - err =parse_events (evlist, name,0 ); + err =parse_events (evlist, name);if (err) ret = err; }
@@ -70,7 +70,7 @@ static int __perf_evsel__name_array_test(const char *names[], int nr_names)return -ENOMEM ;for (i =0 ; i < nr_names; ++i) { - err =parse_events (evlist, names[i],0 ); + err =parse_events (evlist, names[i]);if (err) {pr_debug ("failed to parse event '%s', err %d\n" , names[i], err);
tools/perf/tests/hists_link.c +2 -2
@@ -441,10 +441,10 @@ int test__hists_link(void)if (evlist ==NULL )return -ENOMEM ; - err =parse_events (evlist,"cpu-clock" ,0 ); + err =parse_events (evlist,"cpu-clock" );if (err) goto out; - err =parse_events (evlist,"task-clock" ,0 ); + err =parse_events (evlist,"task-clock" );if (err) goto out;
tools/perf/tests/parse-events.c +1 -1
@@ -1018,7 +1018,7 @@ static int test_event(struct test__event_st *e)if (evlist ==NULL )return -ENOMEM ; - ret =parse_events (evlist, e->name,0 ); + ret =parse_events (evlist, e->name);if (ret) {pr_debug ("failed to parse event '%s', err %d\n" , e->name, ret);
tools/perf/util/parse-events.c +2 -3
@@ -872,8 +872,7 @@ int parse_events_terms(struct list_head *terms, const char *str)return ret; } -int parse_events (struct perf_evlist *evlist,const char *str, -int unset__maybe_unused ) +int parse_events (struct perf_evlist *evlist,const char *str) {struct parse_events_data__events data = { .list =LIST_HEAD_INIT (data.list),
@@ -900,7 +899,7 @@ int parse_events_option(const struct option *opt, const char *str, int unset __maybe_unused) {struct perf_evlist *evlist = *(struct perf_evlist **)opt->value; -int ret =parse_events (evlist, str, unset); +int ret =parse_events (evlist, str);if (ret) {fprintf (stderr,"invalid or unsupported event: '%s'\n" , str);
tools/perf/util/parse-events.h +1 -2
@@ -29,8 +29,7 @@ const char *event_type(int type);extern int parse_events_option (const struct option *opt,const char *str,int unset); -extern int parse_events (struct perf_evlist *evlist,const char *str, -int unset); +extern int parse_events (struct perf_evlist *evlist,const char *str);extern int parse_events_terms (struct list_head *terms,const char *str);extern int parse_filter (const struct option *opt,const char *str,int unset);
Signature · 1 line
1.7.11.7
[tip:perf/core] perf tools: Remove unused 'unset' parameter from parse_events
Commit-ID: d8f7bbc947afb59c68a8574d1fe99b20cff2b1be Gitweb: http://git.kernel.org/tip/d8f7bbc947afb59c68a8574d1fe99b20cff2b1be Author: Jiri Olsa <[email protected]> AuthorDate: Tue, 15 Jan 2013 14:39:51 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 24 Jan 2013 16:40:40 -0300
perf tools: Remove unused 'unset' parameter from parse_events
The 'unset' parameter is option callback leftover with no use, removing.
--- tools/perf/tests/evsel-roundtrip-name.c | 4 ++-- tools/perf/tests/hists_link.c | 4 ++-- tools/perf/tests/parse-events.c | 2 +- tools/perf/util/parse-events.c | 5 ++--- tools/perf/util/parse-events.h | 3 +-- 5 files changed, 8 insertions(+), 10 deletions(-)
tools/perf/tests/evsel-roundtrip-name.c +2 -2
@@ -22,7 +22,7 @@ static int perf_evsel__roundtrip_cache_name_test(void)for (i =0 ; i <PERF_COUNT_HW_CACHE_RESULT_MAX ; i++) {__perf_evsel__hw_cache_type_op_res_name (type, op, i, name,sizeof (name)); - err =parse_events (evlist, name,0 ); + err =parse_events (evlist, name);if (err) ret = err; }
@@ -70,7 +70,7 @@ static int __perf_evsel__name_array_test(const char *names[], int nr_names)return -ENOMEM ;for (i =0 ; i < nr_names; ++i) { - err =parse_events (evlist, names[i],0 ); + err =parse_events (evlist, names[i]);if (err) {pr_debug ("failed to parse event '%s', err %d\n" , names[i], err);
tools/perf/tests/hists_link.c +2 -2
@@ -441,10 +441,10 @@ int test__hists_link(void)if (evlist ==NULL )return -ENOMEM ; - err =parse_events (evlist,"cpu-clock" ,0 ); + err =parse_events (evlist,"cpu-clock" );if (err) goto out; - err =parse_events (evlist,"task-clock" ,0 ); + err =parse_events (evlist,"task-clock" );if (err) goto out;
tools/perf/tests/parse-events.c +1 -1
@@ -1018,7 +1018,7 @@ static int test_event(struct test__event_st *e)if (evlist ==NULL )return -ENOMEM ; - ret =parse_events (evlist, e->name,0 ); + ret =parse_events (evlist, e->name);if (ret) {pr_debug ("failed to parse event '%s', err %d\n" , e->name, ret);
tools/perf/util/parse-events.c +2 -3
@@ -872,8 +872,7 @@ int parse_events_terms(struct list_head *terms, const char *str)return ret; } -int parse_events (struct perf_evlist *evlist,const char *str, -int unset__maybe_unused ) +int parse_events (struct perf_evlist *evlist,const char *str) {struct parse_events_data__events data = { .list =LIST_HEAD_INIT (data.list),
@@ -900,7 +899,7 @@ int parse_events_option(const struct option *opt, const char *str, int unset __maybe_unused) {struct perf_evlist *evlist = *(struct perf_evlist **)opt->value; -int ret =parse_events (evlist, str, unset); +int ret =parse_events (evlist, str);if (ret) {fprintf (stderr,"invalid or unsupported event: '%s'\n" , str);
tools/perf/util/parse-events.h +1 -2
@@ -29,8 +29,7 @@ const char *event_type(int type);extern int parse_events_option (const struct option *opt,const char *str,int unset); -extern int parse_events (struct perf_evlist *evlist,const char *str, -int unset); +extern int parse_events (struct perf_evlist *evlist,const char *str);extern int parse_events_terms (struct list_head *terms,const char *str);extern int parse_filter (const struct option *opt,const char *str,int unset);
PATCH 2/4 perf tool: Add formula interface to interface ratio definitions
In reply to Jiri OlsaAdding formula object to interface formula definitions like:
set {
events = {cycles,instructions,branch-instructions}:u
cpi {
formula = cycles / instructions
desc = cycles per instruction
}
branch-rate {
formula = branch-instructions / instructions desc = branch rate
}
}
The 'set' defines set of counter that share same events. Each 'set' defines:
events - event string that would go into stat/record -e option
counters - any number of counters based on above events
Each counter (cpi/branch-rate) defines
formula - formula with that produce the counter number
event names and numbers could be used
desc - text description of the counter
Interface:
perf_formula__init
- initialize perf_formula handler
perf_formula__load
- load file into the handler
perf_formula__free
- cleanup
perf_formula__set
- get 'set' handler
perf_formula__evlist
- update perf_evlist with needed events
perf_formula__print
- display output ratios
--- tools/perf/Makefile | 11 ++ tools/perf/util/evlist.c | 13 ++ tools/perf/util/evlist.h | 4 + tools/perf/util/formula.c | 387 ++++++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/formula.h | 113 ++++++++++++++ tools/perf/util/formula.l | 119 ++++++++++++++ tools/perf/util/formula.y | 248 +++++++++++++++++++++++++++++ 7 files changed, 895 insertions(+) create mode 100644 tools/perf/util/formula.c create mode 100644 tools/perf/util/formula.h create mode 100644 tools/perf/util/formula.l create mode 100644 tools/perf/util/formula.y
tools/perf/Makefile +11 -0
@@ -296,8 +296,15 @@ $(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c $(OUTPUT)util/pmu-bison.c: util/pmu.y $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c +$(OUTPUT)util/formula-flex.c: util/formula.l util/formula.y $(OUTPUT)util/formula-bison.c + $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/formula-flex.h $(PARSER_DEBUG_FLEX) -t util/formula.l > $(OUTPUT)util/formula-flex.c + +$(OUTPUT)util/formula-bison.c: util/formula.y + $(QUIET_BISON)$(BISON) -v util/formula.y -d $(PARSER_DEBUG_BISON) -o $(OUTPUT)util/formula-bison.c + $(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c $(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c +$(OUTPUT)util/formula.o: $(OUTPUT)util/formula-flex.c $(OUTPUT)util/formula-bison.c LIB_FILE=$(OUTPUT)libperf.a
@@ -391,6 +398,7 @@ LIB_H += util/intlist.h LIB_H += util/perf_regs.h LIB_H += util/unwind.h LIB_H += util/vdso.h +LIB_H += util/formula.h LIB_H += ui/helpline.h LIB_H += ui/progress.h LIB_H += ui/util.h
@@ -464,6 +472,9 @@ LIB_OBJS += $(OUTPUT)util/rblist.o LIB_OBJS += $(OUTPUT)util/intlist.o LIB_OBJS += $(OUTPUT)util/vdso.o LIB_OBJS += $(OUTPUT)util/stat.o +LIB_OBJS += $(OUTPUT)util/formula.o +LIB_OBJS += $(OUTPUT)util/formula-flex.o +LIB_OBJS += $(OUTPUT)util/formula-bison.o LIB_OBJS += $(OUTPUT)ui/setup.o LIB_OBJS += $(OUTPUT)ui/helpline.o
tools/perf/util/evlist.c +13 -0
@@ -845,3 +845,16 @@ size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp)return printed +fprintf (fp,"\n" );; } + +struct perf_evsel * +perf_evlist__find_evsel_name (struct perf_evlist *evlist,char *name) +{ +struct perf_evsel *evsel; + +list_for_each_entry (evsel, &evlist->entries, node) { +if (!strcmp (name,perf_evsel__name (evsel))) +return evsel; + } + +return NULL ; +}
tools/perf/util/evlist.h +4 -0
@@ -135,4 +135,8 @@ static inline struct perf_evsel *perf_evlist__last(struct perf_evlist *evlist) }size_t perf_evlist__fprintf (struct perf_evlist *evlist,FILE *fp); + +struct perf_evsel * +perf_evlist__find_evsel_name (struct perf_evlist *evlist,char *name); +#endif /* __PERF_EVLIST_H */
tools/perf/util/formula.c new file +387 -0
387 lines not on this page · raw message
tools/perf/util/formula.h new file +113 -0
113 lines not on this page · raw message
tools/perf/util/formula.l new file +119 -0
119 lines not on this page · raw message
tools/perf/util/formula.y new file +248 -0
248 lines not on this page · raw message
Signature · 1 line
1.7.11.7
PATCH 3/4 perf stat: Adding -f option to load and process ratios
In reply to Jiri OlsaAdding -f option to specify the formula definition to use. Its value needs to be specified in following form:
'file:set'
where 'file' is the formula definition file and the 'set' is the name of the set to use for output.
With following formula.conf config file:
---
cpi {
events = {cycles,instructions}:u
CPI {
formula = cycles / instructions desc = cycles per instruction
}
}
branch {
events = {instructions,branch-instructions,branch-misses}:u branch-rate {
formula = branch-instructions / instructions desc = branch rate
}
branch-miss-rate {
formula = branch-misses / instructions desc = branch misprediction rate
}
branch-miss-ratio{
formula = branch-misses / branch-instructions desc = branch misprediction ratio
}
}
---
You'll get following result:
$ perf stat -f formula.conf:branch kill
usage: kill [ -s signal | -p ] [ -a ] pid ...
kill -l [ signal ]Performance counter stats for 'kill':
184,195 instructions # 0.00 insns per cycle
40,907 branch-instructions
4,815 branch-misses # 11.77% of all branches
0.000655767 seconds time elapsed
0.22208529 branch-rate # branch rate
0.02614077 branch-miss-rate # branch misprediction rate
0.11770602 branch-miss-ratio # branch misprediction ratio
$ perf stat -f formula.conf:cpi kill
usage: kill [ -s signal | -p ] [ -a ] pid ...
kill -l [ signal ]Performance counter stats for 'kill':
356,635 cycles # 0.000 GHz
187,191 instructions # 0.52 insns per cycle0.001907600 seconds time elapsed
1.90519309 CPI # cycles per instruction
--- tools/perf/builtin-stat.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-)
tools/perf/builtin-stat.c +60 -1
@@ -56,6 +56,7 @@#include "util/cpumap.h" #include "util/thread.h" #include "util/thread_map.h" +#include "util/formula.h" #include <stdlib.h> #include <sys/prctl.h>
@@ -67,6 +68,9 @@static struct perf_evlist *evsel_list; +static struct perf_formula formula; +static struct perf_formula__set *formula_set; +static struct perf_target target = { .uid =UINT_MAX , };
@@ -1065,6 +1069,42 @@ static int add_default_attributes(void)return perf_evlist__add_default_attrs (evsel_list, very_very_detailed_attrs); } +static int formula_option (const struct option *opt__maybe_unused , +const char *str,int unset__maybe_unused ) +{ +char *name; + +if (no_aggr) { +pr_err ("failed to run formulas with no aggr mode\n" ); +return -1 ; + } + + name =strrchr (str,':' ); +if (!name) { +pr_err ("need to specify set name\n" ); +return -1 ; + } + + *name++ =0x0 ; + +pr_debug ("formula file '%s', name '%s'\n" , str, name); + +perf_formula__init (&formula); + +if (perf_formula__load (&formula, (char *) str)) { +pr_err ("failed to load formula file '%s'\n" , str); +return -1 ; + } + + formula_set =perf_formula__set (&formula, name); +if (!formula_set) { +pr_err ("failed to find formula counter '%s'\n" , name); +return -1 ; + } + +return 0 ; +} +int cmd_stat (int argc,const char **argv,const char *prefix__maybe_unused ) {bool append_file = false;
@@ -1076,6 +1116,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) parse_events_option),OPT_CALLBACK (0 ,"filter" , &evsel_list,"filter" ,"event filter" , parse_filter), +OPT_CALLBACK ('f' ,"formula" ,NULL ,"formula" , +"counters formula, file[:name]" , + formula_option),OPT_BOOLEAN ('i' ,"no-inherit" , &no_inherit,"child tasks do not inherit counters" ), OPT_STRING('p', "pid", &target.pid, "pid",
@@ -1134,6 +1177,12 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) argc =parse_options (argc, argv, options, stat_usage,PARSE_OPT_STOP_AT_NON_OPTION ); +if (formula_set && +perf_formula__evlist (formula_set, evsel_list)) { +fprintf (stderr,"failed to load formula events\n" ); +usage_with_options (stat_usage, options); + } + output = stderr;if (output_name &&strcmp (output_name,"-" )) output =NULL ;
@@ -1242,13 +1291,23 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) status =run_perf_stat (argc, argv); } -if (status !=-1 ) +if (status !=-1 ) {print_stat (argc, argv); + +if (formula_set) +perf_formula__print (output, formula_set, + evsel_list,NULL ); + } + out_free_fd:list_for_each_entry (pos, &evsel_list->entries, node)perf_evsel__free_stat_priv (pos);perf_evlist__delete_maps (evsel_list); out:perf_evlist__delete (evsel_list); + +if (formula_set) +perf_formula__free (&formula); +return status; }
Signature · 1 line
1.7.11.7
PATCH 4/4 perf tool: Adding formula.conf file for testing
In reply to Jiri Olsa--- tools/perf/formula.conf | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tools/perf/formula.conf
tools/perf/formula.conf new file +28 -0
@@ -0,0 +1,28 @@ + +cpi { + events = {cycles,instructions}:u + + CPI { + formula = cycles / instructions + desc = cycles per instruction + } +} + +branch { + events = {instructions,branch-instructions,branch-misses}:u + + branch-rate { + formula = branch-instructions / instructions + desc = branch rate + } + + branch-miss-rate { + formula = branch-misses / instructions + desc = branch misprediction rate + } + + branch-miss-ratio{ + formula = branch-misses / branch-instructions + desc = branch misprediction ratio + } +}
Signature · 1 line
1.7.11.7
Quoted 1 line · Jiri Olsa
hi,
Hi Jiri,
Quoted 24 lines
adding support to predefine event ratios formulas so they could be used easily in perf.
The formulas are handed in the config file with following format:
set { events = {cycles,instructions,branch-instructions}:ucpi {
formula = cycles / instructions
desc = cycles per instruction
}branch-rate {
formula = branch-instructions / instructions desc = branch rate
}
}The 'set' defines set of counter that share same events. Each 'set' defines:
events - event string that would go into stat/record -e option
counters - any number of counters based on above events
Quoted 8 lines
Each counter (cpi/branch-rate) defines
formula - formula with that produce the counter number
event names and numbers could be used
desc - text description of the counterThe formula can currently contain any event from the
set::eventsplus any number (int). There'll be support in future for outside values runtime and other if needed.
Just to say that I *really* like this idea! If we extended it to include other operators then it would help us on ARM, where we often have events like 'cache accesses' and 'cache misses' but not 'cache hits'.
Quoted 3 lines
My current thinking is to have generic formulas file(s) for architectural events and add arch-specific ones once when we have the support for non-architectural events (already sent RFC, v2 is on its way..).
Would the architectural formula files also be in userspace, or is there any merit to including useful PMU-specific formulae in sysfs, along with the other PMU files?
Cheers,
Will
Quoted 34 lines · Will Deacon
Quoted 1 line · Jiri Olsa
hi,
Hi Jiri,
Quoted 29 lines
adding support to predefine event ratios formulas so they could be used easily in perf.
The formulas are handed in the config file with following format:
set { events = {cycles,instructions,branch-instructions}:ucpi {
formula = cycles / instructions
desc = cycles per instruction
}branch-rate {
formula = branch-instructions / instructions desc = branch rate
}
}The 'set' defines set of counter that share same events. Each 'set' defines:
events - event string that would go into stat/record -e option
counters - any number of counters based on above eventsEach counter (cpi/branch-rate) defines
formula - formula with that produce the counter number
event names and numbers could be used
desc - text description of the counter
Quoted 7 lines
Quoted 3 lines
The formula can currently contain any event from the
set::eventsplus any number (int). There'll be support in future for outside values runtime and other if needed.Just to say that I *really* like this idea! If we extended it to include other operators then it would help us on ARM, where we often have events like 'cache accesses' and 'cache misses' but not 'cache hits'.
great, thanks for sharing this
The current operators set is just basic one to show the idea, it can/will be expanded.
Quoted 8 lines
Quoted 4 lines
My current thinking is to have generic formulas file(s) for architectural events and add arch-specific ones once when we have the support for non-architectural events (already sent RFC, v2 is on its way..).
Would the architectural formula files also be in userspace, or is there any merit to including useful PMU-specific formulae in sysfs, along with the other PMU files?
hum, isn't this too specific for sysfs files?
I think that's going to be the perf tool specific info.. so it's going to be placed in its configuration files.
jirka
Quoted 6 lines · Jiri Olsa
Quoted 5 lines · Will Deacon
Quoted 3 lines · Jiri Olsa
The formula can currently contain any event from the
set::eventsplus any number (int). There'll be support in future for outside values runtime and other if needed.
Quoted 8 lines
Quoted 3 lines
Just to say that I *really* like this idea! If we extended it to include other operators then it would help us on ARM, where we often have events like 'cache accesses' and 'cache misses' but not 'cache hits'.
great, thanks for sharing this
The current operators set is just basic one to show the idea, it can/will be expanded.
Makes sense.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
My current thinking is to have generic formulas file(s) for architectural events and add arch-specific ones once when we have the support for non-architectural events (already sent RFC, v2 is on its way..).
Quoted 8 lines
Quoted 3 lines
Would the architectural formula files also be in userspace, or is there any merit to including useful PMU-specific formulae in sysfs, along with the other PMU files?
hum, isn't this too specific for sysfs files?
I think that's going to be the perf tool specific info.. so it's going to be placed in its configuration files.
Understood. It would just be nice if the ARM perf backend could implement more of the generic events, which would be possible if the kernel could expose these formulae for those. Plumbing that together probably still requires userspace changes though, in which case it's not worth it.
Will
Quoted 11 lines · Will Deacon
Quoted 10 lines · Jiri Olsa
Quoted 8 lines · Will Deacon
Quoted 3 lines · Jiri Olsa
The formula can currently contain any event from the
set::eventsplus any number (int). There'll be support in future for outside values runtime and other if needed.Just to say that I *really* like this idea! If we extended it to include other operators then it would help us on ARM, where we often have events like 'cache accesses' and 'cache misses' but not 'cache hits'.
Quoted 6 lines
Quoted 4 lines
great, thanks for sharing this
The current operators set is just basic one to show the idea, it can/will be expanded.
Makes sense.
any particular operators you'd like to see in?
jirka
Quoted 12 lines · Jiri Olsa
Quoted 11 lines · Will Deacon
Quoted 10 lines · Jiri Olsa
Quoted 8 lines · Will Deacon
Quoted 3 lines · Jiri Olsa
The formula can currently contain any event from the
set::eventsplus any number (int). There'll be support in future for outside values runtime and other if needed.Just to say that I *really* like this idea! If we extended it to include other operators then it would help us on ARM, where we often have events like 'cache accesses' and 'cache misses' but not 'cache hits'.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
great, thanks for sharing this
The current operators set is just basic one to show the idea, it can/will be expanded.
Makes sense.
any particular operators you'd like to see in?
I think the basic: add, subtract, divide operators are the most useful to start with.
Cheers,
Will
Quoted 3 lines · Jiri Olsa
$ perf stat -f formula.conf:cpi kill
usage: kill [ -s signal | -p ] [ -a ] pid ...
kill -l [ signal ]I do like this proposal. The only comment I have is that perhaps the command line syntax isn't ideal. What you use above is tied to the ratios be defined in the config file. I would imagine that at least over time (for some ratios probably right away) they become available by default and don't require a config file. Also, users might want to put individualized ratio definitions in a config file which is read by default.
How about the formulas becoming available whenever the config file is read. Maybe this means a few more keywords in the config file (ratio, ratio-set, ...). E.g.:
ratio-set branch {
events = {instructions,branch-instructions,branch-misses}:u
ratio branch-rate {
formula = branch-instructions / instructions desc = branch rate
}
ratio branch-miss-rate {
formula = branch-misses / instructions desc = branch misprediction rate
}
ratio branch-miss-ratio{
formula = branch-misses / branch-instructions desc = branch misprediction ratio
}
}
You get the idea. Maybe substitute "ratio":with "formula". Then allow such a ratio/formula to be used just like a normal event, perhaps with a special suffix/prefix to designate it. This should then also mark the events as part of a group so that the underlying counters are scheduled in together.
Quoted 30 lines · Ulrich Drepper
Quoted 3 lines · Jiri Olsa
$ perf stat -f formula.conf:cpi kill usage: kill [ -s signal | -p ] [ -a ] pid ... kill -l [ signal ]I do like this proposal. The only comment I have is that perhaps the command line syntax isn't ideal. What you use above is tied to the ratios be defined in the config file. I would imagine that at least over time (for some ratios probably right away) they become available by default and don't require a config file. Also, users might want to put individualized ratio definitions in a config file which is read by default.
How about the formulas becoming available whenever the config file is read. Maybe this means a few more keywords in the config file (ratio, ratio-set, ...). E.g.:
ratio-set branch {
events = {instructions,branch-instructions,branch-misses}:uratio branch-rate {
formula = branch-instructions / instructions desc = branch rate
}ratio branch-miss-rate {
formula = branch-misses / instructions desc = branch misprediction rate
}
Quoted 5 lines
ratio branch-miss-ratio{
formula = branch-misses / branch-instructions desc = branch misprediction ratio
}
}
I was thinking having config files (global and arch specific) comming with perf having predefined formulas.
Plus adding the possibility to load extra config file via command line option.
Quoted 4 lines
You get the idea. Maybe substitute "ratio":with "formula". Then allow such a ratio/formula to be used just like a normal event, perhaps with a special suffix/prefix to designate it. This should then also mark
I like the idea of having ratios handled within event definitions maybe even in a similar way like aliases are handled today.. like:
1) -e 'ratio/branch-rate/' # special event class 2) -e 'ratio-branch-rate' # 'ratio-' prefix 3) -e cpu/branch-rate/ # handled like aliases, ratio name would need to be unique
... ?
ideas?
Having both 2) with 3) seems good to me
Quoted 2 lines
the events as part of a group so that the underlying counters are scheduled in together.
the 'events' definitions could be put into group by default, meanwhile I used 'events = { ... }'
thanks,
jirka
Quoted 2 lines · Jiri Olsa
I was thinking having config files (global and arch specific) comming with perf having predefined formulas.
All the more reason to not mention the file name or really any source for the definition of the formula in the name,
Quoted 4 lines
1) -e 'ratio/branch-rate/' # special event class 2) -e 'ratio-branch-rate' # 'ratio-' prefix 3) -e cpu/branch-rate/ # handled like aliases, ratio name would need to be unique... ?
I think 3 is the most extensible. Perhaps use the syntax used in other places. We have these :u suffixes etc. Perhaps have :r or :R or whatever.
Given the other comments, we might want to avoid right away "ratio". If the mechanism is generalized it could be used to express "counter1
- counter2" for events which cannot be expressed with a single counter but are not really ratios.
Namhyung Kim
maintainerHi,
Quoted 8 lines · Ulrich Drepper
Quoted 2 lines · Jiri Olsa
I was thinking having config files (global and arch specific) comming with perf having predefined formulas.
All the more reason to not mention the file name or really any source for the definition of the formula in the name,
Quoted 8 lines
Quoted 4 lines
1) -e 'ratio/branch-rate/' # special event class 2) -e 'ratio-branch-rate' # 'ratio-' prefix 3) -e cpu/branch-rate/ # handled like aliases, ratio name would need to be unique... ?
I think 3 is the most extensible. Perhaps use the syntax used in other places. We have these :u suffixes etc. Perhaps have :r or :R or whatever.
I don't think it's a good idea. The ':r' syntax is for modifiers to the existing events so it doesn't match to this case IMHO.
I prefer a special event class like 1 since it's possible to include non-cpu events to a ratio/formular. In that case, using 'cpu' in the PMU name can be misleading.
Quoted 5 lines
Given the other comments, we might want to avoid right away "ratio". If the mechanism is generalized it could be used to express "counter1
- counter2" for events which cannot be expressed with a single counter but are not really ratios.
Agreed. Looks like "formular" is better.
Thanks,
Namhyung
Quoted 28 lines · Namhyung Kim
Hi,
Quoted 8 lines · Ulrich Drepper
Quoted 2 lines · Jiri Olsa
I was thinking having config files (global and arch specific) comming with perf having predefined formulas.
All the more reason to not mention the file name or really any source for the definition of the formula in the name,
Quoted 8 lines
Quoted 4 lines
1) -e 'ratio/branch-rate/' # special event class 2) -e 'ratio-branch-rate' # 'ratio-' prefix 3) -e cpu/branch-rate/ # handled like aliases, ratio name would need to be unique... ?
I think 3 is the most extensible. Perhaps use the syntax used in other places. We have these :u suffixes etc. Perhaps have :r or :R or whatever.
I don't think it's a good idea. The ':r' syntax is for modifiers to the existing events so it doesn't match to this case IMHO.
I prefer a special event class like 1 since it's possible to include non-cpu events to a ratio/formular. In that case, using 'cpu' in the PMU name can be misleading.
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Given the other comments, we might want to avoid right away "ratio". If the mechanism is generalized it could be used to express "counter1
- counter2" for events which cannot be expressed with a single counter but are not really ratios.Agreed. Looks like "formular" is better.
agreed, I think I wouldn't touch modifiers for this also, 'ratio' is not good choice, formula seems better
jirka