Skip to content

Arena Spin Lock

Kumar Kartikeya Dwivedi bpf 8 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 posting 2/225 patches 1 replyApplied
  2. v5 Latest3 patches 0 repliesApplied 3/3
  3. v4 posting 1/23 patches 1 replySuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v3 posting 2/23 patches7 repliesSuperseded
v3 posting 1/225 patches1 replySuperseded
v2 posting 2/226 patches35 repliesSuperseded
v2 posting 1/22 patches1 replySuperseded
v12 patches0 repliesSuperseded

Changes in v5 from the cover letter

v4: https://lore.kernel.org/bpf/[email protected]

* Add better comment and document LLVM bug for __unqual_typeof.
* Switch to precise counting in the selftest and simplify test.
* Add comment about return value handling.
* Reduce size for 100k to 50k to cap test runtime.

Patches in v5 All 3 applied

#Subject and filesSizeRepliesApplied
1/3selftests/bpf: Introduce cond_break_labeltools/testing/selftests/bpf/bpf_experimental.h+9 -60 repliesApplied
2/3selftests/bpf: Introduce arena spin locktools/testing/selftests/bpf/bpf_arena_spin_lock.h tools/testing/selftests/bpf/bpf_atomic.h+652 -00 repliesApplied
3/3selftests/bpf: Add tests for arena spin locktools/testing/selftests/bpf/prog_tests/arena_spin_lock.c tools/testing/selftests/bpf/progs/arena_spin_lock.c+159 -00 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH bpf-next v5 0/3] Arena Spin Lock

This set provides an implementation of queued spin lock for arena. There is no support for resiliency and recovering from deadlocks yet. We will wait for the rqspinlock patch set to land before incorporating support.

One minor change compared to the qspinlock algorithm in the kernel is that we don't have the trylock fallback when nesting count exceeds 4. The maximum number of supported CPUs is 1024, but this can be increased in the future if necessary.

The API supports returning an error, so resiliency support can be added in the future. Callers are still expected to check for and handle any potential errors.

Errors are returned when the spin loops time out, when the number of CPUs is greater than 1024, or when the extreme edge case of NMI interrupting NMI interrupting HardIRQ interrupting SoftIRQ interrupting task, all of them simultaneously in slow path, occurs, which is unsupported.

Changelog:
----------
v4 -> v5
v4: https://lore.kernel.org/bpf/[email protected]

* Add better comment and document LLVM bug for __unqual_typeof.
* Switch to precise counting in the selftest and simplify test.
* Add comment about return value handling.
* Reduce size for 100k to 50k to cap test runtime.

v3 -> v4
v3: https://lore.kernel.org/bpf/[email protected]

* Drop extra corruption handling case in decode_tail.
* Stick to 1, 1k, 100k critical section sizes.
* Fix unqual_typeof to not cast away arena tag for pointers.
* Remove hack to skip first qnode.
* Choose 100 as repeat count, 1000 is too much for 100k size.
* Use pthread_barrier in test.

v2 -> v3
v2: https://lore.kernel.org/bpf/[email protected]

* Rename to arena_spin_lock
* Introduce cond_break_label macro to jump to label from cond_break.
* Drop trylock fallback when nesting count exceeds 4.
* Fix bug in try_cmpxchg implementation.
* Add tests with critical sections of varying lengths.
* Add comments for _Generic trick to drop __arena tag.
* Fix bug due to qnodes being placed on first page, leading to CPU 0's node being indistinguishable from NULL.

v1 -> v2
v1: https://lore.kernel.org/bpf/[email protected]

* Fix definition of lock in selftest

Kumar Kartikeya Dwivedi (3):
selftests/bpf: Introduce cond_break_label
selftests/bpf: Introduce arena spin lock
selftests/bpf: Add tests for arena spin lock

 .../selftests/bpf/bpf_arena_spin_lock.h       | 512 ++++++++++++++++++
 tools/testing/selftests/bpf/bpf_atomic.h      | 140 +++++
 .../testing/selftests/bpf/bpf_experimental.h  |  15 +-
 .../bpf/prog_tests/arena_spin_lock.c          | 108 ++++
 .../selftests/bpf/progs/arena_spin_lock.c     |  51 ++
 5 files changed, 820 insertions(+), 6 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/bpf_arena_spin_lock.h
 create mode 100644 tools/testing/selftests/bpf/bpf_atomic.h
 create mode 100644 tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c
 create mode 100644 tools/testing/selftests/bpf/progs/arena_spin_lock.c

base-commit: 7781fd0ddeb43d078b750ff27a54dd3f85a26481

Signature · 1 line
2.47.1