• Hou Tao's avatar
    selftests/bpf: Test preemption between bpf_obj_new() and bpf_obj_drop() · 29c11aa8
    Hou Tao authored
    The test case creates 4 threads and then pins these 4 threads in CPU 0.
    These 4 threads will run different bpf program through
    bpf_prog_test_run_opts() and these bpf program will use bpf_obj_new()
    and bpf_obj_drop() to allocate and free local kptrs concurrently.
    
    Under preemptible kernel, bpf_obj_new() and bpf_obj_drop() may preempt
    each other, bpf_obj_new() may return NULL and the test will fail before
    applying these fixes as shown below:
    
      test_preempted_bpf_ma_op:PASS:open_and_load 0 nsec
      test_preempted_bpf_ma_op:PASS:attach 0 nsec
      test_preempted_bpf_ma_op:PASS:no test prog 0 nsec
      test_preempted_bpf_ma_op:PASS:no test prog 0 nsec
      test_preempted_bpf_ma_op:PASS:no test prog 0 nsec
      test_preempted_bpf_ma_op:PASS:no test prog 0 nsec
      test_preempted_bpf_ma_op:PASS:pthread_create 0 nsec
      test_preempted_bpf_ma_op:PASS:pthread_create 0 nsec
      test_preempted_bpf_ma_op:PASS:pthread_create 0 nsec
      test_preempted_bpf_ma_op:PASS:pthread_create 0 nsec
      test_preempted_bpf_ma_op:PASS:run prog err 0 nsec
      test_preempted_bpf_ma_op:PASS:run prog err 0 nsec
      test_preempted_bpf_ma_op:PASS:run prog err 0 nsec
      test_preempted_bpf_ma_op:PASS:run prog err 0 nsec
      test_preempted_bpf_ma_op:FAIL:ENOMEM unexpected ENOMEM: got TRUE
      #168     preempted_bpf_ma_op:FAIL
      Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED
    Signed-off-by: default avatarHou Tao <houtao1@huawei.com>
    Link: https://lore.kernel.org/r/20230901111954.1804721-4-houtao@huaweicloud.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    29c11aa8
preempted_bpf_ma_op.c 1.73 KB