Subject: Re: [PATCHv4 bpf-next 0/2] perf tools: Fix prologue generation

From: Jiri Olsa <[email-masked]>
Date: Thu, 16 Jun 2022 00:12:10 +0200

On Wed, Jun 15, 2022 at 09:36:34PM +0200, Jiri Olsa wrote:
> On Wed, Jun 15, 2022 at 12:27:03PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Sun, Jun 12, 2022 at 06:25:09PM +0200, Jiri Olsa escreveu:
> > > so the problem is that we prepend init proglogue instructions
> > > for each program not just for the one that needs it, so it will
> > > mismatch later on.. the fix below makes it work for me
> > 
> > > Arnaldo,
> > > I squashed and pushed the change below changes to my bpf/depre
> > > branch, could you please retest?
> > 
> > Before:
> > 
> > [acme@quaco perf-urgent]$ git log --oneline -5
> > e2cf9d315f90670f (HEAD -> perf/urgent, five/perf/urgent) perf test topology: Use !strncmp(right platform) to fix guest PPC comparision check
> > 42e4fb08ff987b50 perf test: Record only user callchains on the "Check Arm64 callgraphs are complete in fp mode" test
> > 819d5c3cf75d0f95 perf beauty: Update copy of linux/socket.h with the kernel sources
> > ebdc02b3ece8238b perf test: Fix variable length array undefined behavior in bp_account
> > 8ff58c35adb7f118 libperf evsel: Open shouldn't leak fd on failure
> > [acme@quaco perf-urgent]$ sudo su -
> > [root@quaco ~]# perf -v
> > perf version 5.19.rc2.ge2cf9d315f90
> > [root@quaco ~]# perf test bpf
> >  40: LLVM search and compile                                         :
> >  40.1: Basic BPF llvm compile                                        : Ok
> >  40.3: Compile source for BPF prologue generation                    : Ok
> >  40.4: Compile source for BPF relocation                             : Ok
> >  42: BPF filter                                                      :
> >  42.1: Basic BPF filtering                                           : Ok
> >  42.2: BPF pinning                                                   : Ok
> >  42.3: BPF prologue generation                                       : Ok
> >  63: Test libpfm4 support                                            :
> >  96: perf stat --bpf-counters test                                   : Ok
> > [root@quaco ~]#
> > 
> > After your first patch:
> > 
> > [acme@quaco perf-urgent]$ git log --oneline -5 jolsa/bpf/depre
> > 9317b879db422632 (jolsa/bpf/depre) perf tools: Rework prologue generation code
> > 4d40831f29f2c9ad perf tools: Register fallback libbpf section handler
> > f913ad6559e337b4 libbpf: Fix is_pow_of_2
> > f175ece2e3436748 selftests/bpf: Fix tc_redirect_dtime
> > 7b711e721234f475 bpf, test_run: Remove unnecessary prog type checks
> > [acme@quaco perf-urgent]$ git cherry-pick 4d40831f29f2c9ad
> > [perf/urgent ab39fb6880b57507] perf tools: Register fallback libbpf section handler
> >  Author: Jiri Olsa <[email-masked]>
> >  Date: Thu Apr 21 15:22:25 2022 +0200
> >  1 file changed, 65 insertions(+), 11 deletions(-)
> > [acme@quaco perf-urgent]$
> > [acme@quaco perf-urgent]$ alias m='rm -rf ~/libexec/perf-core/ ; perf stat -e cycles:u,instructions:u make -k BUILD_BPF_SKEL=1 PYTHON=python3 O=/tmp/build/perf-urgent -C tools/perf install-bin && perf test python'
> > [acme@quaco perf-urgent]$ rm -rf /tmp/build/perf-urgent ; mkdir -p /tmp/build/perf-urgent ; m
> > <SNIP>
> >  19: 'import perf' in python                                         : Ok
> > [acme@quaco perf-urgent]$
> > [acme@quaco perf-urgent]$ sudo su -
> > [sudo] password for acme:
> > [root@quaco ~]# perf test bpf
> >  40: LLVM search and compile                                         :
> >  40.1: Basic BPF llvm compile                                        : Ok
> >  40.3: Compile source for BPF prologue generation                    : Ok
> >  40.4: Compile source for BPF relocation                             : Ok
> >  42: BPF filter                                                      :
> >  42.1: Basic BPF filtering                                           : Ok
> >  42.2: BPF pinning                                                   : Ok
> >  42.3: BPF prologue generation                                       : FAILED!
> >  63: Test libpfm4 support                                            :
> >  96: perf stat --bpf-counters test                                   : Ok
> > [root@quaco ~]#
> > 
> > perf test -v bpf later, lets see if landing the second patch fixes
> > things and this bisection problem is justified:
> > 
> > [acme@quaco perf-urgent]$ git log --oneline -5 jolsa/bpf/depre
> > 9317b879db422632 (jolsa/bpf/depre) perf tools: Rework prologue generation code
> > 4d40831f29f2c9ad perf tools: Register fallback libbpf section handler
> > f913ad6559e337b4 libbpf: Fix is_pow_of_2
> > f175ece2e3436748 selftests/bpf: Fix tc_redirect_dtime
> > 7b711e721234f475 bpf, test_run: Remove unnecessary prog type checks
> > [acme@quaco perf-urgent]$ git remote update jolsa
> > Fetching jolsa
> > [acme@quaco perf-urgent]$ git cherry-pick 9317b879db422632
> > [perf/urgent 9a36c7c94e1f596d] perf tools: Rework prologue generation code
> >  Author: Jiri Olsa <[email-masked]>
> >  Date: Mon May 9 22:46:20 2022 +0200
> >  1 file changed, 110 insertions(+), 18 deletions(-)
> > [acme@quaco perf-urgent]$
> > [acme@quaco perf-urgent]$ rm -rf /tmp/build/perf-urgent ; mkdir -p /tmp/build/perf-urgent ; m
> > <SNIP>
> >  19: 'import perf' in python                                         : Ok
> > [acme@quaco perf-urgent]$ sudo su -
> > [root@quaco ~]# perf test bpf
> >  40: LLVM search and compile                                         :
> >  40.1: Basic BPF llvm compile                                        : Ok
> >  40.3: Compile source for BPF prologue generation                    : Ok
> >  40.4: Compile source for BPF relocation                             : Ok
> >  42: BPF filter                                                      :
> >  42.1: Basic BPF filtering                                           : Ok
> >  42.2: BPF pinning                                                   : Ok
> >  42.3: BPF prologue generation                                       : Ok
> >  63: Test libpfm4 support                                            :
> >  96: perf stat --bpf-counters test                                   : Ok
> > [root@quaco ~]#
> > 
> > So it works in the end, can it be made to work after the first step? I
> > didn't check that.
> 
> heya,
> so the first patch is preparation and the last one is the real fix
> 
> at the moment it does not work without this change, so I don't
> think it's a problem for the bisect, is it?

ah I just checked that thing worked before :)) ok.. I think the only
way here is to squash them together.. doesn't look that bad

jirka