Re: [PATCH bpf-next 5/6] bpf: Improve tracing recursion prevention mechanism

From: kernel test robot
Date: Mon Apr 17 2023 - 19:30:16 EST


Hi Yafang,

kernel test robot noticed the following build errors:

[auto build test ERROR on bpf-next/master]

url: https://github.com/intel-lab-lkp/linux/commits/Yafang-Shao/bpf-Add-__rcu_read_-lock-unlock-into-btf-id-deny-list/20230417-235009
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link: https://lore.kernel.org/r/20230417154737.12740-6-laoar.shao%40gmail.com
patch subject: [PATCH bpf-next 5/6] bpf: Improve tracing recursion prevention mechanism
config: loongarch-defconfig (https://download.01.org/0day-ci/archive/20230418/202304180736.cWjpwhs6-lkp@xxxxxxxxx/config)
compiler: loongarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/ac84d2623c0469a703245030f2b23612ab4505dd
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Yafang-Shao/bpf-Add-__rcu_read_-lock-unlock-into-btf-id-deny-list/20230417-235009
git checkout ac84d2623c0469a703245030f2b23612ab4505dd
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=loongarch olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=loongarch SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Link: https://lore.kernel.org/oe-kbuild-all/202304180736.cWjpwhs6-lkp@xxxxxxxxx/

All errors (new ones prefixed by >>):

kernel/bpf/trampoline.c: In function '__bpf_prog_enter_recur':
>> kernel/bpf/trampoline.c:848:15: error: implicit declaration of function 'test_recursion_try_acquire' [-Werror=implicit-function-declaration]
848 | bit = test_recursion_try_acquire(_THIS_IP_, _RET_IP_);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/bpf/trampoline.c: In function '__bpf_prog_exit_recur':
>> kernel/bpf/trampoline.c:896:9: error: implicit declaration of function 'test_recursion_release'; did you mean 'dev_recursion_level'? [-Werror=implicit-function-declaration]
896 | test_recursion_release(run_ctx->recursion_bit);
| ^~~~~~~~~~~~~~~~~~~~~~
| dev_recursion_level
cc1: some warnings being treated as errors


vim +/test_recursion_try_acquire +848 kernel/bpf/trampoline.c

828
829 /* The logic is similar to bpf_prog_run(), but with an explicit
830 * rcu_read_lock() and migrate_disable() which are required
831 * for the trampoline. The macro is split into
832 * call __bpf_prog_enter
833 * call prog->bpf_func
834 * call __bpf_prog_exit
835 *
836 * __bpf_prog_enter returns:
837 * 0 - skip execution of the bpf prog
838 * 1 - execute bpf prog
839 * [2..MAX_U64] - execute bpf prog and record execution time.
840 * This is start time.
841 */
842 static u64 notrace __bpf_prog_enter_recur(struct bpf_prog *prog, struct bpf_tramp_run_ctx *run_ctx)
843 __acquires(RCU)
844 {
845 int bit;
846
847 rcu_read_lock();
> 848 bit = test_recursion_try_acquire(_THIS_IP_, _RET_IP_);
849 run_ctx->recursion_bit = bit;
850 if (bit < 0) {
851 preempt_disable_notrace();
852 bpf_prog_inc_misses_counter(prog);
853 preempt_enable_notrace();
854 return 0;
855 }
856
857 migrate_disable();
858
859 run_ctx->saved_run_ctx = bpf_set_run_ctx(&run_ctx->run_ctx);
860 return bpf_prog_start_time();
861 }
862
863 static void notrace update_prog_stats(struct bpf_prog *prog,
864 u64 start)
865 {
866 struct bpf_prog_stats *stats;
867
868 if (static_branch_unlikely(&bpf_stats_enabled_key) &&
869 /* static_key could be enabled in __bpf_prog_enter*
870 * and disabled in __bpf_prog_exit*.
871 * And vice versa.
872 * Hence check that 'start' is valid.
873 */
874 start > NO_START_TIME) {
875 unsigned long flags;
876
877 stats = this_cpu_ptr(prog->stats);
878 flags = u64_stats_update_begin_irqsave(&stats->syncp);
879 u64_stats_inc(&stats->cnt);
880 u64_stats_add(&stats->nsecs, sched_clock() - start);
881 u64_stats_update_end_irqrestore(&stats->syncp, flags);
882 }
883 }
884
885 static void notrace __bpf_prog_exit_recur(struct bpf_prog *prog, u64 start,
886 struct bpf_tramp_run_ctx *run_ctx)
887 __releases(RCU)
888 {
889 if (run_ctx->recursion_bit < 0)
890 goto out;
891
892 bpf_reset_run_ctx(run_ctx->saved_run_ctx);
893
894 update_prog_stats(prog, start);
895 migrate_enable();
> 896 test_recursion_release(run_ctx->recursion_bit);
897
898 out:
899 rcu_read_unlock();
900 }
901

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests