Re: [PATCH bpf-next] Add support for tracing programs in BPF_PROG_RUN

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Grant,

Thank you for the patch! Perhaps something to improve:

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

url:    https://github.com/intel-lab-lkp/linux/commits/Grant-Seltzer/Add-support-for-tracing-programs-in-BPF_PROG_RUN/20230128-130222
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link:    https://lore.kernel.org/r/20230127214353.628551-1-grantseltzer%40gmail.com
patch subject: [PATCH bpf-next] Add support for tracing programs in BPF_PROG_RUN
config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20230128/202301281606.OPSk1bci-lkp@xxxxxxxxx/config)
compiler: powerpc-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/990088d6233eb15a4a42a83a998f47432305d4d7
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Grant-Seltzer/Add-support-for-tracing-programs-in-BPF_PROG_RUN/20230128-130222
        git checkout 990088d6233eb15a4a42a83a998f47432305d4d7
        # 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=powerpc olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash net/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

   net/bpf/test_run.c: In function 'bpf_prog_test_run_tracing':
>> net/bpf/test_run.c:818:30: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
     818 |         u16 side_effect = 0, ret = 0;
         |                              ^~~
>> net/bpf/test_run.c:818:13: warning: variable 'side_effect' set but not used [-Wunused-but-set-variable]
     818 |         u16 side_effect = 0, ret = 0;
         |             ^~~~~~~~~~~


vim +/ret +818 net/bpf/test_run.c

