Skip to content

Add support for monitoring guest TLB operations

Punit Agrawal kvm kvmarm linux-arm-kernel lkml 5 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest9 patches 0 repliesNew
  2. v39 patches 13 repliesSuperseded
  3. v2 posting 2/28 patches 1 replySuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v2 RFC posting 1/27 patches20 repliesSuperseded
v1 RFC7 patches14 repliesSuperseded

Changes in v4 from the cover letter

* Use vcpupid specified via perf instead of custom VM specifier. This results in simplifying the synchronisation requirements for callbacks
* Dropped change to track VM pid as it's no longer being used
* Moved host pmu to virt/kvm
* Added copyright headers

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9arm64/kvm: hyp: tlb: use __tlbi() helperarch/arm64/kvm/hyp/tlb.c+6 -60 replies
2/9KVM: Add event to trace tlb invalidationsinclude/trace/events/kvm.h+18 -00 replies
3/9arm: KVM: Handle trappable TLB instructionsarch/arm/include/asm/kvm_asm.h arch/arm/include/asm/kvm_host.h arch/arm/kvm/coproc.c +1 more+92 -00 replies
4/9arm64: KVM: Handle trappable TLB instructionsarch/arm64/include/asm/kvm_asm.h arch/arm64/include/asm/kvm_host.h arch/arm64/kvm/hyp/tlb.c +1 more+161 -00 replies
5/9kvm: Add host pmu to support VM introspectioninclude/kvm/host_pmu.h virt/kvm/Kconfig virt/kvm/host_pmu.c+284 -00 replies
6/9KVM: arm/arm64: Add support for tracking guest TLB operationsvirt/kvm/arm/host_pmu_events.c+82 -00 replies
7/9arm64: KVM: Enable support for the host pmuarch/arm64/include/asm/kvm_host.h arch/arm64/kvm/Kconfig arch/arm64/kvm/Makefile+10 -00 replies
8/9arm: KVM: Enable support for host pmuarch/arm/include/asm/kvm_host.h arch/arm/kvm/Kconfig arch/arm/kvm/Makefile+10 -00 replies
9/9arm/arm64: KVM: Initialise the host pmuarch/arm/kvm/arm.c+2 -00 replies

Reviews trailers per patch

1 of 9 patches has a Reviewed-by or Acked-by.

PatchChristoffer Dall
1/9A-b
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9

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

Read the v4 thread

Cover letter [PATCH v4 0/9] Add support for monitoring guest TLB operations

Hi,

This series adds support for a software pmu on the host which can be used to monitor VM operations. For arm and arm64, support is added to monitor guest TLB operations using the host pmu infrastructure.

This posting addresses all feedback on the previous version[0]. Instead of requiring a VM pid as part of the event attribute, it now depends on vcpu thread ids being passed via the standard perf interface (-t). Thread ids instead of process ids (-p) is used as -p when called with the thread id ends up resolving to the parent process.

Prior versions can be found at [1][2][3][4].

As a result of the changes, the user interface has changed as well. With the patchset, TLB operations can be monitored using -

# perf stat -e kvm/tlb_invalidate/ -t 3967,3968
^C
 Performance counter stats for thread id '3967,3968':
                71      kvm/tlb_invalidate/

      10.207587028 seconds time elapsed

where 3967 and 3968 are the thread ids of the vcpus.

Patches based on v4.10-rc6.

Thanks,
Punit

[0] http://www.mail-archive.com/[email protected]/msg09357.html
[1] http://www.mail-archive.com/[email protected]/msg1210715.html
[2] http://www.mail-archive.com/[email protected]/msg1224353.html
[3] https://marc.info/?l=linux-kernel&m=147376184208258&w=2
[4] https://marc.info/?l=kvm&m=147750373716545&w=2

Changes:
v3 -> v4
* Use vcpupid specified via perf instead of custom VM specifier. This results in simplifying the synchronisation requirements for callbacks
* Dropped change to track VM pid as it's no longer being used
* Moved host pmu to virt/kvm
* Added copyright headers

v2 -> v3
* Replaced perf trace monitoring with software PMU
* Re-ordered patches as a result of the above re-write

v1 -> v2
* New (Patch 6) - Add support for trapping and emulating TLB operations to ARM hosts
* Move common code to handle perf trace notifications to virt/kvm/arm
* Move tracepoint to include/trace/events/kvm.h
* Drop patch to introduce __tlbi helper as it is now merged
* Reorder patches

RFC v2 -> v1
* Dropped the RFC tag
* Patch 2 - Use VM thread group id for identification
* Patch 4 - Update comment for clarity
* Patch 6 - Add comment explaining switch to hype-role when VHE is enabled
* Patch 7 - Add comment to clarify struct kvm_trace_hook

RFC -> RFC v2
* Patch 4 - Rename left-over TLBI macro to __TLBI
* Patch 6 - Replace individual TLB operation emulation with invalidating all stage 1 TLB for the VM. TLB monitoring is expected to be a debug feature and performance is not critical.

Mark Rutland (1):
arm64/kvm: hyp: tlb: use __tlbi() helper

Punit Agrawal (8):
KVM: Add event to trace tlb invalidations
arm: KVM: Handle trappable TLB instructions
arm64: KVM: Handle trappable TLB instructions
kvm: Add host pmu to support VM introspection
kvm: host_pmu: Add support for tracking guest TLB operations
arm64: KVM: Enable support for the host pmu
arm: KVM: Enable support for host pmu
arm: KVM: Initialise the host pmu

 arch/arm/include/asm/kvm_asm.h    |   2 +
 arch/arm/include/asm/kvm_host.h   |   9 ++
 arch/arm/kvm/Kconfig              |   1 +
 arch/arm/kvm/Makefile             |   1 +
 arch/arm/kvm/arm.c                |   2 +
 arch/arm/kvm/coproc.c             |  56 +++++++++
 arch/arm/kvm/hyp/tlb.c            |  33 +++++
 arch/arm64/include/asm/kvm_asm.h  |   2 +
 arch/arm64/include/asm/kvm_host.h |   9 ++
 arch/arm64/kvm/Kconfig            |   1 +
 arch/arm64/kvm/Makefile           |   1 +
 arch/arm64/kvm/hyp/tlb.c          |  87 +++++++++++++-
 arch/arm64/kvm/sys_regs.c         |  83 +++++++++++++
 include/kvm/host_pmu.h            |  35 ++++++
 include/trace/events/kvm.h        |  18 +++
 virt/kvm/Kconfig                  |   3 +
 virt/kvm/arm/host_pmu_events.c    |  82 +++++++++++++
 virt/kvm/host_pmu.c               | 246 ++++++++++++++++++++++++++++++++++++++
 18 files changed, 665 insertions(+), 6 deletions(-)
 create mode 100644 include/kvm/host_pmu.h
 create mode 100644 virt/kvm/arm/host_pmu_events.c
 create mode 100644 virt/kvm/host_pmu.c
Signature · 1 line
2.11.0