Re: [PATCH v2] perf stat: Append to default list if use -e +event

From: Jin, Yao
Date: Sun Jan 17 2021 - 23:58:25 EST


Hi Jiri,

On 1/12/2021 6:08 PM, Jiri Olsa wrote:
On Mon, Jan 04, 2021 at 10:18:37AM +0800, Jin Yao wrote:
The default event list includes the most common events which are widely
used by users. But with -e option, the current perf only counts the events
assigned by -e option. Users may want to collect some extra events with
the default list. For this case, users have to manually add all the events
from the default list. It's inconvenient. Also, users may don't know how to
get the default list.

Now it supports a simple syntax: -e +event

The prefix '+' tells perf to append this event (or event list) to default
event list.

Before:

root@kbl-ppc:~# ./perf stat -e power/energy-pkg/ -a -- sleep 1

Performance counter stats for 'system wide':

2.04 Joules power/energy-pkg/

1.000863884 seconds time elapsed

After:

root@kbl-ppc:~# ./perf stat -e +power/energy-pkg/ -a -- sleep 1

Performance counter stats for 'system wide':

2.11 Joules +power/energy-pkg/ # 0.000 K/sec

I dont think we should print the extra '+' prefix

jirka

8,007.17 msec cpu-clock # 7.993 CPUs utilized
125 context-switches # 0.016 K/sec
8 cpu-migrations # 0.001 K/sec
2 page-faults # 0.000 K/sec
8,520,084 cycles # 0.001 GHz
2,808,302 instructions # 0.33 insn per cycle
555,427 branches # 0.069 M/sec
59,005 branch-misses # 10.62% of all branches

1.001832003 seconds time elapsed

Signed-off-by: Jin Yao <yao.jin@xxxxxxxxxxxxxxx>


Printing '+' prefix is the original behavior.

Without this patch,

root@kbl-ppc:# ./perf stat -e +power/energy-pkg/ -a -- sleep 1

Performance counter stats for 'system wide':

2.02 Joules +power/energy-pkg/

1.000859434 seconds time elapsed

The '+' prefix is printed. So I finally decide not to remove the '+' prefix in order to keep original behavior.

Thanks
Jin Yao