Skip to content

Conversation

FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Mar 28, 2025

What type of PR is this?

/kind bug

Any specific area of the project related to this PR?

/area driver-kmod
/area driver-bpf

Does this PR require a change in the driver versions?

What this PR does / why we need it:

Since torvalds/linux@13b2548, our driver and bpf makefile were a bit off.
Quoting the commit message:

Currently, Kbuild always operates in the output directory of the kernel,
even when building external modules.

...

The command for building external modules maintains backward
compatibility, but Makefiles that rely on working in the kernel
directory may break. In such cases, $(objtree) and $(srctree) should
be used to refer to the output and source directories of the kernel.

Thus, to retain old behavior, we should definitely use $(objtree)

objtree is also part of the documentation: torvalds/linux@13b2548#diff-5a02662444aaba282ed85bc93267c9f07095fa0a882ce5717275ecda46e4a137R462

$(objtree)

$(objtree) refers to the root of the kernel object tree. It is . when
building the kernel, but it is different when building external modules.

Which issue(s) this PR fixes:

Fixes #2277

Supersedes #2301

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

fix(driver): fix driver and bpf makefile for linux 6.13.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
@poiana
Copy link
Contributor

poiana commented Mar 28, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FedeDP

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@FedeDP
Copy link
Contributor Author

FedeDP commented Mar 28, 2025

@nathan-b @m-pellizzer @therealbobo
Care to test this one?

Copy link

Perf diff from master - unit tests

     3.83%     -0.31%  [.] next_event_from_file
     1.16%     -0.27%  [.] sinsp::fetch_next_event
     2.64%     -0.21%  [.] gzfile_read
     0.61%     -0.19%  [.] sinsp_evt::get_param
     1.10%     +0.17%  [.] std::_Hashtable<unsigned long, std::pair<unsigned long const, std::shared_ptr<ppm_evt_hdr> >, std::allocator<std::pair<unsigned long const, std::shared_ptr<ppm_evt_hdr> > >, std::__detail::_Select1st, std::equal_to<unsigned long>, std::hash<unsigned long>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_find_before_node
     4.19%     -0.15%  [.] sinsp_thread_manager::find_thread
     0.58%     +0.15%  [.] sinsp_evt::get_syscall_return_value
     0.25%     +0.15%  [.] 0x0000000000071e80
    36.35%     +0.14%  [.] sinsp_thread_manager::create_thread_dependencies
     0.40%     +0.13%  [.] std::_Hashtable<unsigned long, std::pair<unsigned long const, std::shared_ptr<ppm_evt_hdr> >, std::allocator<std::pair<unsigned long const, std::shared_ptr<ppm_evt_hdr> > >, std::__detail::_Select1st, std::equal_to<unsigned long>, std::hash<unsigned long>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::find

Heap diff from master - unit tests

peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Heap diff from master - scap file

peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Benchmarks diff from master

Comparing gbench_data.json to /root/actions-runner/_work/libs/libs/build/gbench_data.json
Benchmark                                                         Time             CPU      Time Old      Time New       CPU Old       CPU New
----------------------------------------------------------------------------------------------------------------------------------------------
BM_sinsp_split_mean                                            -0.0138         -0.0137           150           148           150           148
BM_sinsp_split_median                                          -0.0130         -0.0129           150           148           150           148
BM_sinsp_split_stddev                                          +0.4618         +0.4593             1             1             1             1
BM_sinsp_split_cv                                              +0.4823         +0.4796             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_mean                  +0.1680         +0.1681            54            64            54            64
BM_sinsp_concatenate_paths_relative_path_median                +0.1667         +0.1668            55            64            55            64
BM_sinsp_concatenate_paths_relative_path_stddev                +4.6193         +4.6226             0             1             0             1
BM_sinsp_concatenate_paths_relative_path_cv                    +3.8112         +3.8136             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_mean                     +0.0471         +0.0472            24            25            24            25
BM_sinsp_concatenate_paths_empty_path_median                   +0.0468         +0.0469            24            25            24            25
BM_sinsp_concatenate_paths_empty_path_stddev                   +1.3136         +1.3093             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_cv                       +1.2095         +1.2052             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_mean                  +0.1105         +0.1106            58            65            58            65
BM_sinsp_concatenate_paths_absolute_path_median                +0.1165         +0.1167            58            65            58            65
BM_sinsp_concatenate_paths_absolute_path_stddev                -0.5150         -0.5152             1             0             1             0
BM_sinsp_concatenate_paths_absolute_path_cv                    -0.5633         -0.5635             0             0             0             0

Copy link

codecov bot commented Mar 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.18%. Comparing base (dc16ffa) to head (7e1041b).
Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2329   +/-   ##
=======================================
  Coverage   77.18%   77.18%           
=======================================
  Files         227      227           
  Lines       30192    30192           
  Branches     4611     4611           
