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

From: Jin, Yao
Date: Thu Jan 21 2021 - 00:14:24 EST

Hi Jiri,

On 1/21/2021 5:25 AM, Jiri Olsa wrote:
On Mon, Jan 18, 2021 at 12:54:37PM +0800, Jin, Yao wrote:
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.


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


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


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.

hm, originaly there's no purpose for the '+', right?
it seems it's more like bug then anything else

Yes, I also don't understand what's the purpose for the '+'. Just a bug is possible.

you added function to the '+' to add default events to specified event,
which I think is good idea, but I don't think we should display the
extra '+' in output

I'm OK to remove the extra '+' in output.

Jin Yao