← Back to context

Comment by dwattttt

2 days ago

Allowing SIMD instructions to be used arbitrarily in kernel actually has a fair penalty to it. I'm not sure what Linux does specifically, but:

When a syscall is made, the kernel has to backup the user mode state of the thread, so it can restore it later.

If any kernel code could use SIMD registers, you'll have to backup and restore that too, and those registers get big. You could easily be looking at adding a 1kb copy to every syscall, and most of the time it wouldn't be needed.

Why is that? Couldn’t there be push_simd()/pop_simd() that the syscall itself uses around its SIMD calls?

If no syscalls use SIMD today, I’d think we’re starting from a safe position.

  • push_simd/pop_simd exist and are called kernel_fpu_begin/kernel_fpu_end. Their use is practically prohibited in most areas and iiuc not available on all archs, but it's available if needed.