Well, page tables don't change on a thread context switch, that is relevant for this discussion.
Re:Re: 100k Threads? (2002)
by PhilipRoman on Saturday September 23, 2023 @10:04AM
(#37623320)
Why do page tables need to change in a context switch between two threads? AFAIK the kernel is mapped in every process, just not accessible in user mode.
The biggest cost of a context switch, though, is typically that your CPU goes to do something else, which reduces the efficiency of any caches (including branch prediction etc.). This is the same whether you have kernel or userspace context switches, assuming the threads you're switching between touch different code and/or data.