Repository navigation
Commit 6c17f7c
authored
Expose how much scratch a sandbox has allocated (#2019)
Adds `Sandbox::scratch_allocated_bytes()`, which returns how far the
guest's scratch bump allocator has moved since the sandbox was last
restored or snapshotted.
Every page a guest writes after a restore is taken from scratch through
that allocator, whether it's a copy-on-write copy of a snapshot page, a
fresh page, or a page table. So this is how much memory the sandbox has
dirtied. The host already reads the allocator on restore. This makes it
public, so a host such as fiberd can charge each sandbox for what it
wrote, the same way on KVM, mshv, WHP and HVF.
- `SandboxMemoryManager::used_scratch_end_gpa()` reads the allocator,
held to the transport arena since the guest controls it.
`install_captured_snapshot` now uses it too.
- `Sandbox::scratch_allocated_bytes()` returns the bytes between the
first free scratch page and that end. It is 0 after a restore or
snapshot and capped at the scratch the guest can allocate.
- A unit test covers growth with writes, determinism across restores,
and the reset at restore and at snapshot.
- CHANGELOG entry under Added.
---------
Signed-off-by: danbugs <danilochiarlone@gmail.com>1 parent 3294ee3 commit 6c17f7c
3 files changed
Lines changed: 90 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
987 | 987 | | |
988 | 988 | | |
989 | 989 | | |
990 | | - | |
991 | | - | |
992 | | - | |
| 990 | + | |
993 | 991 | | |
994 | 992 | | |
995 | 993 | | |
996 | 994 | | |
997 | 995 | | |
998 | 996 | | |
999 | 997 | | |
1000 | | - | |
1001 | | - | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
1002 | 1019 | | |
1003 | | - | |
1004 | | - | |
1005 | | - | |
1006 | 1020 | | |
1007 | 1021 | | |
1008 | 1022 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1279 | 1279 | | |
1280 | 1280 | | |
1281 | 1281 | | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
1282 | 1311 | | |
1283 | 1312 | | |
1284 | 1313 | | |
| |||
1673 | 1702 | | |
1674 | 1703 | | |
1675 | 1704 | | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
1676 | 1734 | | |
1677 | 1735 | | |
1678 | 1736 | | |
| |||
3121 | 3179 | | |
3122 | 3180 | | |
3123 | 3181 | | |
| 3182 | + | |
| 3183 | + | |
| 3184 | + | |
| 3185 | + | |
| 3186 | + | |
| 3187 | + | |
| 3188 | + | |
| 3189 | + | |
| 3190 | + | |
3124 | 3191 | | |
3125 | 3192 | | |
3126 | 3193 | | |
| |||
0 commit comments