Sched_ext development
 help / color / mirror / Atom feed
* [PATCH v2 sched_ext/for-7.2 0/2] sched_ext: Add cookie API for early qseq capture
@ 2026-05-06 16:04 Cheng-Yang Chou
  2026-05-06 16:04 ` [PATCH v2 1/2] " Cheng-Yang Chou
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Cheng-Yang Chou @ 2026-05-06 16:04 UTC (permalink / raw)
  To: sched-ext, Tejun Heo, David Vernet, Andrea Righi, Changwoo Min
  Cc: Kuba Piecuch, Ching-Chun Huang, Chia-Ping Tsai, yphbchou0911

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/20260319083518.94673-1-arighi@nvidia.com/

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/20260506075925.371138-1-yphbchou0911@gmail.com/

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

-- 
2.48.1


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

end of thread, other threads:[~2026-05-08 18:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-06 16:04 [PATCH v2 sched_ext/for-7.2 0/2] sched_ext: Add cookie API for early qseq capture Cheng-Yang Chou
2026-05-06 16:04 ` [PATCH v2 1/2] " Cheng-Yang Chou
2026-05-06 20:34   ` sashiko-bot
2026-05-06 16:04 ` [PATCH v2 2/2] selftests/sched_ext: Add dispatch_cookie test Cheng-Yang Chou
2026-05-06 20:52   ` sashiko-bot
2026-05-07 10:43     ` Cheng-Yang Chou
2026-05-08 18:51 ` [PATCH v2 sched_ext/for-7.2 0/2] sched_ext: Add cookie API for early qseq capture Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox