perf stat: Support --all-kernel and --all-user
cover perf stat: Support --all-kernel and --all-user
This patch series supports the new options "--all-kernel" and "--all-user" in perf-stat.
For example,
root@kbl:~# perf stat -e cycles,instructions --all-kernel --all-user -a -- sleep 1
Performance counter stats for 'system wide':
19,156,665 cycles:k
7,265,342 instructions:k # 0.38 insn per cycle
4,511,186,293 cycles:u
121,881,436 instructions:u # 0.03 insn per cycle1.001153540 seconds time elapsed
root@kbl:~# perf stat -a --topdown --all-kernel -- sleep 1
Performance counter stats for 'system wide':
retiring:k bad speculation:k frontend bound:k backend bound:k
S0-D0-C0 2 7.6% 1.8% 40.5% 50.0% S0-D0-C1 2 15.4% 3.4% 14.4% 66.8% S0-D0-C2 2 15.8% 5.1% 26.9% 52.2% S0-D0-C3 2 5.7% 5.7% 46.2% 42.4%
1.000771709 seconds time elapsed
More detail information are in the patch descriptions.
Jin Yao (2):
perf stat: Support --all-kernel and --all-user options perf stat: Support topdown with --all-kernel/--all-user
tools/perf/Documentation/perf-record.txt | 3 +- tools/perf/Documentation/perf-stat.txt | 7 + tools/perf/builtin-stat.c | 200 ++++++++++++++++++++++- tools/perf/util/stat-shadow.c | 167 ++++++++++++++----- tools/perf/util/stat.h | 23 +++ 5 files changed, 353 insertions(+), 47 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/2 perf stat: Support --all-kernel and --all-user options
perf record has supported --all-kernel / --all-user to configure all used events to run in kernel space or in user space. But perf stat doesn't support that. It would be useful to support these options so that we can collect metrics for e.g. user space only without having to type ":u" in the events manually.
Also it would be useful if --all-user / --all-kernel could be specified together, and the tool would automatically add two copies of the events, so that we get a break down between user and kernel.
Since we need to support specifying both --all-user and --all-kernel together, we can't do as what the perf record does for supporting --all-user / --all-kernel (it sets attr->exclude_kernel and attr->exclude_user).
This patch uses another solution which appends the modifiers ":u"/":k" to event string.
For example,
perf stat -e cycles,instructions --all-user --all-kernel
It's automatically expanded to:
perf stat -e cycles:k,instructions:k,cycles:u,instructions:u
More examples,
root@kbl:~# perf stat -e cycles --all-kernel --all-user -a -- sleep 1
Performance counter stats for 'system wide':
20,884,637 cycles:k
4,511,494,722 cycles:u
1.000891147 seconds time elapsedroot@kbl:~# perf stat -e cycles,instructions --all-kernel --all-user -a -- sleep 1
Performance counter stats for 'system wide':
19,156,665 cycles:k
7,265,342 instructions:k # 0.38 insn per cycle
4,511,186,293 cycles:u
121,881,436 instructions:u # 0.03 insn per cycle1.001153540 seconds time elapsed
root@kbl:~# perf stat -e "{cycles,instructions}" --all-kernel --all-user -a -- sleep 1Performance counter stats for 'system wide':
16,230,472 cycles:k
5,357,549 instructions:k # 0.33 insn per cycle
4,510,695,030 cycles:u
122,097,780 instructions:u # 0.03 insn per cycle1.000933419 seconds time elapsed
root@kbl:~# perf stat -e "{cycles,instructions},{cache-misses,cache-references}" --all-kernel --all-user -a -- sleep 1Performance counter stats for 'system wide':
111,688,302 cycles:k (74.81%)
24,322,238 instructions:k # 0.22 insn per cycle (74.81%)
1,115,414 cache-misses:k # 21.292 % of all cache refs (75.02%)
5,238,665 cache-references:k (75.02%)
4,506,792,681 cycles:u (75.22%)
124,199,635 instructions:u # 0.03 insn per cycle (75.22%)
43,846,543 cache-misses:u # 62.616 % of all cache refs (74.97%)
70,024,231 cache-references:u (74.97%)1.001186804 seconds time elapsed
Note:
1. This patch can only configure the specified events (-e xxx) to run in user space or in kernel space. For supporting other options, such as --topdown, need follow-up patches.
2. In perf-record, it has already supported the --all-kernel and --all-user, but they can't be combined. We should keep the behavior consistent among all perf subtools. So if this patch can be accepted, will post follow-up patches for supporting other subtools for the same behavior.
--- tools/perf/Documentation/perf-record.txt | 3 +- tools/perf/Documentation/perf-stat.txt | 7 + tools/perf/builtin-stat.c | 163 ++++++++++++++++++++++- tools/perf/util/stat.h | 11 ++ 4 files changed, 182 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-record.txt +2 -1
@@ -495,7 +495,8 @@ Produce compressed trace using specified level n (default: 1 - fastest compressi Configure all used events to run in kernel space. --all-user:: -Configure all used events to run in user space. +Configure all used events to run in user space. The --all-kernel +and --all-user can't be combined. --kernel-callchains:: Collect callchains only from kernel space. I.e. this option sets
tools/perf/Documentation/perf-stat.txt +7 -0
@@ -323,6 +323,13 @@ The output is SMI cycles%, equals to (aperf - unhalted core cycles) / aperf Users who wants to get the actual value can apply --no-metric-only. +--all-kernel:: +Configure all specified events to run in kernel space. + +--all-user:: +Configure all specified events to run in user space. The --all-kernel +and --all-user can be combined. + EXAMPLES --------
tools/perf/builtin-stat.c +162 -1
198 lines not on this page · raw message
tools/perf/util/stat.h +11 -0
@@ -93,6 +93,13 @@ struct runtime_stat {typedef int (*aggr_get_id_t )(struct perf_stat_config *config,struct perf_cpu_map *m,int cpu); +struct perf_stat_event_opt { +const struct option *opt; +const char *event_str; +}; + +#define PERF_STAT_EVENT_OPT_MAX 128 +struct perf_stat_config {enum aggr_mode aggr_mode;bool scale;
@@ -106,6 +113,8 @@ struct perf_stat_config {bool big_num;bool no_merge;bool walltime_run_table; +bool all_kernel; +bool all_user;FILE *output;unsigned int interval;unsigned int timeout;
@@ -126,6 +135,8 @@ struct perf_stat_config {struct perf_cpu_map *cpus_aggr_map;u64 *walltime_run;struct rblist metric_events; +struct perf_stat_event_opt event_opt[PERF_STAT_EVENT_OPT_MAX ]; +int opt_num; };void update_stats (struct stats *stats,u64 val);
Signature · 1 line
2.17.1
PATCH 2/2 perf stat: Support topdown with --all-kernel/--all-user
In reply to Jin YaoWhen perf stat --topdown is enabled, the internal event list is expanded to:
"{topdown-total-slots,topdown-slots-retired,topdown-recovery-bubbles,topdown-fetch-bubbles,topdown-slots-issued}".
With this patch,
1. When --all-user is enabled, it's expanded to:
"{topdown-total-slots:u,topdown-slots-retired:u,topdown-recovery-bubbles:u,topdown-fetch-bubbles:u,topdown-slots-issued:u}"
2. When --all-kernel is enabled, it's expanded to:
"{topdown-total-slots:k,topdown-slots-retired:k,topdown-recovery-bubbles:k,topdown-fetch-bubbles:k,topdown-slots-issued:k}"
3. Both are enabled, it's expanded to:
"{topdown-total-slots:k,topdown-slots-retired:k,topdown-recovery-bubbles:k,topdown-fetch-bubbles:k,topdown-slots-issued:k},{topdown-total-slots:u,topdown-slots-retired:u,topdown-recovery-bubbles:u,topdown-fetch-bubbles:u,topdown-slots-issued:u}"
This patch creates new topdown stat type (STAT_TOPDOWN_XXX_K / STAT_TOPDOWN_XXX_U), and save the event counting value to type related entry in runtime_stat rblist.
For example,
root@kbl:~# perf stat -a --topdown --all-kernel -- sleep 1
Performance counter stats for 'system wide':
retiring:k bad speculation:k frontend bound:k backend bound:k
S0-D0-C0 2 7.6% 1.8% 40.5% 50.0% S0-D0-C1 2 15.4% 3.4% 14.4% 66.8% S0-D0-C2 2 15.8% 5.1% 26.9% 52.2% S0-D0-C3 2 5.7% 5.7% 46.2% 42.4%
1.000771709 seconds time elapsed
root@kbl:~# perf stat -a --topdown --all-user -- sleep 1
Performance counter stats for 'system wide':
retiring:u bad speculation:u frontend bound:u backend bound:u
S0-D0-C0 2 0.5% 0.0% 0.0% 99.4% S0-D0-C1 2 5.7% 5.8% 77.7% 10.7% S0-D0-C2 2 15.5% 20.5% 35.8% 28.2% S0-D0-C3 2 14.1% 0.5% 1.5% 83.9%
1.000773028 seconds time elapsed
--- tools/perf/builtin-stat.c | 37 +++++++- tools/perf/util/stat-shadow.c | 167 +++++++++++++++++++++++++--------- tools/perf/util/stat.h | 12 +++ 3 files changed, 171 insertions(+), 45 deletions(-)
tools/perf/builtin-stat.c +36 -1
@@ -1436,7 +1436,8 @@ static int add_default_attributes(void)if (topdown_run) {char *str =NULL ; -bool warn = false; +bool warn = false, append_uk = false; +struct strbuf new_str;if (stat_config.aggr_mode !=AGGR_GLOBAL && stat_config.aggr_mode !=AGGR_CORE ) {
@@ -1457,6 +1458,21 @@ static int add_default_attributes(void)return -1 ; }if (topdown_attrs[0 ] && str) { +int ret; + +if (stat_config.all_kernel || stat_config.all_user) { + ret =append_modifier (&new_str, str, + stat_config.all_kernel, + stat_config.all_user); +if (ret) +return ret; + +free (str); + str =strbuf_detach (&new_str,NULL ); +strbuf_release (&new_str); + append_uk = true; + } +if (warn)arch_topdown_group_warn (); err =parse_events (evsel_list, str, &errinfo);
@@ -1468,6 +1484,25 @@ static int add_default_attributes(void)free (str);return -1 ; } + +if (append_uk) { +struct evsel *evsel; +char *p; + +evlist__for_each_entry (evsel_list, evsel) { +/* +* We appended the modifiers ":u"/":k" +* to evsel->name. Since the events have +* been parsed, remove the appended +* modifiers from event name here. +*/ +if (evsel->name) { + p =strchr (evsel->name,':' ); +if (p) + *p =0 ; + } + } + } }else {fprintf (stderr,"System does not support topdown\n" );return -1 ;
tools/perf/util/stat-shadow.c +123 -44
256 lines not on this page · raw message
tools/perf/util/stat.h +12 -0
@@ -60,6 +60,8 @@ enum {#define NUM_CTX CTX_BIT_MAX +#define STAT_TOPDOWN_NUM 5 +enum stat_type {STAT_NONE =0 ,STAT_NSECS ,
@@ -81,6 +83,16 @@ enum stat_type {STAT_TOPDOWN_SLOTS_RETIRED ,STAT_TOPDOWN_FETCH_BUBBLES ,STAT_TOPDOWN_RECOVERY_BUBBLES , +STAT_TOPDOWN_TOTAL_SLOTS_K , +STAT_TOPDOWN_SLOTS_ISSUED_K , +STAT_TOPDOWN_SLOTS_RETIRED_K , +STAT_TOPDOWN_FETCH_BUBBLES_K , +STAT_TOPDOWN_RECOVERY_BUBBLES_K , +STAT_TOPDOWN_TOTAL_SLOTS_U , +STAT_TOPDOWN_SLOTS_ISSUED_U , +STAT_TOPDOWN_SLOTS_RETIRED_U , +STAT_TOPDOWN_FETCH_BUBBLES_U , +STAT_TOPDOWN_RECOVERY_BUBBLES_U ,STAT_SMI_NUM ,STAT_APERF ,STAT_MAX
Signature · 1 line
2.17.1
Quoted 5 lines · Jin Yao
This patch series supports the new options "--all-kernel" and "--all-user" in perf-stat.
For example,
Quoted 8 lines
root@kbl:~# perf stat -e cycles,instructions --all-kernel --all-user -a -- sleep 1Performance counter stats for 'system wide':
19,156,665 cycles:k 7,265,342 instructions:k # 0.38 insn per cycle 4,511,186,293 cycles:u 121,881,436 instructions:u # 0.03 insn per cycle
hi,
I think we should follow --all-kernel/--all-user behaviour from record command, adding extra events seems like unnecesary complexity to me
jirka
Quoted 32 lines
1.001153540 seconds time elapsedroot@kbl:~# perf stat -a --topdown --all-kernel -- sleep 1Performance counter stats for 'system wide':
retiring:k bad speculation:k frontend bound:k backend bound:k
S0-D0-C0 2 7.6% 1.8% 40.5% 50.0% S0-D0-C1 2 15.4% 3.4% 14.4% 66.8% S0-D0-C2 2 15.8% 5.1% 26.9% 52.2% S0-D0-C3 2 5.7% 5.7% 46.2% 42.4%1.000771709 seconds time elapsedMore detail information are in the patch descriptions.
Jin Yao (2):
perf stat: Support --all-kernel and --all-user options perf stat: Support topdown with --all-kernel/--all-usertools/perf/Documentation/perf-record.txt | 3 +- tools/perf/Documentation/perf-stat.txt | 7 + tools/perf/builtin-stat.c | 200 ++++++++++++++++++++++- tools/perf/util/stat-shadow.c | 167 ++++++++++++++----- tools/perf/util/stat.h | 23 +++ 5 files changed, 353 insertions(+), 47 deletions(-)Signature · 1 line
2.17.1
Quoted 10 lines · Jiri Olsa
Quoted 9 lines · Jin Yao
This patch series supports the new options "--all-kernel" and "--all-user" in perf-stat.
For example,
root@kbl:~# perf stat -e cycles,instructions --all-kernel --all-user -a -- sleep 1Performance counter stats for 'system wide':
Quoted 8 lines
Quoted 4 lines
19,156,665 cycles:k 7,265,342 instructions:k # 0.38 insn per cycle 4,511,186,293 cycles:u 121,881,436 instructions:u # 0.03 insn per cyclehi,
I think we should follow --all-kernel/--all-user behaviour from record command, adding extra events seems like unnecesary complexity to me
I think it's useful. Makes it easy to do kernel/user break downs. perf record should support the same.
-Andi
Em Mon, Sep 30, 2019 at 11:21:36AM -0700, Andi Kleen escreveu:
Quoted 16 lines · Jiri Olsa
Quoted 14 lines · Jin Yao
Quoted 13 lines
This patch series supports the new options "--all-kernel" and "--all-user" in perf-stat.
For example,
root@kbl:~# perf stat -e cycles,instructions --all-kernel --all-user -a -- sleep 1Performance counter stats for 'system wide':
19,156,665 cycles:k 7,265,342 instructions:k # 0.38 insn per cycle 4,511,186,293 cycles:u 121,881,436 instructions:u # 0.03 insn per cycle
Quoted 5 lines
Quoted 2 lines
I think we should follow --all-kernel/--all-user behaviour from record command, adding extra events seems like unnecesary complexity to me
I think it's useful. Makes it easy to do kernel/user break downs. perf record should support the same.
Don't we have this already with:
[root@quaco ~]# perf stat -e cycles:u,instructions:u,cycles:k,instructions:k -a -- sleep 1
Performance counter stats for 'system wide':
69,937,445 cycles:u
23,459,595 instructions:u # 0.34 insn per cycle
51,040,704 cycles:k
11,368,152 instructions:k # 0.22 insn per cycle1.002887417 seconds time elapsed
[root@quaco ~]# perf record -e cycles:u,instructions:u,cycles:k,instructions:k -a -- sleep 1 [ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.340 MB perf.data (927 samples) ] [root@quaco ~]# perf evlist
cycles:u
instructions:u
cycles:k
instructions:k
[root@quaco ~]#
To make it shorter we could have:
tools/perf/util/parse-events.l +2 -2
@@ -313,11 +313,11 @@ aux-output { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_AUX_OUTPUT); } <<EOF>> { BEGIN(INITIAL); } } -cpu-cycles|cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES); } +cpu-cycles|cycles|cyc { 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); } +instructions|insn|ins { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS); } 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); }
And another thing that comes to mind is to make -M metrics be accepted as -e arg, as someone suggested recently (Andi?), and also make it set its events honouring the :k or :u modifiers:
[root@quaco ~]# perf stat -M ipc
^C
Performance counter stats for 'system wide':
15,030,011 inst_retired.any # 0.3 IPC
54,449,797 cpu_clk_unhalted.thread
1.186531715 seconds time elapsed[root@quaco ~]# perf stat -M ipc:k,ipc:u
Cannot find metric or group `ipc:k'
Usage: perf stat [<options>] [<command>]
-M, --metrics <metric/metric group list>
monitor specified metrics or metric groups (separated by ,)
[root@quaco ~]#
- Arnaldo
Quoted 6 lines
Quoted 2 lines
I think it's useful. Makes it easy to do kernel/user break downs. perf record should support the same.
Don't we have this already with:
[root@quaco ~]# perf stat -e cycles:u,instructions:u,cycles:k,instructions:k -a -- sleep 1
This only works for simple cases. Try it for --topdown or multiple -M metrics.
-Andi
Quoted 11 lines · Andi Kleen
Quoted 6 lines
Quoted 2 lines
I think it's useful. Makes it easy to do kernel/user break downs. perf record should support the same.
Don't we have this already with:
[root@quaco ~]# perf stat -e cycles:u,instructions:u,cycles:k,instructions:k -a -- sleep 1
This only works for simple cases. Try it for --topdown or multiple -M metrics.
-Andi
Hi Arnaldo, Jiri,
We think it should be very useful if --all-user / --all-kernel can be specified together, so that we can get a break down between user and kernel easily.
But yes, the patches for supporting this new semantics is much complicated than the patch which just follows original perf-record behavior. I fully understand this concern.
So if this new semantics can be accepted, that would be very good. But if you think the new semantics is too complicated, I'm also fine for posting a new patch which just follows the perf-record behavior.
Thanks
Jin Yao
Quoted 21 lines · Yao
Quoted 11 lines · Andi Kleen
Quoted 6 lines
Quoted 2 lines
I think it's useful. Makes it easy to do kernel/user break downs. perf record should support the same.
Don't we have this already with:
[root@quaco ~]# perf stat -e cycles:u,instructions:u,cycles:k,instructions:k -a -- sleep 1
This only works for simple cases. Try it for --topdown or multiple -M metrics.
-Andi
Hi Arnaldo, Jiri,
We think it should be very useful if --all-user / --all-kernel can be specified together, so that we can get a break down between user and kernel easily.
Quoted 7 lines
But yes, the patches for supporting this new semantics is much complicated than the patch which just follows original perf-record behavior. I fully understand this concern.
So if this new semantics can be accepted, that would be very good. But if you think the new semantics is too complicated, I'm also fine for posting a new patch which just follows the perf-record behavior.
I still need to think a bit more about this.. did you consider other options like cloning of the perf_evlist/perf_evsel and changing just the exclude* bits? might be event worse actualy ;-)
or maybe if we add modifier we could add extra events/groups within the parser.. like:
"{cycles,instructions}:A,{cache-misses,cache-references}:A,cycles:A"
but that might be still more complicated then what you did
also please add the perf record changes so we have same code and logic for both if we are going to change it
jirka
Quoted 26 lines · Jiri Olsa
Quoted 25 lines · Yao
Quoted 11 lines · Andi Kleen
Quoted 6 lines
Quoted 2 lines
I think it's useful. Makes it easy to do kernel/user break downs. perf record should support the same.
Don't we have this already with:
[root@quaco ~]# perf stat -e cycles:u,instructions:u,cycles:k,instructions:k -a -- sleep 1
This only works for simple cases. Try it for --topdown or multiple -M metrics.
-Andi
Hi Arnaldo, Jiri,
We think it should be very useful if --all-user / --all-kernel can be specified together, so that we can get a break down between user and kernel easily.
But yes, the patches for supporting this new semantics is much complicated than the patch which just follows original perf-record behavior. I fully understand this concern.
Quoted 8 lines
Quoted 3 lines
So if this new semantics can be accepted, that would be very good. But if you think the new semantics is too complicated, I'm also fine for posting a new patch which just follows the perf-record behavior.
I still need to think a bit more about this.. did you consider other options like cloning of the perf_evlist/perf_evsel and changing just the exclude* bits? might be event worse actualy ;-)
That should be another approach, but it might be a bit more complicated than just appending ":u"/":k" modifiers to the event name string.
Quoted 7 lines
or maybe if we add modifier we could add extra events/groups within the parser.. like:
"{cycles,instructions}:A,{cache-misses,cache-references}:A,cycles:A"
but that might be still more complicated then what you did
Yes agree.
Quoted 3 lines
also please add the perf record changes so we have same code and logic for both if we are going to change it
If this new semantics can be accepted, I'd like to add perf record supporting as well. :)
Another difficulty for the new semantics is we need to create user and kernel stat type in runtime_stat rblist (see patch "perf stat: Support topdown with --all-kernel/--all-user"). That has to bring extra complexity.
Thanks
Jin Yao
Quoted 2 lines
jirka
Em Thu, Oct 10, 2019 at 04:33:57PM +0800, Jin, Yao escreveu:
Quoted 49 lines · Jiri Olsa
Quoted 26 lines · Yao
Quoted 25 lines · Andi Kleen
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines
I think it's useful. Makes it easy to do kernel/user break downs. perf record should support the same.
Don't we have this already with:
[root@quaco ~]# perf stat -e cycles:u,instructions:u,cycles:k,instructions:k -a -- sleep 1
This only works for simple cases. Try it for --topdown or multiple -M metrics.
-Andi
Hi Arnaldo, Jiri,
We think it should be very useful if --all-user / --all-kernel can be specified together, so that we can get a break down between user and kernel easily.
But yes, the patches for supporting this new semantics is much complicated than the patch which just follows original perf-record behavior. I fully understand this concern.
Quoted 8 lines
Quoted 3 lines
So if this new semantics can be accepted, that would be very good. But if you think the new semantics is too complicated, I'm also fine for posting a new patch which just follows the perf-record behavior.
I still need to think a bit more about this.. did you consider other options like cloning of the perf_evlist/perf_evsel and changing just the exclude* bits? might be event worse actualy ;-)
That should be another approach, but it might be a bit more complicated than just appending ":u"/":k" modifiers to the event name string.
Quoted 7 lines
or maybe if we add modifier we could add extra events/groups within the parser.. like:
"{cycles,instructions}:A,{cache-misses,cache-references}:A,cycles:A"
but that might be still more complicated then what you did
Quoted 7 lines
Yes agree.
Quoted 2 lines
also please add the perf record changes so we have same code and logic for both if we are going to change it
If this new semantics can be accepted, I'd like to add perf record supporting as well. :)
Changes in semantics should be avoided, when we add an option already present in some other tool, we should strive to keep the semantics, so that people can reuse their knowledge and just switch tools to go from sampling to counting, say.
So if at all possible, and without having really looked deep in this specific case, I would prefer that new semantics come with a new syntax, would that be possible?
- Arnaldo
Quoted 9 lines
Another difficulty for the new semantics is we need to create user and kernel stat type in
runtime_statrblist (see patch "perf stat: Support topdown with --all-kernel/--all-user"). That has to bring extra complexity.Thanks
Jin YaoQuoted 2 lines
jirka
Signature · 1 line
- Arnaldo
Quoted 55 lines · Arnaldo Carvalho de Melo
Em Thu, Oct 10, 2019 at 04:33:57PM +0800, Jin, Yao escreveu:
Quoted 53 lines · Jiri Olsa
Quoted 26 lines · Yao
Quoted 25 lines · Andi Kleen
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines
I think it's useful. Makes it easy to do kernel/user break downs. perf record should support the same.
Don't we have this already with:
[root@quaco ~]# perf stat -e cycles:u,instructions:u,cycles:k,instructions:k -a -- sleep 1
This only works for simple cases. Try it for --topdown or multiple -M metrics.
-Andi
Hi Arnaldo, Jiri,
We think it should be very useful if --all-user / --all-kernel can be specified together, so that we can get a break down between user and kernel easily.
But yes, the patches for supporting this new semantics is much complicated than the patch which just follows original perf-record behavior. I fully understand this concern.
Quoted 8 lines
Quoted 3 lines
So if this new semantics can be accepted, that would be very good. But if you think the new semantics is too complicated, I'm also fine for posting a new patch which just follows the perf-record behavior.
I still need to think a bit more about this.. did you consider other options like cloning of the perf_evlist/perf_evsel and changing just the exclude* bits? might be event worse actualy ;-)
That should be another approach, but it might be a bit more complicated than just appending ":u"/":k" modifiers to the event name string.
Quoted 7 lines
or maybe if we add modifier we could add extra events/groups within the parser.. like:
"{cycles,instructions}:A,{cache-misses,cache-references}:A,cycles:A"
but that might be still more complicated then what you did
Yes agree.
Quoted 2 lines
also please add the perf record changes so we have same code and logic for both if we are going to change it
Quoted 8 lines
Quoted 2 lines
If this new semantics can be accepted, I'd like to add perf record supporting as well. :)
Changes in semantics should be avoided, when we add an option already present in some other tool, we should strive to keep the semantics, so that people can reuse their knowledge and just switch tools to go from sampling to counting, say.
Yes, that makes sense. We need to try our best to keep the original semantics. I will post a patch for perf-stat which just follows the semantics in perf-record.
Quoted 4 lines
So if at all possible, and without having really looked deep in this specific case, I would prefer that new semantics come with a new syntax, would that be possible?
Yes, that's possible. Maybe we can use a new option for automatically adding two copies of the events (one copy for user and the other copy for kernel). The option something like "--all-space"?
Thanks
Jin Yao
Quoted 15 lines
- Arnaldo
Quoted 9 lines
Another difficulty for the new semantics is we need to create user and kernel stat type in
runtime_statrblist (see patch "perf stat: Support topdown with --all-kernel/--all-user"). That has to bring extra complexity.Thanks
Jin YaoQuoted 2 lines
jirka
Quoted 70 lines · Yao
Quoted 54 lines · Arnaldo Carvalho de Melo
Em Thu, Oct 10, 2019 at 04:33:57PM +0800, Jin, Yao escreveu:
Quoted 53 lines · Jiri Olsa
Quoted 26 lines · Yao
Quoted 25 lines · Andi Kleen
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines
I think it's useful. Makes it easy to do kernel/user break downs. perf record should support the same.
Don't we have this already with:
[root@quaco ~]# perf stat -e cycles:u,instructions:u,cycles:k,instructions:k -a -- sleep 1
This only works for simple cases. Try it for --topdown or multiple -M metrics.
-Andi
Hi Arnaldo, Jiri,
We think it should be very useful if --all-user / --all-kernel can be specified together, so that we can get a break down between user and kernel easily.
But yes, the patches for supporting this new semantics is much complicated than the patch which just follows original perf-record behavior. I fully understand this concern.
Quoted 8 lines
Quoted 3 lines
So if this new semantics can be accepted, that would be very good. But if you think the new semantics is too complicated, I'm also fine for posting a new patch which just follows the perf-record behavior.
I still need to think a bit more about this.. did you consider other options like cloning of the perf_evlist/perf_evsel and changing just the exclude* bits? might be event worse actualy ;-)
That should be another approach, but it might be a bit more complicated than just appending ":u"/":k" modifiers to the event name string.
Quoted 7 lines
or maybe if we add modifier we could add extra events/groups within the parser.. like:
"{cycles,instructions}:A,{cache-misses,cache-references}:A,cycles:A"
but that might be still more complicated then what you did
Yes agree.
Quoted 2 lines
also please add the perf record changes so we have same code and logic for both if we are going to change it
Quoted 8 lines
Quoted 2 lines
If this new semantics can be accepted, I'd like to add perf record supporting as well. :)
Changes in semantics should be avoided, when we add an option already present in some other tool, we should strive to keep the semantics, so that people can reuse their knowledge and just switch tools to go from sampling to counting, say.
Yes, that makes sense. We need to try our best to keep the original semantics. I will post a patch for perf-stat which just follows the semantics in perf-record.
Quoted 8 lines
Quoted 4 lines
So if at all possible, and without having really looked deep in this specific case, I would prefer that new semantics come with a new syntax, would that be possible?
Yes, that's possible. Maybe we can use a new option for automatically adding two copies of the events (one copy for user and the other copy for kernel). The option something like "--all-space"?
some other ideas:
--all
--uk
--both
--full
-e {cycles,cache-misses}:A,cycles,instructions:A
-e {cycles,cache-misses}:B,cycles,instructions:B
--duplicate-every-event-or-group-of-events-for-each-address-space ;-)jirka
Quoted 90 lines · Jiri Olsa
Quoted 70 lines · Yao
Quoted 54 lines · Arnaldo Carvalho de Melo
Em Thu, Oct 10, 2019 at 04:33:57PM +0800, Jin, Yao escreveu:
Quoted 53 lines · Jiri Olsa
Quoted 26 lines · Yao
Quoted 25 lines · Andi Kleen
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines
I think it's useful. Makes it easy to do kernel/user break downs. perf record should support the same.
Don't we have this already with:
[root@quaco ~]# perf stat -e cycles:u,instructions:u,cycles:k,instructions:k -a -- sleep 1
This only works for simple cases. Try it for --topdown or multiple -M metrics.
-Andi
Hi Arnaldo, Jiri,
We think it should be very useful if --all-user / --all-kernel can be specified together, so that we can get a break down between user and kernel easily.
But yes, the patches for supporting this new semantics is much complicated than the patch which just follows original perf-record behavior. I fully understand this concern.
Quoted 8 lines
Quoted 3 lines
So if this new semantics can be accepted, that would be very good. But if you think the new semantics is too complicated, I'm also fine for posting a new patch which just follows the perf-record behavior.
I still need to think a bit more about this.. did you consider other options like cloning of the perf_evlist/perf_evsel and changing just the exclude* bits? might be event worse actualy ;-)
That should be another approach, but it might be a bit more complicated than just appending ":u"/":k" modifiers to the event name string.
Quoted 7 lines
or maybe if we add modifier we could add extra events/groups within the parser.. like:
"{cycles,instructions}:A,{cache-misses,cache-references}:A,cycles:A"
but that might be still more complicated then what you did
Yes agree.
Quoted 2 lines
also please add the perf record changes so we have same code and logic for both if we are going to change it
Quoted 8 lines
Quoted 2 lines
If this new semantics can be accepted, I'd like to add perf record supporting as well. :)
Changes in semantics should be avoided, when we add an option already present in some other tool, we should strive to keep the semantics, so that people can reuse their knowledge and just switch tools to go from sampling to counting, say.
Yes, that makes sense. We need to try our best to keep the original semantics. I will post a patch for perf-stat which just follows the semantics in perf-record.
Quoted 8 lines
Quoted 4 lines
So if at all possible, and without having really looked deep in this specific case, I would prefer that new semantics come with a new syntax, would that be possible?
Yes, that's possible. Maybe we can use a new option for automatically adding two copies of the events (one copy for user and the other copy for kernel). The option something like "--all-space"?
some other ideas:
--all --uk --both --full -e {cycles,cache-misses}:A,cycles,instructions:A -e {cycles,cache-misses}:B,cycles,instructions:B --duplicate-every-event-or-group-of-events-for-each-address-space ;-)
Quoted 2 lines
jirka
I like '--uk'. :)
Thanks
Jin Yao