Re: [PATCH bpf-next v1 1/4] bpf: Save struct_ops instance pointer in bpf_prog_aux

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

 



On Mon, Jun 09, 2025 at 04:27:43PM -0700, Amery Hung wrote:
> Allows struct_ops implementors to infer the calling struct_ops instance
> inside a kfunc through prog->aux->this_st_ops. A new field, flags, is
> added to bpf_struct_ops. If BPF_STRUCT_OPS_F_THIS_PTR is set in flags,
> a pointer to the struct_ops structure registered to the kernel (i.e.,
> kvalue->data) will be saved to prog->aux->this_st_ops. To access it in
> a kfunc, use BPF_STRUCT_OPS_F_THIS_PTR with __prog argument [0]. The
> verifier will fixup the argument with a pointer to prog->aux. this_st_ops
> is protected by rcu and is valid until a struct_ops map is unregistered
> updated.
> 
> For a struct_ops map with BPF_STRUCT_OPS_F_THIS_PTR, to make sure all
> programs in it have the same this_st_ops, cmpxchg is used. Only if a
> program is not already used in another struct_ops map also with
> BPF_STRUCT_OPS_F_THIS_PTR can it be assigned to the current struct_ops
> map.
> 
> [0]
> commit bc049387b41f ("bpf: Add support for __prog argument suffix to
> pass in prog->aux")
> https://lore.kernel.org/r/20250513142812.1021591-1-memxor@xxxxxxxxx
> 
> Signed-off-by: Amery Hung <ameryhung@xxxxxxxxx>

FWIW, this looks great from sched_ext POV.

Thanks.

-- 
tejun




[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