Commit 05b1014
KVM: Add hugepage support for dedicated guest memory
NOTE: upstream guest_memfd does not currently support 2MB pages, so the
support added here is disabled by default. Use the
kvm.gmem_2m_enabled=1 module parameter to switch it on.
TODO: Allow hugepages for kvm_gmem_populate() (carefully to avoid
EEXISTS errors when misaligned)
Extended guest_memfd to allow backing guest memory with hugepages. This
is done as a best-effort by default until a better-defined mechanism is
put in place that can provide better control/assurances to userspace
about hugepage allocations.
When reporting the max order when KVM gets a pfn from guest_memfd, force
order-0 pages if the hugepage is not fully contained by the memslot
binding, e.g. if userspace requested hugepages but punches a hole in the
memslot bindings in order to emulate x86's VGA hole.
Link: https://lore.kernel.org/kvm/[email protected]/T/#mccbd3e8bf9897f0ddbf864e6318d6f2f208b269c
Signed-off-by: Sean Christopherson <[email protected]>
Message-Id: <[email protected]>
[Allow even with CONFIG_TRANSPARENT_HUGEPAGE; dropped momentarily due to
uneasiness about the API. - Paolo]
Signed-off-by: Paolo Bonzini <[email protected]>
[mdr: based on discussion in the Link regarding original patch, make the
following set of changes:
- For now, don't introduce an opt-in flag to enable hugepage
support. By default, just make a best-effort for PMD_ORDER
allocations so that there are no false assurances to userspace
that they'll get hugepages. Performance-wise, it's better at
least than the current guarantee that they will get 4K pages
every time. A more proper opt-in interface can then improve on
things later.
- Pass GFP_NOWARN to alloc_pages() so failures are not disruptive
to normal operations
- Drop size checks during creation time. Instead just avoid huge
allocations if they extend beyond end of the memfd.
- Drop hugepage-related unit tests since everything is now handled
transparently to userspace anyway.
- Update commit message accordingly.]
Signed-off-by: Michael Roth <[email protected]>1 parent 66b8df6 commit 05b1014
3 files changed
+73
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2200 | 2200 | | |
2201 | 2201 | | |
2202 | 2202 | | |
| 2203 | + | |
| 2204 | + | |
2203 | 2205 | | |
2204 | 2206 | | |
2205 | 2207 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
| 53 | + | |
53 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
54 | 60 | | |
55 | 61 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
60 | 102 | | |
61 | 103 | | |
62 | 104 | | |
| |||
420 | 462 | | |
421 | 463 | | |
422 | 464 | | |
| 465 | + | |
423 | 466 | | |
424 | 467 | | |
425 | 468 | | |
| |||
545 | 588 | | |
546 | 589 | | |
547 | 590 | | |
548 | | - | |
549 | 591 | | |
| 592 | + | |
550 | 593 | | |
551 | 594 | | |
552 | 595 | | |
| |||
557 | 600 | | |
558 | 601 | | |
559 | 602 | | |
| 603 | + | |
560 | 604 | | |
561 | 605 | | |
562 | 606 | | |
| |||
574 | 618 | | |
575 | 619 | | |
576 | 620 | | |
577 | | - | |
578 | | - | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
579 | 627 | | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
580 | 639 | | |
581 | 640 | | |
582 | 641 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
99 | 103 | | |
100 | 104 | | |
101 | 105 | | |
| |||
0 commit comments