Re: [PATCH] perf env: Find correct branch counter info on hybrid

From: Arnaldo Carvalho de Melo
Date: Wed Sep 11 2024 - 12:05:00 EST


On Wed, Sep 11, 2024 at 12:58:16PM -0300, Arnaldo Carvalho de Melo wrote:
> On Wed, Sep 11, 2024 at 11:41:54AM -0400, Liang, Kan wrote:
> > On 2024-09-11 10:19 a.m., Arnaldo Carvalho de Melo wrote:
> > > On Mon, Sep 09, 2024 at 11:42:00AM -0700, kan.liang@xxxxxxxxxxxxxxx wrote:
> > >> From: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
> > >>
> > >> No event is printed in the "Branch Counter" column on hybrid machines.
> > >>
> > >> For example,
> > >> $perf record -e "{cpu_core/branch-instructions/pp,cpu_core/branches/}:S"
> > >> -j any,counter
> > >> $perf report --total-cycles
> > >
> > > So I tried this on an Intel Hybrid system, I start the TUI, then try 'B'
> > > and, after applying your patch:
> > >
> > > 0.66% 67.8K 0.00% 75 ┌─Branch counter abbr list────────────┐ibc_write+18] libc.so.6
> > > 0.63% 65.4K 0.00% 106 [p│ │r_active+159] [kernel.kallsyms]
> > > 0.61% 63.2K 0.01% 175 [native_queued_spi│ The branch counter is not available.│in_lock_slowpath+528] [kernel.kallsyms]
> > > 0.57% 58.4K 0.00% 39 [syscall_ex│Press any key... │ser_mode+109] [kernel.kallsyms]
> > > 0.54% 55.6K 0.00% 1 [_IO_file_xsputn@@└─────────────────────────────────────┘BC_2.2.5+316] libc.so.6
> > >
> > > The perf.data was obtained from:
> > >
> > > root@number:~# perf record -e "{cpu_core/branch-instructions/pp,cpu_core/branches/}:S" -j any,counter find /
> > >
> > > And:
> > >
> > > root@number:~# perf evlist --group
> > > {cpu_core/branch-instructions/pp,cpu_core/branches/}
> > > dummy:u
> > > root@number:~#
> > >
> > > Only mishap above we discussed already, the missing :S, and then:
> > >
> > > root@number:~# perf evlist -v
> > > cpu_core/branch-instructions/pp: type: 4 (cpu_core), size: 136, config: 0xc4 (branch-instructions), { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|READ|PERIOD|BRANCH_STACK|IDENTIFIER, read_format: ID|GROUP|LOST, disabled: 1, freq: 1, enable_on_exec: 1, precise_ip: 2, sample_id_all: 1, exclude_guest: 1, branch_sample_type: ANY
> >
> > For a hybrid client, the "Branch Counter" feature is only supported
> > starting from the just released Lunar Lake. Perf falls back to only
> > "ANY" on your Raptor Lake.
> >
> > The "The branch counter is not available" message is expected.
> >
> > Here is the perf evlist result from my Lunar Lake machine,
> >
> > #perf evlist -v
> > cpu_core/branch-instructions/pp: type: 4 (cpu_core), size: 136, config:
> > 0xc4 (branch-instructions), { sample_period, sample_freq }: 4000,
> > sample_type: IP|TID|TIME|READ|PERIOD|BRANCH_STACK|IDENTIFIER,
> > read_format: ID|GROUP|LOST, disabled: 1, freq: 1, enable_on_exec: 1,
> > precise_ip: 2, sample_id_all: 1, exclude_guest: 1, branch_sample_type:
> > ANY|COUNTERS
>
> So I'll just take the patch and add these explanations there, ok?

Added this:

Committer notes:

While testing I couldn't s ee those "Branch counter" columns enabled by
pressing 'B' on the TUI, after reporting it to the list Kan explained
the situation:

<quote Kan Liang>
For a hybrid client, the "Branch Counter" feature is only supported
starting from the just released Lunar Lake. Perf falls back to only
"ANY" on your Raptor Lake.

The "The branch counter is not available" message is expected.

Here is the 'perf evlist' result from my Lunar Lake machine,

# perf evlist -v
cpu_core/branch-instructions/pp: type: 4 (cpu_core), size: 136, config: 0xc4 (branch-instructions), { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|READ|PERIOD|BRANCH_STACK|IDENTIFIER, read_format: ID|GROUP|LOST, disabled: 1, freq: 1, enable_on_exec: 1, precise_ip: 2, sample_id_all: 1, exclude_guest: 1, branch_sample_type: ANY|COUNTERS
#
</quote>