Re: [PATCH v3 bpf-next] bpf: Avoid unnecessary -EBUSY from htab_lock_bucket

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

 




> On Oct 4, 2023, at 8:23 PM, Song Liu <song@xxxxxxxxxx> wrote:
> 
> htab_lock_bucket uses the following logic to avoid recursion:
> 
> 1. preempt_disable();
> 2. check percpu counter htab->map_locked[hash] for recursion;
>   2.1. if map_lock[hash] is already taken, return -BUSY;
> 3. raw_spin_lock_irqsave();
> 
> However, if an IRQ hits between 2 and 3, BPF programs attached to the IRQ
> logic will not able to access the same hash of the hashtab and get -EBUSY.
> This -EBUSY is not really necessary. Fix it by disabling IRQ before
> checking map_locked:
> 
> 1. preempt_disable();
> 2. local_irq_save();
> 3. check percpu counter htab->map_locked[hash] for recursion;
>   3.1. if map_lock[hash] is already taken, return -BUSY;
> 4. raw_spin_lock().
> 
> Similarly, use raw_spin_unlock() and local_irq_restore() in
> htab_unlock_bucket().
> 
> Suggested-by: Tejun Heo <tj@xxxxxxxxxx>
> Signed-off-by: Song Liu <song@xxxxxxxxxx>

Somehow this didn't make to lore and thus not to patchwork. Let
me resend, sorry for the noise. 

Song





[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