linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC  0/9] KVM perf support
@ 2022-07-18 17:01 Atish Patra
  2022-07-18 17:01 ` [RFC 1/9] RISC-V: Define a helper function to probe number of hardware counters Atish Patra
                   ` (8 more replies)
  0 siblings, 9 replies; 46+ messages in thread
From: Atish Patra @ 2022-07-18 17:01 UTC (permalink / raw)
  To: linux-kernel
  Cc: Atish Patra, Albert Ou, Anup Patel, Atish Patra, Guo Ren,
	kvm-riscv, kvm, linux-riscv, Mark Rutland, Palmer Dabbelt,
	Paul Walmsley, Will Deacon

This series extends perf support for KVM. The KVM implementation relies
on the SBI PMU extension and trap n emulation of hpmcounter CSRs.
The KVM implementation exposes the virtual counters to the guest and internally
manage the counters using kernel perf counters. 

This series doesn't support the counter overflow as the Sscofpmf extension
doesn't allow trap & emulation mechanism of scountovf CSR yet. The required
changes to allow that are being under discussions. Supporting overflow interrupt
also requires AIA support which is not frozen either.

This series can be found at github[1] as well. It depends Anup's CSR emulation
framework[1] series.

perf stat works in kvm guests with this series. 

Here is example of running perf stat in a guest running in KVM.
===========================================================================
/ # /host/apps/perf stat -e instructions -e cycles -e r8000000000000005 \
> -e r8000000000000006 -e r8000000000000007 -e r8000000000000008 \
> -e r800000000000000a perf bench sched messaging -g 5 -l 15
# Running 'sched/messaging' benchmark:
# 20 sender and receiver processes per group
# 5 groups == 200 processes run

     Total time: 5.210 [sec] 

 Performance counter stats for 'perf bench sched messaging -g 5 -l 15':

       37209585734      instructions              #    1.00  insn per cycle
       37177435570      cycles 
              2740      r8000000000000005
              3727      r8000000000000006
              3655      r8000000000000007
                10      r8000000000000008
                 0      r800000000000000a

       5.863014800 seconds time elapsed

       0.569373000 seconds user
      10.771533000 seconds sys 

[1] https://github.com/atishp04/linux/tree/kvm_perf_rfc
[2] https://lkml.org/lkml/2022/6/15/389

Atish Patra (9):
RISC-V: Define a helper function to probe number of hardware counters
RISC-V: Define a helper function to return counter width
RISC-V: KVM: Define a probe function for SBI extension data structures
RISC-V: KVM: Improve privilege mode filtering for perf
RISC-V: KVM: Add skeleton support for perf
RISC-V: KVM: Add SBI PMU extension support
RISC-V: KVM: Implement trap & emulate for hpmcounters
RISC-V: KVM: Implement perf support
RISC-V: KVM: Implement firmware events

arch/riscv/include/asm/kvm_host.h     |   3 +
arch/riscv/include/asm/kvm_vcpu_pmu.h | 102 +++++
arch/riscv/include/asm/kvm_vcpu_sbi.h |   3 +
arch/riscv/include/asm/sbi.h          |   2 +-
arch/riscv/kvm/Makefile               |   1 +
arch/riscv/kvm/main.c                 |   3 +-
arch/riscv/kvm/tlb.c                  |   6 +-
arch/riscv/kvm/vcpu.c                 |   5 +
arch/riscv/kvm/vcpu_insn.c            |   4 +-
arch/riscv/kvm/vcpu_pmu.c             | 517 ++++++++++++++++++++++++++
arch/riscv/kvm/vcpu_sbi.c             |  11 +
arch/riscv/kvm/vcpu_sbi_base.c        |  13 +-
arch/riscv/kvm/vcpu_sbi_pmu.c         |  81 ++++
arch/riscv/kvm/vcpu_sbi_replace.c     |   7 +
drivers/perf/riscv_pmu_sbi.c          |  75 +++-
include/linux/perf/riscv_pmu.h        |   7 +
16 files changed, 823 insertions(+), 17 deletions(-)
create mode 100644 arch/riscv/include/asm/kvm_vcpu_pmu.h
create mode 100644 arch/riscv/kvm/vcpu_pmu.c
create mode 100644 arch/riscv/kvm/vcpu_sbi_pmu.c

--
2.25.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2022-12-08  1:11 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-18 17:01 [RFC 0/9] KVM perf support Atish Patra
2022-07-18 17:01 ` [RFC 1/9] RISC-V: Define a helper function to probe number of hardware counters Atish Patra
2022-11-01 12:30   ` Andrew Jones
2022-11-21 23:50     ` Atish Patra
2022-07-18 17:01 ` [RFC 2/9] RISC-V: Define a helper function to return counter width Atish Patra
2022-07-18 17:01 ` [RFC 3/9] RISC-V: KVM: Define a probe function for SBI extension data structures Atish Patra
2022-11-01 15:32   ` Andrew Jones
2022-07-18 17:02 ` [RFC 4/9] RISC-V: KVM: Improve privilege mode filtering for perf Atish Patra
2022-11-01 12:51   ` Andrew Jones
2022-11-09 13:42   ` Sergey Matyukevich
2022-11-22  0:21     ` Atish Patra
2022-07-18 17:02 ` [RFC 5/9] RISC-V: KVM: Add skeleton support " Atish Patra
2022-11-01 14:13   ` Andrew Jones
2022-11-23  0:46     ` Atish Patra
2022-11-23  1:34       ` Atish Patra
2022-11-23 13:36         ` Andrew Jones
2022-11-24  9:04           ` Atish Patra
2022-11-24 10:55             ` Andrew Jones
2022-11-23 13:11       ` Andrew Jones
2022-11-24  9:09         ` Atish Patra
2022-11-24 11:14           ` Andrew Jones
2022-07-18 17:02 ` [RFC 6/9] RISC-V: KVM: Add SBI PMU extension support Atish Patra
2022-11-01 14:26   ` Andrew Jones
2022-11-22 23:08     ` Atish Patra
2022-11-23 13:58       ` Andrew Jones
2022-11-24 10:18         ` Atish Patra
2022-11-24 10:50           ` Andrew Jones
2022-11-24 12:59             ` Anup Patel
2022-11-28 21:00               ` Atish Patra
2022-07-18 17:02 ` [RFC 7/9] RISC-V: KVM: Implement trap & emulate for hpmcounters Atish Patra
2022-11-01 14:35   ` Andrew Jones
2022-11-22 23:11     ` Atish Patra
2022-07-18 17:02 ` [RFC 8/9] RISC-V: KVM: Implement perf support Atish Patra
2022-09-20  2:24   ` Eric Lin
2022-09-23 21:04     ` Atish Patra
2022-11-01 15:31   ` Andrew Jones
2022-11-23  0:45     ` Atish Patra
2022-11-23 14:22       ` Andrew Jones
2022-12-02  9:08         ` Atish Patra
2022-12-02 11:37           ` Andrew Jones
2022-12-07  8:49             ` Atish Patra
2022-12-02 17:09   ` Sean Christopherson
2022-12-07  8:06     ` Atish Patra
2022-12-07 16:31       ` Sean Christopherson
2022-12-08  1:11         ` Atish Patra
2022-07-18 17:02 ` [RFC 9/9] RISC-V: KVM: Implement firmware events Atish Patra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).