[PATCH v2 0/2] target/loongarch: Add PTW feature support in KVM mode

Bibo Mao posted 2 patches 6 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251027024347.3315592-1-maobibo@loongson.cn
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Cornelia Huck <cohuck@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Song Gao <gaosong@loongson.cn>
There is a newer version of this series
include/standard-headers/linux/ethtool.h      |  1 +
include/standard-headers/linux/fuse.h         | 22 ++++++++++--
.../linux/input-event-codes.h                 |  1 +
include/standard-headers/linux/input.h        | 22 +++++++++++-
include/standard-headers/linux/pci_regs.h     | 10 ++++++
include/standard-headers/linux/virtio_ids.h   |  1 +
linux-headers/asm-loongarch/kvm.h             |  1 +
linux-headers/asm-riscv/kvm.h                 | 23 +++++++++++-
linux-headers/asm-riscv/ptrace.h              |  4 +--
linux-headers/asm-x86/kvm.h                   | 34 ++++++++++++++++++
linux-headers/asm-x86/unistd_64.h             |  1 +
linux-headers/asm-x86/unistd_x32.h            |  1 +
linux-headers/linux/kvm.h                     |  3 ++
linux-headers/linux/psp-sev.h                 | 10 +++++-
linux-headers/linux/stddef.h                  |  1 -
linux-headers/linux/vduse.h                   |  2 +-
linux-headers/linux/vhost.h                   |  4 +--
target/loongarch/cpu.c                        |  6 ++--
target/loongarch/cpu.h                        |  1 +
target/loongarch/kvm/kvm.c                    | 35 +++++++++++++++++++
20 files changed, 169 insertions(+), 14 deletions(-)
[PATCH v2 0/2] target/loongarch: Add PTW feature support in KVM mode
Posted by Bibo Mao 6 hours ago
Implement Hardware page table walker(PTW for short) feature in KVM mode.
Use OnOffAuto type variable ptw to check the PTW feature. If the PTW
feature is not supported on KVM host, it reports error if there is ptw=on
option. By default PTW feature is disabled on la464 CPU type, and auto
detected on max CPU type.

With PTW enabled, there is no obvious performance improvement with
generic macro benchmark, and somewhat improvement with micro benchmark
such as test-tlb located at https://github.com/torvalds/test-tlb,
overwall there is no negative effective with PTW enabled.

Here is result about test-tlb with command ./test-tlb 0x40000000 0x8000
             host    VM without HW PTW    VM with HW PTW   improvement
cycles       180         320                 261              20%

And TLB miss rate is about 52% n this scenerary. Performance counter stats
for command './test-tlb 0x40000000 0x8000':
   67,724,819      dTLB-load-misses     #52.24% of all dTLB cache accesses
  129,639,899      dTLB-loads

Bibo Mao (2):
  linux-headers: Update to Linux v6.18-rc3
  target/loongarch: Add PTW feature support in KVM mode

 include/standard-headers/linux/ethtool.h      |  1 +
 include/standard-headers/linux/fuse.h         | 22 ++++++++++--
 .../linux/input-event-codes.h                 |  1 +
 include/standard-headers/linux/input.h        | 22 +++++++++++-
 include/standard-headers/linux/pci_regs.h     | 10 ++++++
 include/standard-headers/linux/virtio_ids.h   |  1 +
 linux-headers/asm-loongarch/kvm.h             |  1 +
 linux-headers/asm-riscv/kvm.h                 | 23 +++++++++++-
 linux-headers/asm-riscv/ptrace.h              |  4 +--
 linux-headers/asm-x86/kvm.h                   | 34 ++++++++++++++++++
 linux-headers/asm-x86/unistd_64.h             |  1 +
 linux-headers/asm-x86/unistd_x32.h            |  1 +
 linux-headers/linux/kvm.h                     |  3 ++
 linux-headers/linux/psp-sev.h                 | 10 +++++-
 linux-headers/linux/stddef.h                  |  1 -
 linux-headers/linux/vduse.h                   |  2 +-
 linux-headers/linux/vhost.h                   |  4 +--
 target/loongarch/cpu.c                        |  6 ++--
 target/loongarch/cpu.h                        |  1 +
 target/loongarch/kvm/kvm.c                    | 35 +++++++++++++++++++
 20 files changed, 169 insertions(+), 14 deletions(-)


base-commit: 36076d24f04ea9dc3357c0fbe7bb14917375819c
-- 
2.39.3
[PATCH v2 0/2] target/loongarch: Add PTW feature support in KVM mode
Posted by Bibo Mao 5 hours ago
Add missing changelog.

Implement Hardware page table walker(PTW for short) feature in KVM mode.
Use OnOffAuto type variable ptw to check the PTW feature. If the PTW
feature is not supported on KVM host, it reports error if there is ptw=on
option. By default PTW feature is disabled on la464 CPU type, and auto
detected on max CPU type.

With PTW enabled, there is no obvious performance improvement with
generic macro benchmark, and somewhat improvement with micro benchmark
such as test-tlb located at https://github.com/torvalds/test-tlb,
overwall there is no negative effective with PTW enabled.

Here is result about test-tlb with command ./test-tlb 0x40000000 0x8000
             host    VM without HW PTW    VM with HW PTW   improvement
cycles       180         320                 261              20%

And TLB miss rate is about 52% n this scenerary. Performance counter stats
for command './test-tlb 0x40000000 0x8000':
   67,724,819      dTLB-load-misses     #52.24% of all dTLB cache accesses
  129,639,899      dTLB-loads

---
v1 ... v2:
  1. Update Linux headers from v6.18-rc2 to v6.18-rc3.
  2. Set PTW feature with ON_OFF_AUTO_AUTO by default with max CPU type
     in KVM mode also.
---
Bibo Mao (2):
  linux-headers: Update to Linux v6.18-rc3
  target/loongarch: Add PTW feature support in KVM mode

 include/standard-headers/linux/ethtool.h      |  1 +
 include/standard-headers/linux/fuse.h         | 22 ++++++++++--
 .../linux/input-event-codes.h                 |  1 +
 include/standard-headers/linux/input.h        | 22 +++++++++++-
 include/standard-headers/linux/pci_regs.h     | 10 ++++++
 include/standard-headers/linux/virtio_ids.h   |  1 +
 linux-headers/asm-loongarch/kvm.h             |  1 +
 linux-headers/asm-riscv/kvm.h                 | 23 +++++++++++-
 linux-headers/asm-riscv/ptrace.h              |  4 +--
 linux-headers/asm-x86/kvm.h                   | 34 ++++++++++++++++++
 linux-headers/asm-x86/unistd_64.h             |  1 +
 linux-headers/asm-x86/unistd_x32.h            |  1 +
 linux-headers/linux/kvm.h                     |  3 ++
 linux-headers/linux/psp-sev.h                 | 10 +++++-
 linux-headers/linux/stddef.h                  |  1 -
 linux-headers/linux/vduse.h                   |  2 +-
 linux-headers/linux/vhost.h                   |  4 +--
 target/loongarch/cpu.c                        |  6 ++--
 target/loongarch/cpu.h                        |  1 +
 target/loongarch/kvm/kvm.c                    | 35 +++++++++++++++++++
 20 files changed, 169 insertions(+), 14 deletions(-)


base-commit: 36076d24f04ea9dc3357c0fbe7bb14917375819c
-- 
2.39.3