Repository navigation
Commit 9f7cfba
authored
Hoist the XCOMP_BV read into MSHV vCPU creation (#1912)
Currently, every MSHV vCPU reset calls `get_xsave` to copy XCOMP_BV into
the zeroed XSAVE area. This PR hoists that read into vCPU creation, and
every reset reuses the value. This saves one hypercall per
`Sandbox::restore()`.
This is safe because XCOMP_BV depends only on the partition's XSAVE
features, which are fixed at partition initialization and unaffected by
guest state or snapshots.
## Benchmarks
`mshv3`: AMD EPYC 7763, Linux 6.6 MSHV.
| Benchmark | Before | After | Change |
|---|---|---|---|
| `snapshots/restore/default` | 87.9 µs | 66.0 µs | −25% |
| `snapshots/restore/small` | 88.6 µs | 66.5 µs | −25% |
| `snapshots/restore/medium` | 99.4 µs | 77.9 µs | −22% |
| `guest_calls/call_with_restore/default` | 156.8 µs | 133.9 µs | −15% |
| `guest_calls/call_with_restore/medium` | 165.5 µs | 140.6 µs | −15% |
| `sandboxes/create_initialized/default` | 1.48 ms | 1.53 ms | +3% |
| `sandboxes/sandbox_from_snapshot/default` | 598 µs | 624 µs | +4% |
Each restore saves one `get_xsave` hypercall, about 22 µs. Each vCPU
creation makes that hypercall once.
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>1 parent 558732b commit 9f7cfba
3 files changed
Lines changed: 15 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
158 | 160 | | |
159 | 161 | | |
160 | 162 | | |
| |||
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
212 | 220 | | |
213 | 221 | | |
214 | 222 | | |
215 | 223 | | |
216 | 224 | | |
217 | 225 | | |
| 226 | + | |
218 | 227 | | |
219 | 228 | | |
220 | 229 | | |
| |||
569 | 578 | | |
570 | 579 | | |
571 | 580 | | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | 581 | | |
585 | 582 | | |
586 | 583 | | |
587 | | - | |
| 584 | + | |
588 | 585 | | |
589 | 586 | | |
590 | 587 | | |
| |||
0 commit comments