Bug 2117580

Summary: pahole does not generate VARs for percpu symbols on non-x86_64 arches
Product: Red Hat Enterprise Linux 9 Reporter: Artem Savkov <asavkov>
Component: dwarvesAssignee: Viktor Malik <vmalik>
Status: CLOSED ERRATA QA Contact: Ziqian SUN (Zamir) <zsun>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.4CC: zsun
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dwarves-1.24-2.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-09 07:41:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Artem Savkov 2022-08-11 11:40:00 UTC
rhel9's version of pahole doesn't properly generate VARs for percpu symbols on non-x86_64 architectures. Found this while running bpf selftests on aarch64. Looks like the following commit fixes the issue (and can be cherry-picked cleanly onto v1.22)

commit 16a7acaba446612135ba674a51cdda6bfcc34667
Author: Ilya Leoshkevich <iii.com>
Date:   Tue Oct 12 04:26:37 2021 +0200

    btf_encoder: Fix handling of percpu symbols on s390

    pahole does not generate VARs for percpu symbols on s390. A percpu
    symbol definition on a typical x86_64 kernel looks like this:

      [33] .data..percpu     PROGBITS         0000000000000000  01c00000
                                              ^^^^^^^^^^^^^^^^ sh_addr
      LOAD           0x0000000001c00000 0x0000000000000000 0x000000000286f000
                                        ^^^^^^^^^^^^^^^^^^ p_vaddr
     13559: 000000000001ba50     4 OBJECT  LOCAL  DEFAULT   33 cpu_profile_flip
            ^^^^^^^^^^^^^^^^ st_value

    Most importantly, .data..percpu's sh_addr is 0, and this is what pahole
    is currently assuming. However, on s390 this is different:

       [37] .data..percpu     PROGBITS         00000000019cd000  018ce000
                                               ^^^^^^^^^^^^^^^^ sh_addr
      LOAD           0x000000000136e000 0x000000000146d000 0x000000000146d000
                                        ^^^^^^^^^^^^^^^^^^ p_vaddr
    80377: 0000000001ba1440     4 OBJECT  WEAK   DEFAULT   37 cpu_profile_flip
           ^^^^^^^^^^^^^^^^ st_value

    Fix by restructuring the code to always use section-relative offsets for
    symbols. Change the comment to focus on this invariant.

    Signed-off-by: Ilya Leoshkevich <iii.com>
    Cc: Alexei Starovoitov <ast>
    Cc: Andrii Nakryiko <andrii.nakryiko>
    Cc: Daniel Borkmann <daniel>
    Cc: Heiko Carstens <hca.com>
    Cc: Vasily Gorbik <gor.com>
    Cc: bpf.org
    Cc: dwarves.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme>

Without this commit:
    # ./pahole --btf_encode_detached=vml.btf /mnt/testarea/bpf/bpf-next/vmlinux; bpftool btf dump file vml.btf | grep -w VAR | wc -l
    0

With commit applied:
    # ./pahole --btf_encode_detached=vml.btf /mnt/testarea/bpf/bpf-next/vmlinux; bpftool btf dump file vml.btf | grep -w VAR | wc -l
    586

Comment 1 Viktor Malik 2022-12-06 12:09:15 UTC
This was fixed with the 1.24 pahole update.

The above reproducer won't work, though, as it requires a newer bpftool which will get into the buildroot with the bpf 5.19 rebase.

Comment 5 Ziqian SUN (Zamir) 2023-01-03 08:33:09 UTC
The bug is verified as fixed with dwarves-1.24-2.el9.s390x.
[root@ibm-z-503 ~]# pahole --btf_encode_detached=vml.btf /usr/lib/debug/lib/modules/$(uname -r)/vmlinux;  bpftool btf dump file vml.btf | grep -w VAR | wc -l
426
[root@ibm-z-503 ~]# rpm -q bpftool
bpftool-7.0.0-221.el9.s390x

And dwarves-1.24-2.el9 is in the compose.

https://download-node-02.eng.bos.redhat.com/rhel-9/composes/RHEL-9/RHEL-9.2.0-20230102.0/compose/AppStream/x86_64/os/Packages/dwarves-1.24-2.el9.x86_64.rpm

And our bpf testsuite, including dwarves test case, finished without any blocker with the following packages.
bpftrace-0.16.0-1.el9
kernel-5.14.0-221.el9
libbpf-0.8.0-1.el9
bcc-0.25.0-1.el9
https://beaker.engineering.redhat.com/matrix/?toggle_nacks_on=on&job_ids=7385834

All the failures in the above job have been reported into separated bugs.

Comment 7 errata-xmlrpc 2023-05-09 07:41:02 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (dwarves bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2263