Commit 9536eaa
committed
fix: only use mmap trick when restoring from file
When the balloon inflates, and the guest gives us back some pages of
memory, we need to free those pages. In booted VMs, we do this with
madvise(MADV_DONTNEED), and in restored VMs we do it by MAP_FIXED-ing a
new VMA on top of the range-to-free. This is because if guest memory is
a MAP_PRIVATE of a memory file, madvise has no effect.
However, we also do this MAP_FIXED trick if the snapshot is restored
with UFFD. In this case, its not needed (madvise works perfectly fine),
and in fact, its wrong: If we map over the memory range, UFFD will not
receive Remove events for the specified range.
Fix this by only using the mmap trick for file-based restored.
Fixes #4988
Signed-off-by: Patrick Roy <[email protected]>1 parent bb1edd1 commit 9536eaa
File tree
6 files changed
+26
-13
lines changed- src/vmm/src
- device_manager
- devices/virtio/balloon
6 files changed
+26
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
| 534 | + | |
534 | 535 | | |
535 | 536 | | |
536 | 537 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
217 | 218 | | |
218 | 219 | | |
219 | 220 | | |
| |||
512 | 513 | | |
513 | 514 | | |
514 | 515 | | |
515 | | - | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
516 | 520 | | |
517 | 521 | | |
518 | 522 | | |
| |||
807 | 811 | | |
808 | 812 | | |
809 | 813 | | |
| 814 | + | |
810 | 815 | | |
811 | 816 | | |
812 | 817 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
| 192 | + | |
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
| 207 | + | |
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
248 | | - | |
| 248 | + | |
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
358 | | - | |
| 358 | + | |
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| |||
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
124 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
125 | 131 | | |
126 | 132 | | |
127 | 133 | | |
| |||
192 | 198 | | |
193 | 199 | | |
194 | 200 | | |
195 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
196 | 205 | | |
197 | 206 | | |
198 | 207 | | |
199 | 208 | | |
200 | 209 | | |
201 | | - | |
| 210 | + | |
202 | 211 | | |
203 | 212 | | |
204 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
317 | | - | |
318 | | - | |
319 | 317 | | |
320 | 318 | | |
321 | 319 | | |
| |||
0 commit comments