On 12/10/21 6:10 PM, Zebediah Figura wrote:
One possible optimization that Paul and I had discussed a while back was to allow for the possibility of "masked" or "uninterruptible" syscalls, that is, syscalls that cannot be directly interrupted with SuspendThread(). The idea is that instead of saving the whole nonvolatile context up front, you instead set a flag in the syscall dispatcher (when SIGUSR1 is received) that tells the restore path to save the whole context and break into the suspend handler.
This would only be usable for calls which don't sleep (or don't sleep for a meaningful amount of time), but as I understand that could include most Vulkan calls, including vkUpdateDescriptorSets and other important ones.
Note that it's not just SuspendThread() that would be affected, but also system APCs.
In cases like internal Vulkan syscalls we have a bit less compatibility constrains than in ntdll, because those are not syscalls called directly by applications. If xsave is causing a problem, we can put CPU into a state when it's cheaper. We discussed earlier doing vzeroupper, we could reset even more parts of the context to make xstor cheaper.
That, however, can help only with context store part of syscalls. There are other things like %fs base switching on the horizon.
Jacek