=======================================
  Hits        23304    23304           
  Misses       6888     6888           
Flag Coverage Δ
libsinsp 77.18% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@FedeDP
Copy link
Contributor Author

FedeDP commented Mar 28, 2025

/milestone next-driver

@poiana poiana added this to the next-driver milestone Mar 28, 2025
Copy link

X64 kernel testing matrix

KERNEL CMAKE-CONFIGURE KMOD BUILD KMOD SCAP-OPEN BPF-PROBE BUILD BPF-PROBE SCAP-OPEN MODERN-BPF SCAP-OPEN
amazonlinux2-4.19 🟢 🟢 🟢 🟢 🟢 🟡
amazonlinux2-5.10 🟢 🟢 🟢 🟢 🟢 🟢
amazonlinux2-5.15 🟢 🟢 🟢 🟢 🟢 🟢
amazonlinux2-5.4 🟢 🟢 🟢 🟢 🟢 🟡
amazonlinux2022-5.15 🟢 🟢 🟢 🟢 🟢 🟢
amazonlinux2023-6.1 🟢 🟢 🟢 🟢 🟢 🟢
archlinux-6.0 🟢 🟢 🟢 🟢 🟢 🟢
archlinux-6.7 🟢 🟢 🟢 🟢 🟢 🟢
centos-3.10 🟢 🟢 🟢 🟡 🟡 🟡
centos-4.18 🟢 🟢 🟢 🟢 🟢 🟢
centos-5.14 🟢 🟢 🟢 🟢 🟢 🟢
fedora-5.17 🟢 🟢 🟢 🟢 🟢 🟢
fedora-5.8 🟢 🟢 🟢 🟢 🟢 🟢
fedora-6.2 🟢 🟢 🟢 🟢 🟢 🟢
oraclelinux-3.10 🟢 🟢 🟢 🟡 🟡 🟡
oraclelinux-4.14 🟢 🟢 🟢 🟢 🟢 🟡
oraclelinux-5.15 🟢 🟢 🟢 🟢 🟢 🟢
oraclelinux-5.4 🟢 🟢 🟢 🟢 🟢 🟡
ubuntu-4.15 🟢 🟢 🟢 🟢 🟢 🟡
ubuntu-5.8 🟢 🟢 🟢 🟢 🟢 🟡
ubuntu-6.5 🟢 🟢 🟢 🟢 🟢 🟢

ARM64 kernel testing matrix

KERNEL CMAKE-CONFIGURE KMOD BUILD KMOD SCAP-OPEN BPF-PROBE BUILD BPF-PROBE SCAP-OPEN MODERN-BPF SCAP-OPEN
amazonlinux2-5.4 🟢 🟢 🟢 🟢 🟢 🟡
amazonlinux2022-5.15 🟢 🟢 🟢 🟢 🟢 🟢
fedora-6.2 🟢 🟢 🟢 🟢 🟢 🟢
oraclelinux-4.14 🟢 🟢 🟢 🟡 🟡 🟡
oraclelinux-5.15 🟢 🟢 🟢 🟢 🟢 🟢
ubuntu-6.5 🟢 🟢 🟢 🟢 🟢 🟢

@m-pellizzer
Copy link

Hello @FedeDP
Tested on Ubuntu Plucky with kernel 6.14:

$ uname -r
6.14.0-11-generic
$ make driver
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-14 (Ubuntu 14.2.0-19ubuntu1) 14.2.0
  You are using:           gcc-14 (Ubuntu 14.2.0-19ubuntu1) 14.2.0
[configure-kmod] Including ~/playground/falco/build/driver/src//configure/DEVNODE_ARG1_CONST/Makefile.inc ~/playground/falco/build/driver/src//configure/FS_MNT_IDMAP/Makefile.inc ~/playground/falco/build/driver/src//configure/ACCESS_OK_2/Makefile.inc ~/playground/falco/build/driver/src//configure/0__SANITY/Makefile.inc ~/playground/falco/build/driver/src//configure/CLASS_CREATE_1/Makefile.inc
[configure-kmod] Setting HAS_DEVNODE_ARG1_CONST flag
[configure-kmod] Setting HAS_FS_MNT_IDMAP flag
[configure-kmod] Setting HAS_ACCESS_OK_2 flag
[configure-kmod] Setting HAS_0__SANITY flag
[configure-kmod] Build system is sane
[configure-kmod] Setting HAS_CLASS_CREATE_1 flag
Skipping BTF generation for scap.ko due to unavailability of vmlinux
Built target driver

@FedeDP
Copy link
Contributor Author

FedeDP commented Mar 28, 2025

Thank you very much @m-pellizzer !

Copy link
Member

@leogr leogr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 🚀

@nathan-b
Copy link
Contributor

master branch:

