RFC Extend rseq with sched_state_ptr field
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 RFC Latest4 patches 29 repliesIn review
- v1 RFC4 patches 12 repliesSuperseded
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | rseq: Add sched_state field to struct rseqinclude/ include/ kernel/ | +100 | 28 replies | |
| 2/4 | selftests/rseq: Add sched_state rseq field and gettertools/ tools/ tools/ | +60 | 0 replies | |
| 3/4 | selftests/rseq: Implement sched state test programtools/ tools/ tools/ | +74 | 0 replies | |
| 4/4 | selftests/rseq: Implement rseq_mutex test programtools/ tools/ tools/ | +123 | 1 reply |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [RFC PATCH v2 0/4] Extend rseq with sched_state_ptr field
This prototype extends struct rseq with a new sched_state_ptr field, which points to a structure containing a "on-cpu" flag kept up-to-date by the scheduler.
It is meant to be used by userspace adaptative mutexes to decide between busy-wait and futex wait system call (releasing the CPU) behaviors based on the current state of the mutex owner.
The goal is to improve use-cases where the duration of the critical sections for a given lock follows a multi-modal distribution, preventing statistical guesses from doing a good job at choosing between busy-wait and futex wait behavior.
This is in response to the LWN coverage of 2023 Open Source Summit North America (https://lwn.net/Articles/931789/) unscheduled slot "Adaptive spinning in user space" presented by André Almeida.
New in this v2:
- Introduce a "struct rseq_sched_state", which contains the on-cpu scheduler flag and a thread ID field. This eliminates false sharing on the struct rseq cache lines caused by busy-waiting.
I have favored adding a "thread ID" field to struct rseq_sched_state rather than adding stores of owner pointer in addition to a compare-and-swap and store on a uint32_t for lock state to minimize the number of stores to perform on the fast-path.
Feedback is welcome!
Mathieu
Mathieu Desnoyers (4):
rseq: Add sched_state field to struct rseq selftests/rseq: Add sched_state rseq field and getter selftests/rseq: Implement sched state test program selftests/rseq: Implement rseq_mutex test program
include/linux/sched.h | 16 +++ include/uapi/linux/rseq.h | 41 ++++++ kernel/rseq.c | 43 +++++++ tools/testing/selftests/rseq/.gitignore | 2 + tools/testing/selftests/rseq/Makefile | 3 +- tools/testing/selftests/rseq/rseq-abi.h | 42 ++++++ tools/testing/selftests/rseq/rseq.c | 13 ++ tools/testing/selftests/rseq/rseq.h | 5 + tools/testing/selftests/rseq/rseq_mutex.c | 120 ++++++++++++++++++ .../testing/selftests/rseq/sched_state_test.c | 72 +++++++++++ 10 files changed, 356 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/rseq/rseq_mutex.c create mode 100644 tools/testing/selftests/rseq/sched_state_test.c
Signature · 1 line
2.25.1