Bug 4430 - [Anolis23][x86_64][社区nightly & ANCK-5.10-14-rc1] perf-test测试case:BPF-prologue-generation失败报错提示<stdin>:12:10: fatal error: 'uapi/linux/fs.h' file not found
Summary: [Anolis23][x86_64][社区nightly & ANCK-5.10-14-rc1] perf-test测试case:BPF-prologue...
Status: RESOLVED FIXED
Alias: None
Product: Anolis OS 23
Classification: Anolis OS
Component: Others (show other bugs) Others
Version: 23.0
Hardware: All Linux
: P3-Medium S3-normal
Target Milestone: ---
Assignee: maqiao
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-08 10:27 UTC by anolislw
Modified: 2023-03-27 11:26 UTC (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description anolislw alibaba_cloud_group 2023-03-08 10:27:28 UTC
Description of problem:
Anolis23 x86_64 ECS环境,社区版nightly perf-test测试套 case:BPF-prologue-generation测试失败

Version-Release number of selected component (if applicable):

How reproducible:
Steps to Reproduce:
1. 安装anolis23 x86_64 nightly 内核包及其对应perf包
2. 机器新内核生效后,执行 perf test,找到对应的BPF-prologue-generation 标号执行 perf test -v +case标号
3. 例如执行perf test -v BPF filter

Actual results:
42.3: BPF prologue generation                                       :
--- start ---
test child forked, pid 1573007
detect_kbuild_dir: Couldn't find "/lib/modules/5.10.134-3.git.a83585bed7a8.an23.x86_64/build/include/generated/autoconf.h", missing kernel-devel package?.
WARNING:        unable to get correct kernel building directory.
Hint:   Set correct kbuild directory using 'kbuild-dir' option in [llvm]
        section of ~/.perfconfig or set it to "" to suppress kbuild
        detection.

set env: NR_CPUS=4
set env: LINUX_VERSION_CODE=0x50a86
set env: CLANG_EXEC=/usr/bin/clang
set env: CLANG_OPTIONS=-xc
unset env: KERNEL_INC_OPTIONS
set env: PERF_BPF_INC_OPTIONS=-I/usr/lib/perf/include/bpf
set env: WORKING_DIR=.
set env: CLANG_SOURCE=-
llvm compiling command template: echo '// SPDX-License-Identifier: GPL-2.0
/*
 * bpf-script-test-prologue.c
 * Test BPF prologue
 */
#ifndef LINUX_VERSION_CODE
# error Need LINUX_VERSION_CODE
# error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig'
#endif
#define SEC(NAME) __attribute__((section(NAME), used))

#include <uapi/linux/fs.h>

/*
 * If CONFIG_PROFILE_ALL_BRANCHES is selected,
 * 'if' is redefined after include kernel header.
 * Recover 'if' for BPF object code.
 */
#ifdef if
# undef if
#endif

#define FMODE_READ              0x1
#define FMODE_WRITE             0x2

static void (*bpf_trace_printk)(const char *fmt, int fmt_size, ...) =
        (void *) 6;

SEC("func=null_lseek file->f_mode offset orig")
int bpf_func__null_lseek(void *ctx, int err, unsigned long _f_mode,
                         unsigned long offset, unsigned long orig)
{
        fmode_t f_mode = (fmode_t)_f_mode;

        if (err)
                return 0;
        if (f_mode & FMODE_WRITE)
                return 0;
        if (offset & 1)
                return 0;
        if (orig == SEEK_CUR)
                return 0;
        return 1;
}

char _license[] SEC("license") = "GPL";
int _version SEC("version") = LINUX_VERSION_CODE;
' | $CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS -DLINUX_VERSION_CODE=$LINUX_VERSION_CODE $CLANG_OPTIONS $PERF_BPF_INC_OPTIONS $KERNEL_INC_OPTIONS -Wno-unused-value -Wno-pointer-sign -working-directory $WORKING_DIR -c "$CLANG_SOURCE" -target bpf $CLANG_EMIT_LLVM -O2 -o - $LLVM_OPTIONS_PIPE
llvm compiling command :
<stdin>:12:10: fatal error: 'uapi/linux/fs.h' file not found
#include <uapi/linux/fs.h>
         ^~~~~~~~~~~~~~~~~
1 error generated.
ERROR:  unable to compile -
Hint:   Check error message shown above.
Hint:   You can also pre-compile it into .o using:
                clang -target bpf -O2 -c -
        with proper -I and -D options.
Failed to compile test case: 'Compile source for BPF prologue generation'
Unable to get BPF object, fix kbuild first
test child finished with -1
---- end ----
BPF filter subtest 3: FAILED!

Expected results:
case pass

Additional info:
[root@qibo-anolis23-nightly-func-x86-1 ~]# uname -r
5.10.134-3.git.a83585bed7a8.an23.x86_64
[root@qibo-anolis23-nightly-func-x86-1 ~]# cat /etc/anolis-release
Anolis OS release 23
[root@qibo-anolis23-nightly-func-x86-1 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        4.0M     0  4.0M   0% /dev
tmpfs           7.6G     0  7.6G   0% /dev/shm
tmpfs           3.1G  732K  3.1G   1% /run
/dev/vda1        40G   16G   25G  39% /
tmpfs           7.6G  3.2G  4.5G  42% /tmp
tmpfs           1.6G     0  1.6G   0% /run/user/0
[root@qibo-anolis23-nightly-func-x86-1 ~]# free -g
               total        used        free      shared  buff/cache   available
Mem:              15           0          10           3           3          10
Swap:              0           0           0
[root@qibo-anolis23-nightly-func-x86-1 ~]# cat /proc/cmdline
BOOT_IMAGE=(hd0,msdos1)/boot/vmlinuz-5.10.134-3.git.a83585bed7a8.an23.x86_64 root=UUID=ece72b7f-465b-433d-8b3b-e5fa53a04642 ro rhgb cryptomgr.notests rcupdate.rcu_cpu_stall_timeout=300 quiet biosdevname=0 net.ifnames=0 console=tty0 console=ttyS0,115200n8 noibrs nvme_core.io_timeout=4294967295 nvme_core.admin_timeout=4294967295 cgroup.memory=nokmem crashkernel=0M-2G:0M,2G-8G:192M,8G-:256M
[root@qibo-anolis23-nightly-func-x86-1 ~]# lscpu
Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         46 bits physical, 57 bits virtual
  Byte Order:            Little Endian
CPU(s):                  4
  On-line CPU(s) list:   0-3
Vendor ID:               GenuineIntel
  BIOS Vendor ID:        Alibaba Cloud
  Model name:            Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
    BIOS Model name:     pc-i440fx-2.1  CPU @ 0.0GHz
    BIOS CPU family:     1
    CPU family:          6
    Model:               106
    Thread(s) per core:  2
    Core(s) per socket:  2
    Socket(s):           1
    Stepping:            6
    BogoMIPS:            5399.99
    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss h
                         t syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid tsc_known_freq pni pclmulq
                         dq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor
                         lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep
                         bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw
                          avx512vl xsaveopt xsavec xgetbv1 xsaves wbnoinvd arat avx512vbmi pku ospke avx512_vbmi2 gfni vaes vpc
                         lmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid fsrm arch_capabilities
Virtualization features:
  Hypervisor vendor:     KVM
  Virtualization type:   full
Caches (sum of all):
  L1d:                   96 KiB (2 instances)
  L1i:                   64 KiB (2 instances)
  L2:                    2.5 MiB (2 instances)
  L3:                    48 MiB (1 instance)
NUMA:
  NUMA node(s):          1
  NUMA node0 CPU(s):     0-3
Vulnerabilities:
  Itlb multihit:         Not affected
  L1tf:                  Not affected
  Mds:                   Not affected
  Meltdown:              Not affected
  Mmio stale data:       Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
  Retbleed:              Not affected
  Spec store bypass:     Vulnerable
  Spectre v1:            Mitigation; usercopy/swapgs barriers and __user pointer sanitization
  Spectre v2:            Mitigation; Enhanced IBRS, RSB filling, PBRSB-eIBRS SW sequence
  Srbds:                 Not affected
  Tsx async abort:       Not affected
[root@qibo-anolis23-nightly-func-x86-1 ~]#
[root@qibo-anolis23-nightly-func-x86-1 ~]# perf -v
perf version 5.10.134-3.git.a83585bed7a8.an23.x86_64
[root@qibo-anolis23-nightly-func-x86-1 ~]#
Comment 1 anolislw alibaba_cloud_group 2023-03-08 10:33:04 UTC
对比了Anolis8 5.10 x86的nightly测试该case是skip的
-----------------------------------------------
  {
    "testcase": "BPF-prologue-generation",
    "value": "Skip"
  }
Comment 2 anolislw alibaba_cloud_group 2023-03-08 10:38:39 UTC
Anolis23 x86_64 ECS环境,社区版nightly perf-test测试套 case:kbuild searching 也有类似的问题 <stdin>:12:10: fatal error: 'uapi/linux/fs.h' file not found


日志如下:
---------
40.2: kbuild searching                                              :
--- start ---
test child forked, pid 1577985
detect_kbuild_dir: Couldn't find "/lib/modules/5.10.134-3.git.a83585bed7a8.an23.x86_64/build/include/generated/autoconf.h", missing kernel-devel package?.
WARNING:        unable to get correct kernel building directory.
Hint:   Set correct kbuild directory using 'kbuild-dir' option in [llvm]
        section of ~/.perfconfig or set it to "" to suppress kbuild
        detection.

set env: NR_CPUS=4
set env: LINUX_VERSION_CODE=0x50a86
set env: CLANG_EXEC=/usr/bin/clang
set env: CLANG_OPTIONS=-xc
unset env: KERNEL_INC_OPTIONS
set env: PERF_BPF_INC_OPTIONS=-I/usr/lib/perf/include/bpf
set env: WORKING_DIR=.
set env: CLANG_SOURCE=-
llvm compiling command template: echo '// SPDX-License-Identifier: GPL-2.0
/*
 * bpf-script-test-kbuild.c
 * Test include from kernel header
 */
#ifndef LINUX_VERSION_CODE
# error Need LINUX_VERSION_CODE
# error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig'
#endif
#define SEC(NAME) __attribute__((section(NAME), used))

#include <uapi/linux/fs.h>

SEC("func=vfs_llseek")
int bpf_func__vfs_llseek(void *ctx)
{
        return 0;
}

char _license[] SEC("license") = "GPL";
int _version SEC("version") = LINUX_VERSION_CODE;
' | $CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS -DLINUX_VERSION_CODE=$LINUX_VERSION_CODE $CLANG_OPTIONS $PERF_BPF_INC_OPTIONS $KERNEL_INC_OPTIONS -Wno-unused-value -Wno-pointer-sign -working-directory $WORKING_DIR -c "$CLANG_SOURCE" -target bpf $CLANG_EMIT_LLVM -O2 -o - $LLVM_OPTIONS_PIPE
llvm compiling command : echo '// SPDX-License-Identifier: GPL-2.0
/*
 * bpf-script-test-kbuild.c
 * Test include from kernel header
 */
#ifndef LINUX_VERSION_CODE
# error Need LINUX_VERSION_CODE
# error Example: for 4.2 kernel, put 'clang-opt=-DLINUX_VERSION_CODE=0x40200 into llvm section of ~/.perfconfig'
#endif
#define SEC(NAME) __attribute__((section(NAME), used))

#include <uapi/linux/fs.h>

SEC(func=vfs_llseek)
int bpf_func__vfs_llseek(void *ctx)
{
        return 0;
}

char _license[] SEC(license) = GPL;
int _version SEC(version) = LINUX_VERSION_CODE;
' | /usr/bin/clang -D__KERNEL__ -D__NR_CPUS__=4 -DLINUX_VERSION_CODE=0x50a86 -xc  -I/usr/lib/perf/include/bpf  -Wno-unused-value -Wno-pointer-sign -working-directory . -c - -target bpf  -O2 -o -
<stdin>:12:10: fatal error: 'uapi/linux/fs.h' file not found
#include <uapi/linux/fs.h>
         ^~~~~~~~~~~~~~~~~
1 error generated.
ERROR:  unable to compile -
Hint:   Check error message shown above.
Hint:   You can also pre-compile it into .o using:
                clang -target bpf -O2 -c -
        with proper -I and -D options.
Failed to compile test case: 'kbuild searching'
test child finished with -1
---- end ----
LLVM search and compile subtest 2: FAILED!
40.3: Compile source for BPF prologue generation
Comment 3 anolislw alibaba_cloud_group 2023-03-08 10:40:14 UTC
(In reply to anolislw from comment #2)
> Anolis23 x86_64 ECS环境,社区版nightly perf-test测试套 case:kbuild searching 也有类似的问题
> <stdin>:12:10: fatal error: 'uapi/linux/fs.h' file not found
> 
> 
> 日志如下:
> ---------
> 40.2: kbuild searching                                              :
> --- start ---
> test child forked, pid 1577985
> detect_kbuild_dir: Couldn't find
> "/lib/modules/5.10.134-3.git.a83585bed7a8.an23.x86_64/build/include/
> generated/autoconf.h", missing kernel-devel package?.
> WARNING:        unable to get correct kernel building directory.
> Hint:   Set correct kbuild directory using 'kbuild-dir' option in [llvm]
>         section of ~/.perfconfig or set it to "" to suppress kbuild
>         detection.
> 
> set env: NR_CPUS=4
> set env: LINUX_VERSION_CODE=0x50a86
> set env: CLANG_EXEC=/usr/bin/clang
> set env: CLANG_OPTIONS=-xc
> unset env: KERNEL_INC_OPTIONS
> set env: PERF_BPF_INC_OPTIONS=-I/usr/lib/perf/include/bpf
> set env: WORKING_DIR=.
> set env: CLANG_SOURCE=-
> llvm compiling command template: echo '// SPDX-License-Identifier: GPL-2.0
> /*
>  * bpf-script-test-kbuild.c
>  * Test include from kernel header
>  */
> #ifndef LINUX_VERSION_CODE
> # error Need LINUX_VERSION_CODE
> # error Example: for 4.2 kernel, put
> 'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig'
> #endif
> #define SEC(NAME) __attribute__((section(NAME), used))
> 
> #include <uapi/linux/fs.h>
> 
> SEC("func=vfs_llseek")
> int bpf_func__vfs_llseek(void *ctx)
> {
>         return 0;
> }
> 
> char _license[] SEC("license") = "GPL";
> int _version SEC("version") = LINUX_VERSION_CODE;
> ' | $CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS
> -DLINUX_VERSION_CODE=$LINUX_VERSION_CODE $CLANG_OPTIONS
> $PERF_BPF_INC_OPTIONS $KERNEL_INC_OPTIONS -Wno-unused-value
> -Wno-pointer-sign -working-directory $WORKING_DIR -c "$CLANG_SOURCE" -target
> bpf $CLANG_EMIT_LLVM -O2 -o - $LLVM_OPTIONS_PIPE
> llvm compiling command : echo '// SPDX-License-Identifier: GPL-2.0
> /*
>  * bpf-script-test-kbuild.c
>  * Test include from kernel header
>  */
> #ifndef LINUX_VERSION_CODE
> # error Need LINUX_VERSION_CODE
> # error Example: for 4.2 kernel, put 'clang-opt=-DLINUX_VERSION_CODE=0x40200
> into llvm section of ~/.perfconfig'
> #endif
> #define SEC(NAME) __attribute__((section(NAME), used))
> 
> #include <uapi/linux/fs.h>
> 
> SEC(func=vfs_llseek)
> int bpf_func__vfs_llseek(void *ctx)
> {
>         return 0;
> }
> 
> char _license[] SEC(license) = GPL;
> int _version SEC(version) = LINUX_VERSION_CODE;
> ' | /usr/bin/clang -D__KERNEL__ -D__NR_CPUS__=4 -DLINUX_VERSION_CODE=0x50a86
> -xc  -I/usr/lib/perf/include/bpf  -Wno-unused-value -Wno-pointer-sign
> -working-directory . -c - -target bpf  -O2 -o -
> <stdin>:12:10: fatal error: 'uapi/linux/fs.h' file not found
> #include <uapi/linux/fs.h>
>          ^~~~~~~~~~~~~~~~~
> 1 error generated.
> ERROR:  unable to compile -
> Hint:   Check error message shown above.
> Hint:   You can also pre-compile it into .o using:
>                 clang -target bpf -O2 -c -
>         with proper -I and -D options.
> Failed to compile test case: 'kbuild searching'
> test child finished with -1
> ---- end ----
> LLVM search and compile subtest 2: FAILED!
> 40.3: Compile source for BPF prologue generation


对比了在Anolis8-5.10-x86_64-func-nightly测试下该case是pass的

  {
    "testcase": "kbuild-searching",
    "value": "Pass"
  }
Comment 4 dtcccc alibaba_cloud_group 2023-03-13 15:39:03 UTC
(In reply to anolislw from comment #0)
> Description of problem:
> Anolis23 x86_64 ECS环境,社区版nightly perf-test测试套
> case:BPF-prologue-generation测试失败
> 
> Version-Release number of selected component (if applicable):
> 
> How reproducible:
> Steps to Reproduce:
> 1. 安装anolis23 x86_64 nightly 内核包及其对应perf包
> 2. 机器新内核生效后,执行 perf test,找到对应的BPF-prologue-generation 标号执行 perf test -v
> +case标号
> 3. 例如执行perf test -v BPF filter
> 
> Actual results:
> 42.3: BPF prologue generation                                       :
> --- start ---
> test child forked, pid 1573007
> detect_kbuild_dir: Couldn't find
> "/lib/modules/5.10.134-3.git.a83585bed7a8.an23.x86_64/build/include/
> generated/autoconf.h", missing kernel-devel package?.
> WARNING:        unable to get correct kernel building directory.

这日志里已经说了,缺失kernel-devel包?
Comment 5 anolislw alibaba_cloud_group 2023-03-14 14:08:35 UTC
(In reply to dtcccc from comment #4)
> (In reply to anolislw from comment #0)
> > Description of problem:
> > Anolis23 x86_64 ECS环境,社区版nightly perf-test测试套
> > case:BPF-prologue-generation测试失败
> > 
> > Version-Release number of selected component (if applicable):
> > 
> > How reproducible:
> > Steps to Reproduce:
> > 1. 安装anolis23 x86_64 nightly 内核包及其对应perf包
> > 2. 机器新内核生效后,执行 perf test,找到对应的BPF-prologue-generation 标号执行 perf test -v
> > +case标号
> > 3. 例如执行perf test -v BPF filter
> > 
> > Actual results:
> > 42.3: BPF prologue generation                                       :
> > --- start ---
> > test child forked, pid 1573007
> > detect_kbuild_dir: Couldn't find
> > "/lib/modules/5.10.134-3.git.a83585bed7a8.an23.x86_64/build/include/
> > generated/autoconf.h", missing kernel-devel package?.
> > WARNING:        unable to get correct kernel building directory.
> 
> 这日志里已经说了,缺失kernel-devel包?

kernel-devel测试前是安装好的
-------------------------------------
[root@qibo-anolis23-nightly-func-x86-1 ~]# rpm -qa | grep ^kernel
kernel-core-5.10.134-9.git.b9e0e840126f.an23.x86_64
kernel-modules-5.10.134-9.git.b9e0e840126f.an23.x86_64
kernel-debuginfo-common-x86_64-5.10.134-9.git.b9e0e840126f.an23.x86_64
kernel-debuginfo-5.10.134-9.git.b9e0e840126f.an23.x86_64
kernel-modules-extra-5.10.134-9.git.b9e0e840126f.an23.x86_64
kernel-modules-internal-5.10.134-9.git.b9e0e840126f.an23.x86_64
kernel-5.10.134-9.git.b9e0e840126f.an23.x86_64
kernel-devel-5.10.134-9.git.b9e0e840126f.an23.x86_64
kernel-headers-5.10.134-9.git.b9e0e840126f.an23.x86_64
[root@qibo-anolis23-nightly-func-x86-1 ~]#
[root@qibo-anolis23-nightly-func-x86-1 ~]# uname -r
5.10.134-9.git.b9e0e840126f.an23.x86_64
[root@qibo-anolis23-nightly-func-x86-1 ~]# perf test BPF filter
30: Filter hist entries                                             : Ok
36: Filter fds with revents mask in a fdarray                       : Ok
40: LLVM search and compile                                         :
40.1: Basic BPF llvm compile                                        : Ok
40.3: Compile source for BPF prologue generation                    : FAILED!
40.4: Compile source for BPF relocation                             : Skip
42: BPF filter                                                      :
42.1: Basic BPF filtering                                           : Ok
42.2: BPF pinning                                                   : Ok
42.3: BPF prologue generation                                       : FAILED!  #还是fail
63: Test libpfm4 support                                            : Skip (not compiled in)
[root@qibo-anolis23-nightly-func-x86-1 ~]#
[root@qibo-anolis23-nightly-func-x86-1 ~]# cat /etc/anolis-release
Anolis OS release 23
[root@qibo-anolis23-nightly-func-x86-1 ~]# rpm -q kernel-devel
kernel-devel-5.10.134-9.git.b9e0e840126f.an23.x86_64
[root@qibo-anolis23-nightly-func-x86-1 ~]# uname -r
5.10.134-9.git.b9e0e840126f.an23.x86_64
Comment 6 dtcccc alibaba_cloud_group 2023-03-14 16:56:39 UTC
怀疑kernel-core的打包脚本有问题,软链接配置的不正常导致找不到头文件

在alinux3环境中,正常的软链接如下:
# ll /lib/modules/5.10.134-13.1.al8.x86_64/
lrwxrwxrwx  1 root root      41 2月   6 14:59 build -> /usr/src/kernels/5.10.134-13.1.al8.x86_64


在anolis23环境中,异常的软链接如下:
# ll /lib/modules/5.10.134-13.2_alpha1.an23.x86_64/
lrwxrwxrwx.  1 root root      57 Feb 16 18:14 build -> ../../../usr/src/kernels/5.10.134-13.2_alpha1.an23.x86_64
Comment 7 dtcccc alibaba_cloud_group 2023-03-14 18:02:20 UTC
执行
ln -s /usr/src/kernels/5.10.134-13.2_alpha1.an23.x86_64/ /lib/modules/5.10.134-13.2_alpha1.an23.x86_64/build

修复软链接后测试项均通过
建议检查kernel rpm的打包脚本
Comment 8 anolislw alibaba_cloud_group 2023-03-21 17:59:13 UTC
在5.10.134-14_rc2.an23.x86_64上该case验证是pass的
-------------------------------
  {
    "testcase": "BPF-prologue-generation",
    "value": "Pass"
  }
Comment 9 maqiao alibaba_cloud_group 2023-03-27 11:26:16 UTC
rc2未复现,怀疑是构建环境造成的问题,先置为fixed。