Skip to content

Commit

Permalink
x86_64: avoid unnecessary TLB flushes during context switching
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Sep 8, 2024
1 parent cca4d04 commit 1836172
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/platform/x86_64/sched/switch.asm
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,15 @@ platformLoadContext:

fxrstor [rdi]

mov rax, [rdi+512] ; paging
; save performance by only invalidating TLB if the context actually changed
mov rax, cr3
cmp rax, [rdi+512] ; pml4
jz .continue

mov rax, [rdi+512]
mov cr3, rax

.continue:
mov rax, [rdi+672] ; stack segment
mov ds, rax
mov es, rax
Expand Down

0 comments on commit 1836172

Please sign in to comment.