5 ms·
Also AVX512! And what the heck are we going to do when we need to save the AVX1024 register state! And we really going to push 1kb to memory per context switch?
by frozenport 9y ago
Also AVX512! And what the heck are we going to do when we need to save the AVX1024 register state! And we really going to push 1kb to memory per context switch? (I think this is somewhat solved by trapping when the registers are first invoked, and kernel drivers that use enhanced instruction sets actually need to pass flags before using them)
- jandrewrogers 9y agoThis highlights one of the advantages of context-switching in user space. The OS context switch can make few assumptions about the registers that actually need to be preserved once a register set has been used. Many user space context libraries, on the other hand, only preserve the half dozen basic registers per the ABI by default (very fast) and let the programmer optionally preserve the other register sets. In the vast majority of cases, you never need to preserve any additional state at the logical context switch points even when you are using those additional registers in your application.
- frozenport 9y agoAlternatively juat grep the function source and ban self modifying code. Or run self modifying code in a "fuck you" performance sandbox.
- MichaelMoser123 9y agoRight. Boosts set_fcontext even allows to omit the floating point registers (saves a lot of time if the application doesn't do fp)
- amluto 9y agoThis doesn't bother me as much. X86 could add lightweight instructions to clear large parts of the AVX state (a la VZEROALL) along with their associated "in use" flags, and compilers could be taught to emit these instructions whenever they're done using the big registers. Then context switches could mostly avoid touching them.
- flamedoge 9y ago??? it's way more than that. at least 32kb if they keep # of vector registers same.