Re: map_lookup_and_delete_elem for BPF_MAP_TYPE_HASH

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

 



On Tue, Sep 15, 2020 at 1:15 AM Andrii Nakryiko
<andrii.nakryiko@xxxxxxxxx> wrote:
>
> On Fri, Sep 11, 2020 at 10:03 AM Borna Cafuk <borna.cafuk@xxxxxxxxxx> wrote:
> >
> > Hello everyone,
> >
> > As far as I can see, `map_lookup_and_delete_elem` is implemented only for
> > `BPF_MAP_TYPE_QUEUE` and `BPF_MAP_TYPE_STACK` [0]. It might be useful to be
> > able to do this operation on other kinds of maps, e.g. `BPF_MAP_TYPE_HASH`.
> >
> > If I'm not mistaken, it would have benefits over `bpf_map_lookup_elem` followed
> > by `bpf_map_delete_elem` in regards to avoiding race conditions.
>
> Yes, for a case when you know the key. But for the more general
> iteration cases, in which you go over all elements, read, and later
> remove element, not so much, because removing element would
> essentially break iteration. But I do agree, for some cases it should
> be quite useful.
>
> >
> > Is there a reason this functionality wasn't implemented?
>
> Probably no one had a specific use case for this.
>
> > Is it planned for any time soon?
> >
>
> No, as far as I'm aware.

Alright, thank you for the information.

>
> > I'm looking forward to your input.
>
> Feel free to implement this and send a patch. It doesn't seem to
> impose any extra limitations on use of BPF_MAP_TYPE_HASH, so I don't
> see why this can't be done.

Great, we'll begin looking into implementing it and submitting a patch.

>
> >
> > Best regards,
> > Borna Cafuk
> >
> > [0] https://elixir.bootlin.com/linux/v5.9-rc4/source/kernel/bpf/syscall.c#L1501



[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