selftests/bpf: Add tests for array map with local percpu kptr
authorYonghong Song <yonghong.song@linux.dev>
Sun, 27 Aug 2023 15:28:11 +0000 (08:28 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 8 Sep 2023 15:42:18 +0000 (08:42 -0700)
commit6adf82a4398d774398b4538dad561958c2c9521e
treef94db8a13ea660ba284fb176cbd09cebfc460791
parent968c76cb3dc6cc86e8099ecaa5c30dc0d4738a30
selftests/bpf: Add tests for array map with local percpu kptr

Add non-sleepable and sleepable tests with percpu kptr. For
non-sleepable test, four programs are executed in the order of:
  1. allocate percpu data.
  2. assign values to percpu data.
  3. retrieve percpu data.
  4. de-allocate percpu data.

The sleepable prog tried to exercise all above 4 steps in a
single prog. Also for sleepable prog, rcu_read_lock is needed
to protect direct percpu ptr access (from map value) and
following bpf_this_cpu_ptr() and bpf_per_cpu_ptr() helpers.

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20230827152811.2000125-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/percpu_alloc.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/percpu_alloc_array.c [new file with mode: 0644]