Re: [PATCH bpf-next] bpf/bpf_lru_list: make bpf_percpu_lru_pop_free safe in NMI

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

 



On Wed, Jul 17, 2024 at 6:44 PM Priya Bala Govindasamy <pgovind2@xxxxxxx> wrote:
>
> bpf_percpu_lru_pop_free uses raw_spin_lock_irqsave. This function is
> used by htab_percpu_lru_map_update_elem() which can be called from an
> NMI. A deadlock can happen if a bpf program holding the lock is
> interrupted by the same program in NMI. Use raw_spin_trylock_irqsave if
> in NMI.

And there is a htab_lock_bucket() protection and bpf prog
recursion protection logic that should prevent such deadlock.

Pls share the splat if this deadlock is real.

> -       raw_spin_lock_irqsave(&l->lock, flags);
> +       if (in_nmi()) {
> +               if (!raw_spin_trylock_irqsave(&l->lock, flags))
> +                       return NULL;
> +       } else {
> +               raw_spin_lock_irqsave(&l->lock, flags);
> +       }

We cannot do this, since it will make map behavior 'random'.
There are lots of other raw_spin_lock_irqsave() in that file.
Somehow they're not deadlocking?

pw-bot: cr





[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