Re: [PATCH bpf-next 2/5] bpf: Add bpf_rcu_read_lock/unlock helper

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

 



On Thu, Nov 03, 2022 at 12:51:13PM IST, Yonghong Song wrote:
> Add bpf_rcu_read_lock() and bpf_rcu_read_unlock() helpers.
> Both helpers are available to all program types with
> CAP_BPF capability.
>
> Signed-off-by: Yonghong Song <yhs@xxxxxx>
> ---
>  include/linux/bpf.h            |  2 ++
>  include/uapi/linux/bpf.h       | 14 ++++++++++++++
>  kernel/bpf/core.c              |  2 ++
>  kernel/bpf/helpers.c           | 26 ++++++++++++++++++++++++++
>  tools/include/uapi/linux/bpf.h | 14 ++++++++++++++
>  5 files changed, 58 insertions(+)
>
> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
> index 8d948bfcb984..a9bda4c91fc7 100644
> --- a/include/linux/bpf.h
> +++ b/include/linux/bpf.h
> @@ -2554,6 +2554,8 @@ extern const struct bpf_func_proto bpf_get_retval_proto;
>  extern const struct bpf_func_proto bpf_user_ringbuf_drain_proto;
>  extern const struct bpf_func_proto bpf_cgrp_storage_get_proto;
>  extern const struct bpf_func_proto bpf_cgrp_storage_delete_proto;
> +extern const struct bpf_func_proto bpf_rcu_read_lock_proto;
> +extern const struct bpf_func_proto bpf_rcu_read_unlock_proto;
>
>  const struct bpf_func_proto *tracing_prog_func_proto(
>    enum bpf_func_id func_id, const struct bpf_prog *prog);
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index 94659f6b3395..e86389cd6133 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -5481,6 +5481,18 @@ union bpf_attr {
>   *		0 on success.
>   *
>   *		**-ENOENT** if the bpf_local_storage cannot be found.
> + *
> + * void bpf_rcu_read_lock(void)
> + *	Description
> + *		Call kernel rcu_read_lock().
> + *	Return
> + *		None.
> + *
> + * void bpf_rcu_read_unlock(void)
> + *	Description
> + *		Call kernel rcu_read_unlock().
> + *	Return
> + *		None.
>   */

It would be better to not bake these into UAPI and keep them unstable only IMO.

> [...]



[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