Message ID | 20220815230110.2266741-2-dmatlack@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: x86/mmu: Always enable the TDP MMU when TDP is enabled | expand |
On 8/16/22 01:01, David Matlack wrote: > Delete the module parameter tdp_mmu and force KVM to always use the TDP > MMU when TDP hardware support is enabled. > > The TDP MMU was introduced in 5.10 and has been enabled by default since > 5.15. At this point there are no known functionality gaps between the > TDP MMU and the shadow MMU, and the TDP MMU uses less memory and scales > better with the number of vCPUs. In other words, there is no good reason > to disable the TDP MMU. > > Dropping the ability to disable the TDP MMU reduces the number of > possible configurations that need to be tested to validate KVM (i.e. no > need to test with tdp_mmu=N), and simplifies the code. The snag is that the shadow MMU is only supported on 64-bit systems; testing tdp_mmu=0 is not a full replacement for booting up a 32-bit distro, but it's easier (I do 32-bit testing only with nested virt). Personally I'd have no problem restricting KVM to x86-64 but I know people would complain. What about making the tdp_mmu module parameter read-only, so that at least kvm->arch.tdp_mmu_enabled can be replaced by a global variable? Paolo
On Wed, Aug 17, 2022 at 3:05 AM Paolo Bonzini <pbonzini@redhat.com> wrote: > > On 8/16/22 01:01, David Matlack wrote: > > Delete the module parameter tdp_mmu and force KVM to always use the TDP > > MMU when TDP hardware support is enabled. > > > > The TDP MMU was introduced in 5.10 and has been enabled by default since > > 5.15. At this point there are no known functionality gaps between the > > TDP MMU and the shadow MMU, and the TDP MMU uses less memory and scales > > better with the number of vCPUs. In other words, there is no good reason > > to disable the TDP MMU. > > > > Dropping the ability to disable the TDP MMU reduces the number of > > possible configurations that need to be tested to validate KVM (i.e. no > > need to test with tdp_mmu=N), and simplifies the code. > > The snag is that the shadow MMU is only supported on 64-bit systems; > testing tdp_mmu=0 is not a full replacement for booting up a 32-bit > distro, but it's easier (I do 32-bit testing only with nested virt). Ah, I did forget about 32-bit systems :(. Do Intel or AMD CPUs support TDP in 32-bit mode? > Personally I'd have no problem restricting KVM to x86-64 but I know > people would complain. As a middle-ground we could stop supporting TDP on 32-bit systems. 32-bit KVM would continue working but just with shadow paging. > > What about making the tdp_mmu module parameter read-only, so that at > least kvm->arch.tdp_mmu_enabled can be replaced by a global variable? > > Paolo >
On 8/17/22 18:49, David Matlack wrote: > On Wed, Aug 17, 2022 at 3:05 AM Paolo Bonzini <pbonzini@redhat.com> wrote: >> >> On 8/16/22 01:01, David Matlack wrote: >>> Delete the module parameter tdp_mmu and force KVM to always use the TDP >>> MMU when TDP hardware support is enabled. >>> >>> The TDP MMU was introduced in 5.10 and has been enabled by default since >>> 5.15. At this point there are no known functionality gaps between the >>> TDP MMU and the shadow MMU, and the TDP MMU uses less memory and scales >>> better with the number of vCPUs. In other words, there is no good reason >>> to disable the TDP MMU. >>> >>> Dropping the ability to disable the TDP MMU reduces the number of >>> possible configurations that need to be tested to validate KVM (i.e. no >>> need to test with tdp_mmu=N), and simplifies the code. >> >> The snag is that the shadow MMU is only supported on 64-bit systems; >> testing tdp_mmu=0 is not a full replacement for booting up a 32-bit >> distro, but it's easier (I do 32-bit testing only with nested virt). > > Ah, I did forget about 32-bit systems :(. Do Intel or AMD CPUs support > TDP in 32-bit mode? Both do. Intel theoretically on some 32-bit processors that were actually sold, too. >> Personally I'd have no problem restricting KVM to x86-64 but I know >> people would complain. > > As a middle-ground we could stop supporting TDP on 32-bit > systems. 32-bit KVM would continue working but just with shadow > paging. The main problem is, shadow paging is awfully slow due to Meltdown mitigations these days. I would start with the read-only parameter and then see whether there's more low-hanging fruit (e.g. make fast page fault TDP MMU-only). Paolo >> What about making the tdp_mmu module parameter read-only, so that at >> least kvm->arch.tdp_mmu_enabled can be replaced by a global variable? >> >> Paolo >> >
On Wed, Aug 17, 2022 at 9:53 AM Paolo Bonzini <pbonzini@redhat.com> wrote: > > On 8/17/22 18:49, David Matlack wrote: > > On Wed, Aug 17, 2022 at 3:05 AM Paolo Bonzini <pbonzini@redhat.com> wrote: > >> > >> On 8/16/22 01:01, David Matlack wrote: > >>> Delete the module parameter tdp_mmu and force KVM to always use the TDP > >>> MMU when TDP hardware support is enabled. > >>> > >>> The TDP MMU was introduced in 5.10 and has been enabled by default since > >>> 5.15. At this point there are no known functionality gaps between the > >>> TDP MMU and the shadow MMU, and the TDP MMU uses less memory and scales > >>> better with the number of vCPUs. In other words, there is no good reason > >>> to disable the TDP MMU. > >>> > >>> Dropping the ability to disable the TDP MMU reduces the number of > >>> possible configurations that need to be tested to validate KVM (i.e. no > >>> need to test with tdp_mmu=N), and simplifies the code. > >> > >> The snag is that the shadow MMU is only supported on 64-bit systems; > >> testing tdp_mmu=0 is not a full replacement for booting up a 32-bit > >> distro, but it's easier (I do 32-bit testing only with nested virt). > > > > Ah, I did forget about 32-bit systems :(. Do Intel or AMD CPUs support > > TDP in 32-bit mode? > > Both do. Intel theoretically on some 32-bit processors that were > actually sold, too. > > >> Personally I'd have no problem restricting KVM to x86-64 but I know > >> people would complain. > > > > As a middle-ground we could stop supporting TDP on 32-bit > > systems. 32-bit KVM would continue working but just with shadow > > paging. > > The main problem is, shadow paging is awfully slow due to Meltdown > mitigations these days. I would start with the read-only parameter and > then see whether there's more low-hanging fruit (e.g. make fast page > fault TDP MMU-only). Will do, thanks for the feedback. > > Paolo > > >> What about making the tdp_mmu module parameter read-only, so that at > >> least kvm->arch.tdp_mmu_enabled can be replaced by a global variable? > >> > >> Paolo > >> > > >
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index f7561cd494cb..e75d45a42b01 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2418,7 +2418,8 @@ the KVM_CLEAR_DIRTY ioctl, and only for the pages being cleared. - Eager page splitting is only supported when kvm.tdp_mmu=Y. + Eager page splitting is only supported when TDP hardware + support is enabled. Default is Y (on). diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c index bf2ccf9debca..d6c30a648d8d 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -10,15 +10,12 @@ #include <asm/cmpxchg.h> #include <trace/events/kvm.h> -static bool __read_mostly tdp_mmu_enabled = true; -module_param_named(tdp_mmu, tdp_mmu_enabled, bool, 0644); - /* Initializes the TDP MMU for the VM, if enabled. */ int kvm_mmu_init_tdp_mmu(struct kvm *kvm) { struct workqueue_struct *wq; - if (!tdp_enabled || !READ_ONCE(tdp_mmu_enabled)) + if (!tdp_enabled) return 0; wq = alloc_workqueue("kvm", WQ_UNBOUND|WQ_MEM_RECLAIM|WQ_CPU_INTENSIVE, 0);
Delete the module parameter tdp_mmu and force KVM to always use the TDP MMU when TDP hardware support is enabled. The TDP MMU was introduced in 5.10 and has been enabled by default since 5.15. At this point there are no known functionality gaps between the TDP MMU and the shadow MMU, and the TDP MMU uses less memory and scales better with the number of vCPUs. In other words, there is no good reason to disable the TDP MMU. Dropping the ability to disable the TDP MMU reduces the number of possible configurations that need to be tested to validate KVM (i.e. no need to test with tdp_mmu=N), and simplifies the code. Signed-off-by: David Matlack <dmatlack@google.com> --- Documentation/admin-guide/kernel-parameters.txt | 3 ++- arch/x86/kvm/mmu/tdp_mmu.c | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) base-commit: 93472b79715378a2386598d6632c654a2223267b prerequisite-patch-id: 8c230105c8a2f1245dedb5b386327d98865d0bb2 prerequisite-patch-id: 9b4329037e2e880db19f3221e47d956b78acadc8 prerequisite-patch-id: 2e3661ba8856c29b769499bac525b6943d9284b8