990088d6233eb1 Grant Seltzer          2023-01-27  812  
da00d2f117a08f KP Singh               2020-03-04  813  int bpf_prog_test_run_tracing(struct bpf_prog *prog,
da00d2f117a08f KP Singh               2020-03-04  814  			      const union bpf_attr *kattr,
da00d2f117a08f KP Singh               2020-03-04  815  			      union bpf_attr __user *uattr)
da00d2f117a08f KP Singh               2020-03-04  816  {
d923021c2ce12a Yonghong Song          2020-06-30  817  	struct bpf_fentry_test_t arg = {};
3d08b6f29cf33a KP Singh               2020-03-04 @818  	u16 side_effect = 0, ret = 0;
990088d6233eb1 Grant Seltzer          2023-01-27  819  	int b = 2, err = -EFAULT, current_cpu;
990088d6233eb1 Grant Seltzer          2023-01-27  820  
990088d6233eb1 Grant Seltzer          2023-01-27  821  	void __user *ctx_in = u64_to_user_ptr(kattr->test.ctx_in);
990088d6233eb1 Grant Seltzer          2023-01-27  822  	__u32 ctx_size_in = kattr->test.ctx_size_in;
990088d6233eb1 Grant Seltzer          2023-01-27  823  	struct bpf_tracing_test_run_info info;
990088d6233eb1 Grant Seltzer          2023-01-27  824  	int cpu = kattr->test.cpu;
da00d2f117a08f KP Singh               2020-03-04  825  
b530e9e1063ed2 Toke Høiland-Jørgensen 2022-03-09  826  	if (kattr->test.flags || kattr->test.cpu || kattr->test.batch_size)
1b4d60ec162f82 Song Liu               2020-09-25  827  		return -EINVAL;
1b4d60ec162f82 Song Liu               2020-09-25  828  
da00d2f117a08f KP Singh               2020-03-04  829  	switch (prog->expected_attach_type) {
da00d2f117a08f KP Singh               2020-03-04  830  	case BPF_TRACE_FENTRY:
da00d2f117a08f KP Singh               2020-03-04  831  	case BPF_TRACE_FEXIT:
faeb2dce084aff Alexei Starovoitov     2019-11-14  832  		if (bpf_fentry_test1(1) != 2 ||
faeb2dce084aff Alexei Starovoitov     2019-11-14  833  		    bpf_fentry_test2(2, 3) != 5 ||
faeb2dce084aff Alexei Starovoitov     2019-11-14  834  		    bpf_fentry_test3(4, 5, 6) != 15 ||
faeb2dce084aff Alexei Starovoitov     2019-11-14  835  		    bpf_fentry_test4((void *)7, 8, 9, 10) != 34 ||
faeb2dce084aff Alexei Starovoitov     2019-11-14  836  		    bpf_fentry_test5(11, (void *)12, 13, 14, 15) != 65 ||
d923021c2ce12a Yonghong Song          2020-06-30  837  		    bpf_fentry_test6(16, (void *)17, 18, 19, (void *)20, 21) != 111 ||
d923021c2ce12a Yonghong Song          2020-06-30  838  		    bpf_fentry_test7((struct bpf_fentry_test_t *)0) != 0 ||
d923021c2ce12a Yonghong Song          2020-06-30  839  		    bpf_fentry_test8(&arg) != 0)
da00d2f117a08f KP Singh               2020-03-04  840  			goto out;
da00d2f117a08f KP Singh               2020-03-04  841  		break;
3d08b6f29cf33a KP Singh               2020-03-04  842  	case BPF_MODIFY_RETURN:
3d08b6f29cf33a KP Singh               2020-03-04  843  		ret = bpf_modify_return_test(1, &b);
3d08b6f29cf33a KP Singh               2020-03-04  844  		if (b != 2)
3d08b6f29cf33a KP Singh               2020-03-04  845  			side_effect = 1;
3d08b6f29cf33a KP Singh               2020-03-04  846  		break;
da00d2f117a08f KP Singh               2020-03-04  847  	default:
da00d2f117a08f KP Singh               2020-03-04  848  		goto out;
a25ecd9d1e6024 Colin Ian King         2019-11-18  849  	}
da00d2f117a08f KP Singh               2020-03-04  850  
990088d6233eb1 Grant Seltzer          2023-01-27  851  	/* doesn't support data_in/out, ctx_out, duration, or repeat */
990088d6233eb1 Grant Seltzer          2023-01-27  852  	if (kattr->test.data_in || kattr->test.data_out ||
990088d6233eb1 Grant Seltzer          2023-01-27  853  	    kattr->test.ctx_out || kattr->test.duration ||
990088d6233eb1 Grant Seltzer          2023-01-27  854  	    kattr->test.repeat || kattr->test.batch_size)
990088d6233eb1 Grant Seltzer          2023-01-27  855  		return -EINVAL;
990088d6233eb1 Grant Seltzer          2023-01-27  856  
990088d6233eb1 Grant Seltzer          2023-01-27  857  	if (ctx_size_in < prog->aux->max_ctx_offset ||
990088d6233eb1 Grant Seltzer          2023-01-27  858  	    ctx_size_in > MAX_BPF_FUNC_ARGS * sizeof(u64))
990088d6233eb1 Grant Seltzer          2023-01-27  859  		return -EINVAL;
990088d6233eb1 Grant Seltzer          2023-01-27  860  
990088d6233eb1 Grant Seltzer          2023-01-27  861  	if ((kattr->test.flags & BPF_F_TEST_RUN_ON_CPU) == 0 && cpu != 0)
990088d6233eb1 Grant Seltzer          2023-01-27  862  		return -EINVAL;
990088d6233eb1 Grant Seltzer          2023-01-27  863  
990088d6233eb1 Grant Seltzer          2023-01-27  864  	if (ctx_size_in) {
990088d6233eb1 Grant Seltzer          2023-01-27  865  		info.ctx = memdup_user(ctx_in, ctx_size_in);
990088d6233eb1 Grant Seltzer          2023-01-27  866  		if (IS_ERR(info.ctx))
990088d6233eb1 Grant Seltzer          2023-01-27  867  			return PTR_ERR(info.ctx);
990088d6233eb1 Grant Seltzer          2023-01-27  868  	} else {
990088d6233eb1 Grant Seltzer          2023-01-27  869  		info.ctx = NULL;
990088d6233eb1 Grant Seltzer          2023-01-27  870  	}
3d08b6f29cf33a KP Singh               2020-03-04  871  
da00d2f117a08f KP Singh               2020-03-04  872  	err = 0;
990088d6233eb1 Grant Seltzer          2023-01-27  873  	info.prog = prog;
990088d6233eb1 Grant Seltzer          2023-01-27  874  
990088d6233eb1 Grant Seltzer          2023-01-27  875  	current_cpu = get_cpu();
990088d6233eb1 Grant Seltzer          2023-01-27  876  	if ((kattr->test.flags & BPF_F_TEST_RUN_ON_CPU) == 0 ||
990088d6233eb1 Grant Seltzer          2023-01-27  877  	    cpu == current_cpu) {
990088d6233eb1 Grant Seltzer          2023-01-27  878  		__bpf_prog_test_run_tracing(&info);
990088d6233eb1 Grant Seltzer          2023-01-27  879  	} else if (cpu >= nr_cpu_ids || !cpu_online(cpu)) {
990088d6233eb1 Grant Seltzer          2023-01-27  880  		/* smp_call_function_single() also checks cpu_online()
990088d6233eb1 Grant Seltzer          2023-01-27  881  		 * after csd_lock(). However, since cpu is from user
990088d6233eb1 Grant Seltzer          2023-01-27  882  		 * space, let's do an extra quick check to filter out
990088d6233eb1 Grant Seltzer          2023-01-27  883  		 * invalid value before smp_call_function_single().
990088d6233eb1 Grant Seltzer          2023-01-27  884  		 */
990088d6233eb1 Grant Seltzer          2023-01-27  885  		err = -ENXIO;
990088d6233eb1 Grant Seltzer          2023-01-27  886  	} else {
990088d6233eb1 Grant Seltzer          2023-01-27  887  		err = smp_call_function_single(cpu, __bpf_prog_test_run_tracing,
990088d6233eb1 Grant Seltzer          2023-01-27  888  					       &info, 1);
990088d6233eb1 Grant Seltzer          2023-01-27  889  	}
990088d6233eb1 Grant Seltzer          2023-01-27  890  	put_cpu();
990088d6233eb1 Grant Seltzer          2023-01-27  891  
990088d6233eb1 Grant Seltzer          2023-01-27  892  	if (!err &&
990088d6233eb1 Grant Seltzer          2023-01-27  893  	    copy_to_user(&uattr->test.retval, &info.retval, sizeof(u32)))
990088d6233eb1 Grant Seltzer          2023-01-27  894  		err = -EFAULT;
990088d6233eb1 Grant Seltzer          2023-01-27  895  
990088d6233eb1 Grant Seltzer          2023-01-27  896  	kfree(info.ctx);
990088d6233eb1 Grant Seltzer          2023-01-27  897  
da00d2f117a08f KP Singh               2020-03-04  898  out:
da00d2f117a08f KP Singh               2020-03-04  899  	trace_bpf_test_finish(&err);
da00d2f117a08f KP Singh               2020-03-04  900  	return err;
1cf1cae963c2e6 Alexei Starovoitov     2017-03-30  901  }
1cf1cae963c2e6 Alexei Starovoitov     2017-03-30  902  

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



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux