Skip to content

RFC KVM: arm64: Optimise FPSIMD context switching

Dave Martin kvmarm linux-arm-kernel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest8 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8KVM: arm/arm64: Introduce kvm_arch_vcpu_run_pid_changearch/arm64/kvm/Kconfig include/linux/kvm_host.h virt/kvm/Kconfig +2 more+29 -10 replies
2/8KVM: arm64: Convert lazy FPSIMD context switch trap to Carch/arm64/kvm/hyp/entry.S arch/arm64/kvm/hyp/switch.c+46 -350 replies
3/8KVM: arm64: Optimise FPSIMD handling to reduce guest/host thrashingarch/arm/include/asm/kvm_host.h arch/arm64/include/asm/fpsimd.h arch/arm64/include/asm/kvm_host.h +5 more+187 -433 replies
4/8arm64/sve: Move read_zcr_features() out of cpufeature.harch/arm64/include/asm/cpufeature.h arch/arm64/include/asm/fpsimd.h arch/arm64/include/asm/processor.h +2 more+32 -291 reply
5/8arm64/sve: Switch sve_pffr() argument from task to threadarch/arm64/kernel/fpsimd.c+5 -51 reply
6/8arm64/sve: Move sve_pffr() to fpsimd.h and make inlinearch/arm64/include/asm/fpsimd.h arch/arm64/include/asm/processor.h arch/arm64/kernel/fpsimd.c+15 -131 reply
7/8KVM: arm64: Save host SVE context as appropriatearch/arm64/Kconfig arch/arm64/kvm/fpsimd.c arch/arm64/kvm/hyp/switch.c +1 more+44 -31 reply
8/8KVM: arm64: Remove eager host SVE state savingarch/arm/include/asm/kvm_host.h arch/arm64/include/asm/kvm_host.h arch/arm64/kernel/fpsimd.c +1 more+0 -371 reply

Reviews trailers per patch

5 of 8 patches have a Reviewed-by or Acked-by.

PatchCatalin MarinasChristoffer Dall
1/8
2/8
3/8
4/8A-b
5/8A-b
6/8A-b
7/8R-b
8/8A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [RFC PATCH 0/8] KVM: arm64: Optimise FPSIMD context switching

This is another respin of my attempt to improve FPSIMD context handling for KVM, building on the previous RFC v3 [1].

It's not completely done yet, but it's sufficiently closer to completeness that a it's worth people taking another look at.

The main changes since RFC v3 are:

* Rebased to v4.17-rc1. Please pay close attention to patch 3 which is where most of the pain was felt. Note that fpsimd_enabled() is now gone, since vcpu->arch.fp_enabled provides the same information. The diff is a little confusing to read there.

* patches 4-6: Make sve_pffr more easliy inlinable into Hyp, along with some annoying header refactoring to resolve a #include cycle that is otherwise hard to avoid here.

* patch 7: Add support for saving the host SVE state from hyp.

* patch 8: Remove SVE host-side SVE flushing logic that is rendered unnecessary by patch 7.

Other minor changes as noted.

Some testing done on Juno and the Arm fast model (arm64), including combinations of (non-)SVE and (non-)VHE configurations.

Blurb:

See the individual patches for detailed explanation.

Some things (still) aren't right yet:

* The BUG_ON(system_supports_sve()) added in kvm_arch_vcpu_load_fp() by patch 3 and subsequently removed by patch 7 is a bisectability break (albeit only for people running on SVE-enabled models). I intend to fix this before upstreaming, possibly via a check at VM creation time similar to the check added in patch 7.

* Moving __hyp_switch_fpsimd() to the shallow exit path as requested by Marc Zyngier has *not* been done yet. I will look at that next so that people can benchmark with and without that change.

* task_fpsimd_save() still appears misnamed, but in lieu of having decided on a better name I've just exported this function from fpsimd.c for now.

Any comments, testing, benchmarks appreciated!

Cheers
---Dave

[1] [RFC PATCH v3 0/4] KVM: arm64: Optimise FPSIMD context switching
http://lists.infradead.org/pipermail/linux-arm-kernel/2018-April/570740.html

Christoffer Dall (1):
KVM: arm/arm64: Introduce kvm_arch_vcpu_run_pid_change

Dave Martin (7):
KVM: arm64: Convert lazy FPSIMD context switch trap to C
KVM: arm64: Optimise FPSIMD handling to reduce guest/host thrashing arm64/sve: Move read_zcr_features() out of cpufeature.h arm64/sve: Switch sve_pffr() argument from task to thread arm64/sve: Move sve_pffr() to fpsimd.h and make inline
KVM: arm64: Save host SVE context as appropriate
KVM: arm64: Remove eager host SVE state saving

 arch/arm/include/asm/kvm_host.h     |   9 ++-
 arch/arm64/Kconfig                  |   7 +++
 arch/arm64/include/asm/cpufeature.h |  29 ----------
 arch/arm64/include/asm/fpsimd.h     |  20 +++++++
 arch/arm64/include/asm/kvm_host.h   |  22 +++++---
 arch/arm64/include/asm/processor.h  |   2 +
 arch/arm64/kernel/fpsimd.c          |  87 ++++++++++++++++-------------
 arch/arm64/kernel/ptrace.c          |   1 +
 arch/arm64/kvm/Kconfig              |   1 +
 arch/arm64/kvm/Makefile             |   2 +-
 arch/arm64/kvm/fpsimd.c             | 108 ++++++++++++++++++++++++++++++++++++
 arch/arm64/kvm/hyp/entry.S          |  57 ++++++++-----------
 arch/arm64/kvm/hyp/switch.c         |  83 +++++++++++++++++++--------
 include/linux/kvm_host.h            |   9 +++
 virt/kvm/Kconfig                    |   3 +
 virt/kvm/arm/arm.c                  |  25 ++++++++-
 virt/kvm/kvm_main.c                 |   7 ++-
 17 files changed, 332 insertions(+), 140 deletions(-)
 create mode 100644 arch/arm64/kvm/fpsimd.c
Signature · 1 line
2.1.4