Re: [PATCH bpf-next v2 2/2] selftests/bpf: Test gen_pro/epilogue that generate kfuncs

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

 



On Thu, 2025-02-20 at 13:25 -0800, Amery Hung wrote:

[...]

Given that prologue and epilogue generation is already tested,
it appears that it would be sufficient to add only two tests:
'test_kfunc_pro_epilogue' / 'syscall_pro_epilogue'.
Not sure if testing prologue and epilogue generation separately adds
much value in this context, wdyt?

[...]

> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index 6c296ff551e0..ddebab05934f 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -606,6 +606,7 @@ s32 bpf_find_btf_id(const char *name, u32 kind, struct btf **btf_p)
>  	spin_unlock_bh(&btf_idr_lock);
>  	return ret;
>  }
> +EXPORT_SYMBOL_GPL(bpf_find_btf_id);

I think this is not necessary, see below.

[...]

> @@ -1410,6 +1493,13 @@ static void st_ops_unreg(void *kdata, struct bpf_link *link)
>  
>  static int st_ops_init(struct btf *btf)
>  {
> +	struct btf *kfunc_btf;
> +
> +	bpf_cgroup_from_id_id = bpf_find_btf_id("bpf_cgroup_from_id", BTF_KIND_FUNC, &kfunc_btf);
> +	bpf_cgroup_release_id = bpf_find_btf_id("bpf_cgroup_release", BTF_KIND_FUNC, &kfunc_btf);

Maybe use BTF_ID_LIST for this?
E.g. BTF_ID_LIST(bpf_testmod_dtor_ids) in this file, or
     BTF_ID_LIST(special_kfunc_list) in verifier.c?

(Just in case, sorry if you know this already,
 BTF_ID_LIST declares are set of symbols with special suffix/prefix,
 at build time tools/bpf/resolve_btfids looks for such symbols and patches
 their values to correspond to BTF ids of specified functions and structures).

> +	if (!bpf_cgroup_from_id_id || !bpf_cgroup_release_id)
> +		return -EINVAL;
> +
>  	return 0;
>  }
>  







[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