Post

Replies

Boosts

Views

Activity

Reply to Restartable Sequences. What are they?
Thank you for the answer! Unfortunately, the "doesn't mean you should" part did not survive my selective reading (more questions at the end). It turns out that the fact that they are being used by the Objective-C runtime makes them harder to work with on release kernels because they may only be registered once [1]. Luckily, there is a way to get around that restriction by symbol-interposing [2, 3] task_restartable_ranges_register. I have built a little demo/writeup on how one can try it out on release kernels at [4]. It appears as though macOS 26's SDK only registered five such ranges in libobjc, which jumped to thirty-nine in macOS 27. At this rate, we might not have enough spots for the user as there seems to be a limit of 64 registered ranges [5]. Are there plans to remove the "register once only" limitation or to increase the max number of ranges? Do you see automatic redirection on preemption (similar to linux's rseq) coming to restartable ranges? I would imagine one of the task_restartable_ranges_t.flags bits could opt a range in to this behaviour such that existing ranges used by the scheduler don't completely break. The current implementation seems to check that the program counter is strictly higher than the start symbol [6]. I went through this in my head many times and it seemed reasonable (because the PC is the next instruction), but in my testing [4], it meant having to add a nop the start of my simple looping range .text .globl _myrange_start, _myrange_end .globl _myrange_recovery _myrange_start: nop loop: b loop _myrange_end: _myrange_recovery: ret Why could this be? [1] https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/kern/restartable.c#L562 [2] dyld-interposing.h: https://github.com/apple-oss-distributions/dyld/blob/dyld-1378/include/mach-o/dyld-interposing.h [3] great writeup on symbol interposing: https://github.com/DerekSelander/symbol-interposing [4] full writeup: https://github.com/kimhanm/restartable-ranges-writeup [5] https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/kern/restartable.c#L75 [6] https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/kern/restartable.c#L203
Topic: App & System Services SubTopic: Core OS Tags:
3w
Reply to Restartable Sequences. What are they?
Thank you for the answer! Unfortunately, the "doesn't mean you should" part did not survive my selective reading (more questions at the end). It turns out that the fact that they are being used by the Objective-C runtime makes them harder to work with on release kernels because they may only be registered once [1]. Luckily, there is a way to get around that restriction by symbol-interposing [2, 3] task_restartable_ranges_register. I have built a little demo/writeup on how one can try it out on release kernels at [4]. It appears as though macOS 26's SDK only registered five such ranges in libobjc, which jumped to thirty-nine in macOS 27. At this rate, we might not have enough spots for the user as there seems to be a limit of 64 registered ranges [5]. Are there plans to remove the "register once only" limitation or to increase the max number of ranges? Do you see automatic redirection on preemption (similar to linux's rseq) coming to restartable ranges? I would imagine one of the task_restartable_ranges_t.flags bits could opt a range in to this behaviour such that existing ranges used by the scheduler don't completely break. The current implementation seems to check that the program counter is strictly higher than the start symbol [6]. I went through this in my head many times and it seemed reasonable (because the PC is the next instruction), but in my testing [4], it meant having to add a nop the start of my simple looping range .text .globl _myrange_start, _myrange_end .globl _myrange_recovery _myrange_start: nop loop: b loop _myrange_end: _myrange_recovery: ret Why could this be? [1] https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/kern/restartable.c#L562 [2] dyld-interposing.h: https://github.com/apple-oss-distributions/dyld/blob/dyld-1378/include/mach-o/dyld-interposing.h [3] great writeup on symbol interposing: https://github.com/DerekSelander/symbol-interposing [4] full writeup: https://github.com/kimhanm/restartable-ranges-writeup [5] https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/kern/restartable.c#L75 [6] https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/kern/restartable.c#L203
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
3w