perf tool: Return all events as auto-completions after comma
PATCH 1/1 perf tool: Return all events as auto-completions after comma
It's a follow up patch for one previous patch "perf tool: Improve bash command line auto-complete for multiple events with comma."
It fixes an issue that no events are displayed when <TAB> is directly typed after comma.
With this patch, now the result is:
root@skl:/tmp# perf stat -e cpu-cycles,<TAB> Display all 2389 possibilities? (y or n) alarmtimer:alarmtimer_cancel alarmtimer:alarmtimer_fired alarmtimer:alarmtimer_start alarmtimer:alarmtimer_suspend alignment-faults arith.divider_active BAClear_Cost baclears.any block:block_bio_backmerge block:block_bio_bounce block:block_bio_complete block:block_bio_frontmerge block:block_bio_queue block:block_bio_remap block:block_dirty_buffer block:block_getrq block:block_plug block:block_rq_complete block:block_rq_insert block:block_rq_issue block:block_rq_remap block:block_rq_requeue block:block_sleeprq --More--
One remaining issue is that the auto-completions doesn't work well for the event with ':'. For example, clk:clk_enable.
Because ':' is set as WORDBREAK by default in bash. Need more work for this case.
--- tools/perf/perf-completion.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
tools/perf/perf-completion.sh +7 -3
@@ -183,12 +183,16 @@ __perf_main () fi done - evts=${result}+$(ls /sys/bus/event_source/devices/cpu/events) + evts=${result}" "$(ls /sys/bus/event_source/devices/cpu/events) else - evts=${raw_evts}+$(ls /sys/bus/event_source/devices/cpu/events) + evts=${raw_evts}" "$(ls /sys/bus/event_source/devices/cpu/events) fi - __perfcomp_colon "$evts" "$cur1" + if [[ "$cur1" == , ]]; then + __perfcomp_colon "$evts" "" + else + __perfcomp_colon "$evts" "$cur1" + fi else # List subcommands for perf commands if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerEm Fri, Dec 22, 2017 at 06:57:35PM +0800, Jin Yao escreveu:
Quoted 5 lines
It's a follow up patch for one previous patch "perf tool: Improve bash command line auto-complete for multiple events with comma."
It fixes an issue that no events are displayed when <TAB> is directly typed after comma.
<SNIP>
Quoted 5 lines
One remaining issue is that the auto-completions doesn't work well for the event with ':'. For example, clk:clk_enable.
Because ':' is set as WORDBREAK by default in bash. Need more work for this case.
Thanks, tested and applied.
One other thing you may want to look at:
$ $ perf record -e cycles/<TAB>
Should present the modifiers, i.e. these:
/*
* Update according to parse-events.l
*/
static const char *config_term_names[__PARSE_EVENTS__TERM_TYPE_NR] = {
[PARSE_EVENTS__TERM_TYPE_USER] = "<sysfs term>",
[PARSE_EVENTS__TERM_TYPE_CONFIG] = "config",
[PARSE_EVENTS__TERM_TYPE_CONFIG1] = "config1",
[PARSE_EVENTS__TERM_TYPE_CONFIG2] = "config2",
[PARSE_EVENTS__TERM_TYPE_NAME] = "name",
[PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD] = "period",
[PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ] = "freq",
[PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE] = "branch_type",
[PARSE_EVENTS__TERM_TYPE_TIME] = "time",
[PARSE_EVENTS__TERM_TYPE_CALLGRAPH] = "call-graph",
[PARSE_EVENTS__TERM_TYPE_STACKSIZE] = "stack-size",
[PARSE_EVENTS__TERM_TYPE_NOINHERIT] = "no-inherit",
[PARSE_EVENTS__TERM_TYPE_INHERIT] = "inherit",
[PARSE_EVENTS__TERM_TYPE_MAX_STACK] = "max-stack",
[PARSE_EVENTS__TERM_TYPE_OVERWRITE] = "overwrite",
[PARSE_EVENTS__TERM_TYPE_NOOVERWRITE] = "no-overwrite",
[PARSE_EVENTS__TERM_TYPE_DRV_CFG] = "driver-config",};
:-)
- Arnaldo
Quoted 28 lines
One other thing you may want to look at:
$ $ perf record -e cycles/<TAB>Should present the modifiers, i.e. these:
/*
* Update according to parse-events.l
*/
static const char *config_term_names[__PARSE_EVENTS__TERM_TYPE_NR] = {[PARSE_EVENTS__TERM_TYPE_USER] = "<sysfs term>", [PARSE_EVENTS__TERM_TYPE_CONFIG] = "config", [PARSE_EVENTS__TERM_TYPE_CONFIG1] = "config1", [PARSE_EVENTS__TERM_TYPE_CONFIG2] = "config2", [PARSE_EVENTS__TERM_TYPE_NAME] = "name", [PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD] = "period", [PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ] = "freq", [PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE] = "branch_type", [PARSE_EVENTS__TERM_TYPE_TIME] = "time", [PARSE_EVENTS__TERM_TYPE_CALLGRAPH] = "call-graph", [PARSE_EVENTS__TERM_TYPE_STACKSIZE] = "stack-size", [PARSE_EVENTS__TERM_TYPE_NOINHERIT] = "no-inherit", [PARSE_EVENTS__TERM_TYPE_INHERIT] = "inherit", [PARSE_EVENTS__TERM_TYPE_MAX_STACK] = "max-stack", [PARSE_EVENTS__TERM_TYPE_OVERWRITE] = "overwrite", [PARSE_EVENTS__TERM_TYPE_NOOVERWRITE] = "no-overwrite", [PARSE_EVENTS__TERM_TYPE_DRV_CFG] = "driver-config",
Quoted 6 lines
};
:-)
- Arnaldo
Hi Arnaldo,
Currently, in my understanding, the modifiers appended to an event are:
u/k/h/I/G/H/p/...
For example,
perf stat -e cycles:u
Does perf support the modifiers like "cycles/config" or "cycles/config1", or ..., "cycles/driver-config" now?
I tried some command lines but they were failed. Maybe my used format was not correct.
Or do you mean the format like "cpu/xxx"? For example, perf stat -e cpu/event=0x0e,umask=0x1,inv/ -a sleep 1
Anyway, if we want to implement the auto-completion for the modifiers, it'd better expose them by an interface (e.g. perf list --xx) rather than hardcode them in auto-completion script. That's my initial idea.
Thanks
Jin Yao
tip-bot for Jin Yao
merge bot[tip:perf/core] perf tools: Return all events as auto-completions after comma
In reply to Jin Yaoperf tools: Return all events as auto-completions after comma
Commit-ID: 34c16db0f035f3f3dc50fbed03747693c12b6a5b Gitweb: https://git.kernel.org/tip/34c16db0f035f3f3dc50fbed03747693c12b6a5b Author: Jin Yao <[email protected]> AuthorDate: Fri, 22 Dec 2017 18:57:35 +0800 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 27 Dec 2017 12:15:59 -0300
perf tools: Return all events as auto-completions after comma
It's a follow up for one previous patch "perf tool: Improve bash command line auto-complete for multiple events with comma."
It fixes an issue that no events are displayed when <TAB> is directly typed after comma.
With this patch, now the result is:
root@skl:/tmp# perf stat -e cpu-cycles,<TAB> Display all 2389 possibilities? (y or n) alarmtimer:alarmtimer_cancel alarmtimer:alarmtimer_fired alarmtimer:alarmtimer_start alarmtimer:alarmtimer_suspend alignment-faults arith.divider_active BAClear_Cost baclears.any block:block_bio_backmerge block:block_bio_bounce block:block_bio_complete block:block_bio_frontmerge block:block_bio_queue block:block_bio_remap block:block_dirty_buffer block:block_getrq block:block_plug block:block_rq_complete block:block_rq_insert block:block_rq_issue block:block_rq_remap block:block_rq_requeue block:block_sleeprq --More--
One remaining issue is that the auto-completions doesn't work well for the event with ':'. For example, clk:clk_enable.
Because ':' is set as WORDBREAK by default in bash. Need more work for this case.
--- tools/perf/perf-completion.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
tools/perf/perf-completion.sh +7 -3
@@ -183,12 +183,16 @@ __perf_main () fi done - evts=${result}+$(ls /sys/bus/event_source/devices/cpu/events) + evts=${result}" "$(ls /sys/bus/event_source/devices/cpu/events) else - evts=${raw_evts}+$(ls /sys/bus/event_source/devices/cpu/events) + evts=${raw_evts}" "$(ls /sys/bus/event_source/devices/cpu/events) fi - __perfcomp_colon "$evts" "$cur1" + if [[ "$cur1" == , ]]; then + __perfcomp_colon "$evts" "" + else + __perfcomp_colon "$evts" "$cur1" + fi else # List subcommands for perf commands if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|