作者:liheng gong
链接:https://www.zhihu.com/question/26825537/answer/34544526
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
Why map both the user process and kernel into virtual memory at the same time? Why not map in the user process when in user-space and map the kernel when in kernel-space? One reason: Performance. Swapping the virtual address space incurs a nontrivial cost. Worse, depending on the system, various caches must be flushed. For example, on x86, the TLB, which caches virtual to physical address translations, must be flushed whenever the virtual mappings change. On systems with virtually-tagged caches, such as older ARM architectures, the entirety of the data and instruction cache must be flushed whenever you context switch! Cache performance is everything on modern systems, so avoiding such flushes is of paramount importance.Consequently, by mapping both the kernel and user address spaces into memory at the same time, context switching into the kernel becomes relatively cheap,
作者:liheng gong
链接:https://www.zhihu.com/question/26825537/answer/34544526
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
Why map both the user process and kernel into virtual memory at the same time? Why not map in the user process when in user-space and map the kernel when in kernel-space? One reason: Performance. Swapping the virtual address space incurs a nontrivial cost. Worse, depending on the system, various caches must be flushed. For example, on x86, the TLB, which caches virtual to physical address translations, must be flushed whenever the virtual mappings change. On systems with virtually-tagged caches, such as older ARM architectures, the entirety of the data and instruction cache must be flushed whenever you context switch! Cache performance is everything on modern systems, so avoiding such flushes is of paramount importance.Consequently, by mapping both the kernel and user address spaces into memory at the same time, context switching into the kernel becomes relatively cheap,