• Song Liu's avatar
    bpf: Use raw_spin_trylock() for pcpu_freelist_push/pop in NMI · 39d8f0d1
    Song Liu authored
    Recent improvements in LOCKDEP highlighted a potential A-A deadlock with
    pcpu_freelist in NMI:
    
    ./tools/testing/selftests/bpf/test_progs -t stacktrace_build_id_nmi
    
    [   18.984807] ================================
    [   18.984807] WARNING: inconsistent lock state
    [   18.984808] 5.9.0-rc6-01771-g1466de1330e1 #2967 Not tainted
    [   18.984809] --------------------------------
    [   18.984809] inconsistent {INITIAL USE} -> {IN-NMI} usage.
    [   18.984810] test_progs/1990 [HC2[2]:SC0[0]:HE0:SE1] takes:
    [   18.984810] ffffe8ffffc219c0 (&head->lock){....}-{2:2}, at: __pcpu_freelist_pop+0xe3/0x180
    [   18.984813] {INITIAL USE} state was registered at:
    [   18.984814]   lock_acquire+0x175/0x7c0
    [   18.984814]   _raw_spin_lock+0x2c/0x40
    [   18.984815]   __pcpu_freelist_pop+0xe3/0x180
    [   18.984815]   pcpu_freelist_pop+0x31/0x40
    [   18.984816]   htab_map_alloc+0xbbf/0xf40
    [   18.984816]   __do_sys_bpf+0x5aa/0x3ed0
    [   18.984817]   do_syscall_64+0x2d/0x40
    [   18.984...
    39d8f0d1
percpu_freelist.c 4.66 KB