Skip to content

Backport KVM's nx_huge_pages=never module parameter

Luiz Capitulino stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2KVM: x86/mmu: Use kstrtobool() instead of strtobool()arch/x86/kvm/mmu/mmu.c+2 -11 reply
2/2KVM: x86/mmu: Add "never" option to allow sticky disabling of nx_huge_pagesarch/x86/kvm/mmu/mmu.c+36 -51 reply

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchRobert HooKai HuangLuiz CapitulinoLi RongQingSean Christopherson
1/2A-b
2/2R-b A-b T-b R-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v1 thread

Cover letter [PATH 6.1.y 0/2] Backport KVM's nx_huge_pages=never module parameter

Hi,

As part of the mitigation for the iTLB multihit vulnerability, KVM creates a worker thread in KVM_CREATE_VM ioctl(). This thread calls cgroup_attach_task_all() which takes cgroup_threadgroup_rwsem for writing which may incur 100ms+ latency since upstream commit 6a010a49b63ac8465851a79185d8deff966f8e1a.

However, if the CPU is not vulnerable to iTLB multihit one could just disable the mitigation (and the worker thread creation) with the newly added KVM module parameter nx_huge_pages=never. This avoids the issue altogether.

While there's an alternative solution for this issue already supported in 6.1-stable (ie. cgroup's favordynmods), disabling the mitigation in KVM is probably preferable if the workload is not impacted by dynamic cgroup operations since one doesn't need to decide between the trade-off in using favordynmods, the thread creation code path is avoided at KVM_CREATE_VM and you avoid creating a thread which does nothing.

Tests performed:

* Measured KVM_CREATE_VM latency and confirmed it goes down to less than 1ms
* We've been performing latency measurements internally w/ this parameter for some weeks now

Christophe JAILLET (1):
KVM: x86/mmu: Use kstrtobool() instead of strtobool()

Sean Christopherson (1):
KVM: x86/mmu: Add "never" option to allow sticky disabling of
nx_huge_pages

 arch/x86/kvm/mmu/mmu.c | 42 +++++++++++++++++++++++++++++++++++++-----
 1 file changed, 37 insertions(+), 5 deletions(-)
Signature · 1 line
2.40.1