After scouring the XNU kernel source code, I came across restartable ranges [1].
They seem to be a task-level version of the the part of Linux's restartable sequences [2] for user requested synchronization [3] (akin to MEMBARRIER_CMD_RSEQ).
Because of their differences, I would like to know more about how they work and what they are used for.
From what I have gathered [4], they seem to be closer to RCU [5] that waits for eviction (as opposed to completion). But the fact that they are barely mentioned anywhere (see [4]) in the XNU source code
I'd be really happy if you can point me to more information about them and how they compare to rseq (or rcu). What are the XNU devs planning on doing with them?
[1] osfmk/kern/restartable.c: https://github.com/apple-oss-distributions/xnu/blob/f6217f8/osfmk/kern/restartable.c
[2] https://criu.org/Restartable_Sequences
[3] as opposed to (what I think is what makes rseq really cool) automatic eviction on preemption/CPU migration
[4] there seems to be very little information online (including this forum) and the only places inside the XNU kernel source trees that aren't tests are in osfmk/kern/{thread,thread,sched_prim}.{c,h}, which doesn't really give much more information.
[5] Read-Copy-Update: https://www.kernel.org/doc/html/latest/RCU/whatisRCU.html
This is definitely a ‘just because you can doesn’t mean you should’ moment (-:
What are the XNU devs planning on doing with them?
To be clear, we can’t talk about The Future™ here on the forums. See tip 3 in Quinn’s Top Ten DevForums Tips.
However, you can see this feature already being used by the Objective-C runtime.
Which brings me back to my original point. While this is technically API, you’d want to think very carefully before using it in a product that you ship to a wide range of end users. The Objective-C runtime has the advantage that it’s built in to the system, so if the system changes in a way that breaks this API it can adapt. In contrast, any third-party products in the same situation would require an urgent, and potentially very difficult, update.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"