mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
kvm: set CR4.PGE
```
CR4.PGE (bit-7) enables Paging Global Extensions (PGE). PGE determines whether
moves to CR3 flush all of the PTE's from the TLB, or only those whose G-bit
(global bit) is not set. Likewise, for task switches which implicitly set CR3,
CR4.PGE controls TLB flushing in the same manner.
```
In case of gvisor, it improves performance of switching to/from the Sentry:
│ kvm │ kvm.pge │
│ wall_ns/op │ wall_ns/op vs base │
Getpid 1.774k ± 0% 1.607k ± 1% -9.36% (p=0.000 n=10)
GetpidOpt 1.623k ± 1% 1.452k ± 1% -10.54% (p=0.000 n=10)
geomean 1.696k 1.528k -9.95%
│ kvm │ kvm.pge │
│ cpu_ns/op │ cpu_ns/op vs base │
Getpid 1.749k ± 0% 1.583k ± 1% -9.52% (p=0.000 n=10)
GetpidOpt 1.600k ± 0% 1.414k ± 2% -11.62% (p=0.000 n=10)
geomean 1.673k 1.496k -10.58%
It plays only on hosts without PCID.
PiperOrigin-RevId: 671587163
This commit is contained in:
@@ -186,7 +186,7 @@ func (c *CPU) CR0() uint64 {
|
||||
//
|
||||
//go:nosplit
|
||||
func (c *CPU) CR4() uint64 {
|
||||
cr4 := uint64(_CR4_PAE | _CR4_PSE | _CR4_OSFXSR | _CR4_OSXMMEXCPT)
|
||||
cr4 := uint64(_CR4_PAE | _CR4_PSE | _CR4_PGE | _CR4_OSFXSR | _CR4_OSXMMEXCPT)
|
||||
if hasPCID {
|
||||
cr4 |= _CR4_PCIDE
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user