4 ms·
> Kernels typically cannot use vector instructions because if they did they would need to save and restore the vector register state when servicing interrupts.
by sweetjuly 3y ago
> Kernels typically cannot use vector instructions because if they did they would need to save and restore the vector register state when servicing interrupts. There is a very large performance cost to doing that.
While this is true, it definitely doesn't seem to stop people like Apple [1] from using SIMD extensions in the kernel anyways. On ARMv8, it's an extra 512 bytes (32 qword registers) or eight (and change, depending on alignment) dirty cache lines. Whether or not this causes a serious performance impact will depend on how well the kernel can actually make use of SIMD (saving and restoring might cost 1% perf but if speeding up the kernel wins 5%, who cares!). It could be interesting to play with this on other kernels to verify these assumptions, it might be worth enabling in the kernel on some devices! Kernels do tend to do a lot of moving data around, which these extensions (on ARM, anyways) excel at.
[1] https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/arm64/exception_asm.h#L162-L177 https://github.com/apple-oss-distributions/xnu/blob/main/osf...