Commit 4a43efc
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 718de61 commit 4a43efc
3 files changed
+64
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2211 | 2211 | | |
2212 | 2212 | | |
2213 | 2213 | | |
| 2214 | + | |
| 2215 | + | |
2214 | 2216 | | |
2215 | 2217 | | |
2216 | 2218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
90 | 120 | | |
91 | 121 | | |
92 | 122 | | |
| |||
98 | 128 | | |
99 | 129 | | |
100 | 130 | | |
101 | | - | |
102 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
103 | 140 | | |
104 | 141 | | |
105 | 142 | | |
| |||
429 | 466 | | |
430 | 467 | | |
431 | 468 | | |
| 469 | + | |
432 | 470 | | |
433 | 471 | | |
434 | 472 | | |
| |||
556 | 594 | | |
557 | 595 | | |
558 | 596 | | |
559 | | - | |
560 | 597 | | |
| 598 | + | |
561 | 599 | | |
562 | 600 | | |
563 | 601 | | |
| |||
566 | 604 | | |
567 | 605 | | |
568 | 606 | | |
| 607 | + | |
569 | 608 | | |
570 | 609 | | |
571 | 610 | | |
| |||
582 | 621 | | |
583 | 622 | | |
584 | 623 | | |
585 | | - | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
586 | 640 | | |
587 | 641 | | |
588 | 642 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
| |||
0 commit comments