Re: [PATCH v1 bpf-next 4/9] bpf: Add bpf_refcount_acquire kfunc

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

 



On Mon, Apr 10, 2023 at 12:07:48PM -0700, Dave Marchevsky wrote:
> Currently, BPF programs can interact with the lifetime of refcounted
> local kptrs in the following ways:
> 
>   bpf_obj_new  - Initialize refcount to 1 as part of new object creation
>   bpf_obj_drop - Decrement refcount and free object if it's 0
>   collection add - Pass ownership to the collection. No change to
>                    refcount but collection is responsible for
> 		   bpf_obj_dropping it
> 
> In order to be able to add a refcounted local kptr to multiple
> collections we need to be able to increment the refcount and acquire a
> new owning reference. This patch adds a kfunc, bpf_refcount_acquire,
> implementing such an operation.
> 
> bpf_refcount_acquire takes a refcounted local kptr and returns a new
> owning reference to the same underlying memory as the input. The input
> can be either owning or non-owning. To reinforce why this is safe,
> consider the following code snippets:
> 
>   struct node *n = bpf_obj_new(typeof(*n)); // A
>   struct node *m = bpf_refcount_acquire(m); // B

typo. should probably be bpf_refcount_acquire(n) ?



[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