All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/3] make bpf_task_storage_busy being preemption-safe
@ 2022-08-29 14:27 Hou Tao
  2022-08-29 14:27 ` [PATCH bpf-next 1/3] bpf: Use this_cpu_{inc|dec|inc_return} for bpf_task_storage_busy Hou Tao
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Hou Tao @ 2022-08-29 14:27 UTC (permalink / raw)
  To: bpf
  Cc: Song Liu, Sebastian Andrzej Siewior, Hao Sun, Hao Luo,
	Andrii Nakryiko, Yonghong Song, Alexei Starovoitov,
	Daniel Borkmann, Martin KaFai Lau, KP Singh, David S . Miller,
	Jakub Kicinski, Stanislav Fomichev, Jiri Olsa, John Fastabend,
	Lorenz Bauer, houtao1

From: Hou Tao <houtao1@huawei.com>

Hi,

The patchset aims to make the update of bpf_task_storage_busy being
preemption-safe. The problem is on same architectures (e.g. arm64),
__this_cpu_{inc|dec|inc_return} are neither preemption-safe nor
IRQ-safe, so the concurrent lookups or updates on the same task local
storage and the same CPU may make bpf_task_storage_busy be imbalanced,
and bpf_task_storage_trylock() on specific cpu will always fail.

Patch 1 fixes the problem by using preemption/IRQ-safe per-cpu helpers.
And patch 2 & patch 3 add a test case for the problem. Comments are
always welcome.

Regards,
Tao

Hou Tao (3):
  bpf: Use this_cpu_{inc|dec|inc_return} for bpf_task_storage_busy
  selftests/bpf: Move sys_pidfd_open() into test_progs.h
  selftests/bpf: Test concurrent updates on bpf_task_storage_busy

 kernel/bpf/bpf_local_storage.c                |  4 +-
 kernel/bpf/bpf_task_storage.c                 |  8 +-
 .../bpf/prog_tests/task_local_storage.c       | 91 +++++++++++++++++++
 .../selftests/bpf/prog_tests/test_bprm_opts.c |  9 --
 .../bpf/prog_tests/test_local_storage.c       |  9 --
 tools/testing/selftests/bpf/test_progs.h      |  9 ++
 6 files changed, 106 insertions(+), 24 deletions(-)

-- 
2.29.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-08-31  2:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-29 14:27 [PATCH bpf-next 0/3] make bpf_task_storage_busy being preemption-safe Hou Tao
2022-08-29 14:27 ` [PATCH bpf-next 1/3] bpf: Use this_cpu_{inc|dec|inc_return} for bpf_task_storage_busy Hou Tao
2022-08-30  0:52   ` Martin KaFai Lau
2022-08-30  2:21     ` Hou Tao
2022-08-31  0:41       ` Martin KaFai Lau
2022-08-31  2:04         ` Hou Tao
2022-08-29 14:27 ` [PATCH bpf-next 2/3] selftests/bpf: Move sys_pidfd_open() into test_progs.h Hou Tao
2022-08-29 14:27 ` [PATCH bpf-next 3/3] selftests/bpf: Test concurrent updates on bpf_task_storage_busy Hou Tao
2022-08-30  1:13   ` Martin KaFai Lau
2022-08-30  2:37     ` Hou Tao
2022-08-31  0:47       ` Martin KaFai Lau
2022-08-31  2:07         ` Hou Tao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.