Skip to content

sched_ext: Add cookie API for early qseq capture

Cheng-Yang Chou sashiko sched-ext 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 2 repliesIn review
  2. v11 patch 2 repliesSuperseded

Changes in v2 from the cover letter

- Reword kdoc for both kfuncs to avoid exposing qseq and ops_state as implementation details (Kuba Piecuch)
- Add __ksym __weak declarations for new kfuncs in common.bpf.h
- Add dispatch_cookie selftest (Kuba Piecuch)
- Link to v1:
https://lore.kernel.org/r/[email protected]/

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2sched_ext: Add cookie API for early qseq capturekernel/sched/ext.c tools/sched_ext/include/scx/common.bpf.h+67 -40 replies
2/2selftests/sched_ext: Add dispatch_cookie testtools/testing/selftests/sched_ext/Makefile tools/testing/selftests/sched_ext/dispatch_cookie.bpf.c tools/testing/selftests/sched_ext/dispatch_cookie.c+113 -01 reply

Reviews trailers per patch

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

Read the v2 thread

Cover letter [PATCH v2 sched_ext/for-7.2 0/2] sched_ext: Add cookie API for early qseq capture

scx_bpf_dsq_insert() captures the task's sequence number at insert time, so any pre-dispatch validity checks a BPF scheduler performs before the insert fall outside the race detection window.

Patch 1 introduces two new kfuncs:
- scx_bpf_task_get_cookie() captures the sequence number early, before any pre-dispatch checks
- scx_bpf_dsq_insert_with_cookie() inserts using that early-captured value, extending the window. A stale cookie causes finish_dispatch() to silently discard the dispatch. This is intended for schedulers that do not implement properly synchronized dequeue.

Patch 2 adds a selftest exercising the two new kfuncs.

This series is discussed in [1].
[1]: https://lore.kernel.org/r/[email protected]/

Changes in v2:
- Reword kdoc for both kfuncs to avoid exposing qseq and ops_state as implementation details (Kuba Piecuch)
- Add __ksym __weak declarations for new kfuncs in common.bpf.h
- Add dispatch_cookie selftest (Kuba Piecuch)
- Link to v1:
https://lore.kernel.org/r/[email protected]/

Thanks,
Cheng-Yang

---

Cheng-Yang Chou (2):
sched_ext: Add cookie API for early qseq capture selftests/sched_ext: Add dispatch_cookie test

 kernel/sched/ext.c                            | 69 ++++++++++++++++-
 tools/sched_ext/include/scx/common.bpf.h      |  2 +
 tools/testing/selftests/sched_ext/Makefile    |  1 +
 .../selftests/sched_ext/dispatch_cookie.bpf.c | 38 ++++++++++
 .../selftests/sched_ext/dispatch_cookie.c     | 74 +++++++++++++++++++
 5 files changed, 180 insertions(+), 4 deletions(-)
 create mode 100644 tools/testing/selftests/sched_ext/dispatch_cookie.bpf.c
 create mode 100644 tools/testing/selftests/sched_ext/dispatch_cookie.c
Signature · 1 line
2.48.1