nathan@nathanb-dev ~/src/falco-libs/build (git)-[remotes/origin/HEAD] % make driver
[configure-kmod] Including /home/nathan/src/falco-libs/build/driver/src//configure/ACCESS_OK_2/Makefile.inc /home/nathan/src/falco-libs/build/driver/src//configure/0__SANITY/Makefile.inc /home/nathan/src/falco-libs/build/driver/src//configure/CLASS_CREATE_1/Makefile.inc /home/nathan/src/falco-libs/build/driver/src//configure/FS_MNT_IDMAP/Makefile.inc /home/nathan/src/falco-libs/build/driver/src//configure/DEVNODE_ARG1_CONST/Makefile.inc
[configure-kmod] Build output for HAS_ACCESS_OK_2:
[configure-kmod] make: Entering directory '/home/nathan/src/falco-libs/build/driver/src/configure/ACCESS_OK_2'
make -C /home/nathan/src/falco-libs/build/driver/src M=/home/nathan/src/falco-libs/build/driver/src/configure/ACCESS_OK_2 modules make[1]: Entering directory '/home/nathan/src/falco-libs/build/driver/src'
make[1]: *** No rule to make target 'modules'.  Stop. make[1]: Leaving directory '/home/nathan/src/falco-libs/build/driver/src'
make: *** [Makefile:15: all] Error 2
[configure-kmod] Build output for HAS_0__SANITY:
[configure-kmod] make: Entering directory '/home/nathan/src/falco-libs/build/driver/src/configure/0__SANITY'
make -C /home/nathan/src/falco-libs/build/driver/src M=/home/nathan/src/falco-libs/build/driver/src/configure/0__SANITY modules make[1]: Entering directory '/home/nathan/src/falco-libs/build/driver/src'
make[1]: *** No rule to make target 'modules'.  Stop. make[1]: Leaving directory '/home/nathan/src/falco-libs/build/driver/src'
make: *** [Makefile:15: all] Error 2
[configure-kmod] Build system is broken, please see above errors
/home/nathan/src/falco-libs/build/driver/src//configure/0__SANITY/Makefile.inc:23: *** The build system is broken, please see above errors.  Stop.
make[7]: *** [/usr/lib/modules/6.13.7-arch1-1/build/Makefile:1989: .] Error 2
make[6]: *** [/usr/lib/modules/6.13.7-arch1-1/build/Makefile:251: __sub-make] Error 2
make[5]: *** [Makefile:251: __sub-make] Error 2
make[4]: *** [Makefile:22: all] Error 2
make[3]: *** [driver/CMakeFiles/driver.dir/build.make:70: driver/CMakeFiles/driver] Error 2
make[2]: *** [CMakeFiles/Makefile2:900: driver/CMakeFiles/driver.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:907: driver/CMakeFiles/driver.dir/rule] Error 2
make: *** [Makefile:234: driver] Error 2

Your branch

nathan@nathanb-dev ~/src/falco-libs/build (git)-[fix/linux_613] % make driver
[configure-kmod] Including /home/nathan/src/falco-libs/build/driver/src//configure/ACCESS_OK_2/Makefile.inc /home/nathan/src/falco-libs/build/driver/src//configure/0__SANITY/Makefile.inc /home/nathan/src/falco-libs/build/driver/src//configure/CLASS_CREATE_1/Makefile.inc /home/nathan/src/falco-libs/build/driver/src//configure/FS_MNT_IDMAP/Makefile.inc /home/nathan/src/falco-libs/build/driver/src//configure/DEVNODE_ARG1_CONST/Makefile.inc
[configure-kmod] Setting HAS_ACCESS_OK_2 flag
[configure-kmod] Setting HAS_0__SANITY flag
[configure-kmod] Build system is sane
[configure-kmod] Setting HAS_CLASS_CREATE_1 flag
[configure-kmod] Setting HAS_FS_MNT_IDMAP flag
[configure-kmod] Setting HAS_DEVNODE_ARG1_CONST flag
Built target driver
make driver  12.39s user 2.84s system 99% cpu 15.336 total

LGTM, thanks for the fix!

@poiana
Copy link
Contributor

poiana commented Mar 28, 2025

@nathan-b: changing LGTM is restricted to collaborators

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@FedeDP FedeDP changed the title wip: fix(driver): fix driver and bpf makefile for linux 6.13. fix(driver): fix driver and bpf makefile for linux 6.13. Mar 28, 2025
@github-project-automation github-project-automation bot moved this from Todo to In progress in Falco Roadmap Mar 28, 2025
@poiana poiana merged commit 7f01ec8 into master Mar 28, 2025
56 checks passed
@poiana poiana deleted the fix/linux_613 branch March 28, 2025 13:36
@github-project-automation github-project-automation bot moved this from In progress to Done in Falco Roadmap Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

scap kernel module fails to build on Linux >= 6.13
6 participants