linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf tool: Return all events as auto-completions after comma
@ 2017-12-22 10:57 Jin Yao
  2017-12-22 12:14 ` Arnaldo Carvalho de Melo
  2017-12-28 15:36 ` [tip:perf/core] perf tools: " tip-bot for Jin Yao
  0 siblings, 2 replies; 4+ messages in thread
From: Jin Yao @ 2017-12-22 10:57 UTC (permalink / raw)
  To: acme, jolsa, peterz, mingo, alexander.shishkin
  Cc: Linux-kernel, ak, kan.liang, yao.jin, Jin Yao

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.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
 tools/perf/perf-completion.sh | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh
index d831083..9020641 100644
--- a/tools/perf/perf-completion.sh
+++ b/tools/perf/perf-completion.sh
@@ -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|
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf tool: Return all events as auto-completions after comma
  2017-12-22 10:57 [PATCH] perf tool: Return all events as auto-completions after comma Jin Yao
@ 2017-12-22 12:14 ` Arnaldo Carvalho de Melo
  2017-12-25  2:57   ` Jin, Yao
  2017-12-28 15:36 ` [tip:perf/core] perf tools: " tip-bot for Jin Yao
  1 sibling, 1 reply; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-12-22 12:14 UTC (permalink / raw)
  To: Jin Yao
  Cc: jolsa, peterz, mingo, alexander.shishkin, Linux-kernel, ak,
	kan.liang, yao.jin

Em Fri, Dec 22, 2017 at 06:57:35PM +0800, Jin Yao escreveu:
> 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>
 
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf tool: Return all events as auto-completions after comma
  2017-12-22 12:14 ` Arnaldo Carvalho de Melo
@ 2017-12-25  2:57   ` Jin, Yao
  0 siblings, 0 replies; 4+ messages in thread
From: Jin, Yao @ 2017-12-25  2:57 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: jolsa, peterz, mingo, alexander.shishkin, Linux-kernel, ak,
	kan.liang, yao.jin


> 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
> 

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:perf/core] perf tools: Return all events as auto-completions after comma
  2017-12-22 10:57 [PATCH] perf tool: Return all events as auto-completions after comma Jin Yao
  2017-12-22 12:14 ` Arnaldo Carvalho de Melo
@ 2017-12-28 15:36 ` tip-bot for Jin Yao
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Jin Yao @ 2017-12-28 15:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: alexander.shishkin, tglx, yao.jin, peterz, jolsa, kan.liang,
	linux-kernel, mingo, hpa, acme, ak

Commit-ID:  34c16db0f035f3f3dc50fbed03747693c12b6a5b
Gitweb:     https://git.kernel.org/tip/34c16db0f035f3f3dc50fbed03747693c12b6a5b
Author:     Jin Yao <yao.jin@linux.intel.com>
AuthorDate: Fri, 22 Dec 2017 18:57:35 +0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1513940255-16528-1-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/perf-completion.sh | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh
index d831083..9020641 100644
--- a/tools/perf/perf-completion.sh
+++ b/tools/perf/perf-completion.sh
@@ -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|

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-28 15:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-22 10:57 [PATCH] perf tool: Return all events as auto-completions after comma Jin Yao
2017-12-22 12:14 ` Arnaldo Carvalho de Melo
2017-12-25  2:57   ` Jin, Yao
2017-12-28 15:36 ` [tip:perf/core] perf tools: " tip-bot for Jin Yao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).