qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 00/10] Allow platform specific PMU event encoding
@ 2024-10-09 23:08 Atish Patra
  2024-10-09 23:08 ` [PATCH RFC 01/10] target/riscv: Fix the hpmevent mask Atish Patra
                   ` (10 more replies)
  0 siblings, 11 replies; 24+ messages in thread
From: Atish Patra @ 2024-10-09 23:08 UTC (permalink / raw)
  To: qemu-riscv, qemu-devel
  Cc: alexei.filippov, Atish Patra, palmer, liwei1518, zhiwei_liu,
	bin.meng, dbarboza, alistair.francis

Currently, the pmu implementation is virt machine specific that
implements the SBI PMU encodings. In the future, individual machines
would want to implement their own custom event encodings as there
is no standard event encoding defined by the ISA. There is a performance
events TG which is working on defining standard set of events but not
encodings. That allows flexibility for platforms to choose whatever
encoding scheme they want. However, that means the generic pmu code
should be flexible enough to allow that in Qemu as well.

This series aims to solve that problem by first disassociating the
common pmu implementation and event encoding. The event encoding is
specific to a platform and should be defined in the platform specific
machine or cpu implementation. The newly defined callbacks can be invoked
from machine specific cpu implementation or machine code itself depending
on the requirement.

The first 5 patches in the series are generic improvements and cleanups
where as the last 5 actually implements the disassociation for the virt
machine. The current series can also be found at[2].

I recently found that Alexei has done a similar effort for SiFive FU740[1]
but the implementation differs from this one based on how the cpu callbacks
are invoked. For example, Alexei's series implements a single callback for
all the events and has defined machine specific counter read/write callbacks.
However, it just defaults to get_ticks() for every event. IMO, that is
confusing to the users unless we can actually emulate more generic events or
machine specific events.

I have separate callbacks for each type of events that we currently support
in Qemu (cycle, instruction, TLB events). Separate callbacks seems a better
approach to avoid ambiguity as we have very limited event capability in qemu.
I am open to converging them to one callback as well if we think we will
be extending set of events in the future.

Once we converge on the approaches, we can consolidate the patches
so that both SiFive FU740 and virt machine can use the same abstraction.

Cc: alexei.filippov@syntacore.com

[1] https://lore.kernel.org/all/20240910174747.148141-1-alexei.filippov@syntacore.com/T/
[2] https://github.com/atishp04/qemu/tree/b4/pmu_event_machine

Signed-off-by: Atish Patra <atishp@rivosinc.com>
---
Atish Patra (10):
      target/riscv: Fix the hpmevent mask
      target/riscv: Introduce helper functions for pmu hashtable lookup
      target/riscv: Protect the hashtable modifications with a lock
      target/riscv: Use uint64 instead of uint as key
      target/riscv: Rename the PMU events
      target/riscv: Define PMU event related structures
      hw/riscv/virt.c : Disassociate virt PMU events
      target/riscv: Update event mapping hashtable for invalid events
      target/riscv : Use the new tlb fill event functions
      hw/riscv/virt.c: Generate the PMU node from the machine

 hw/riscv/virt.c           | 102 +++++++++++++++++++++++-
 target/riscv/cpu.h        |  52 ++++++++++--
 target/riscv/cpu_bits.h   |   4 +-
 target/riscv/cpu_helper.c |  21 ++---
 target/riscv/pmu.c        | 198 +++++++++++++++++++++-------------------------
 target/riscv/pmu.h        |   3 +-
 6 files changed, 246 insertions(+), 134 deletions(-)
---
base-commit: 19a9809808a51291008f72d051d0f9b3499fc223
change-id: 20241008-pmu_event_machine-b87c58104e61
--
Regards,
Atish patra



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

end of thread, other threads:[~2024-11-22 17:37 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-09 23:08 [PATCH RFC 00/10] Allow platform specific PMU event encoding Atish Patra
2024-10-09 23:08 ` [PATCH RFC 01/10] target/riscv: Fix the hpmevent mask Atish Patra
2024-10-09 23:09 ` [PATCH RFC 02/10] target/riscv: Introduce helper functions for pmu hashtable lookup Atish Patra
2024-10-10 12:04   ` Alexei Filippov
2024-10-09 23:09 ` [PATCH RFC 03/10] target/riscv: Protect the hashtable modifications with a lock Atish Patra
2024-10-09 23:09 ` [PATCH RFC 04/10] target/riscv: Use uint64 instead of uint as key Atish Patra
2024-10-09 23:09 ` [PATCH RFC 05/10] target/riscv: Rename the PMU events Atish Patra
2024-10-10 12:10   ` Alexei Filippov
2024-10-11 20:41     ` Atish Kumar Patra
2024-10-09 23:09 ` [PATCH RFC 06/10] target/riscv: Define PMU event related structures Atish Patra
2024-10-10 12:44   ` Alexei Filippov
2024-10-11 20:45     ` Atish Kumar Patra
2024-10-21 13:44       ` Aleksei Filippov
2024-10-22 12:58         ` Atish Kumar Patra
2024-11-20 14:25           ` Aleksei Filippov
2024-11-21 19:54             ` Atish Kumar Patra
2024-11-22 11:43               ` Aleksei Filippov
2024-11-22 17:36                 ` Atish Kumar Patra
2024-10-09 23:09 ` [PATCH RFC 07/10] hw/riscv/virt.c : Disassociate virt PMU events Atish Patra
2024-10-09 23:09 ` [PATCH RFC 08/10] target/riscv: Update event mapping hashtable for invalid events Atish Patra
2024-10-09 23:09 ` [PATCH RFC 09/10] target/riscv : Use the new tlb fill event functions Atish Patra
2024-10-09 23:09 ` [PATCH RFC 10/10] hw/riscv/virt.c: Generate the PMU node from the machine Atish Patra
2024-10-10 12:51 ` [PATCH RFC 00/10] Allow platform specific PMU event encoding Alexei Filippov
2024-10-11 21:07   ` Atish Kumar 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).