All of lore.kernel.org
 help / color / mirror / Atom feed
From: Elio Vinciguerra <eliovinciguerra@me.com>
To: ELIO VINCIGUERRA <elio.vinciguerra@phd.unict.it>,
	Atish Patra <atishp@atishpatra.org>
Cc: "qemu-riscv@nongnu.org" <qemu-riscv@nongnu.org>
Subject: Re: About RISCV’s Performance Counters and QEMU
Date: Tue, 5 Dec 2023 13:56:13 +0100	[thread overview]
Message-ID: <61ae4c15-c251-43a6-aa98-b12ea5feb246@Spark> (raw)
In-Reply-To: <CAOnJCUL_kg08aQoNosbTgT64O508kQ58-MtT29fBsD+f8dqyoQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1768 bytes --]

Thanks for your answer, do you know if the working ones return actual or random numbers?

And do you know if it is easily possible to implement the actual behavior of other counters?

Regards,
Elio
Il 4 dic 2023, 9:30 AM +0100, Atish Patra <atishp@atishpatra.org>, ha scritto:
> On Fri, Dec 1, 2023 at 7:57 AM ELIO VINCIGUERRA
> <elio.vinciguerra@phd.unict.it> wrote:
> >
> > Hi everybody, I recently started using RISCV architectures, I would need a way to access “hpmcounter[3-31]” registers using QEMU emulator.
> >
> > The kernel used for simulations is a C program, not a heavy operating system, which is why I would need to access the registers mentioned before via assembly.
> >
> > Trivially accessing any of those registers always returns zero.
> >
> > The question is:
> > Are these registers enabled in QEMU? If not, is it possible to enable them or are they hardwired to zero? How?
> >
> > Trying to access the registers “cycle”, “instret” and “time” the values come out to be non-zero, which is why I think it is also possible to enable “hpmcounter[3-31]”, but the mode of operation is unknown to me, can anyone help me?
> >
>
> Yes. You can use all the hpmcounters[3-31]. By default,
> hpmcounter[3-18] are enabled. You can modify the set of counters using
> pmu-mask cpu property.
> https://gitlab.com/qemu-project/qemu/-/blob/master/target/riscv/cpu.c?ref_type=heads#L1467
>
> However, upstream Qemu doesn't support a lot of PMU events. It only
> supports 3 cache related events apart from cycle/instret.
>
> Here are the events it supports.
> https://gitlab.com/qemu-project/qemu/-/blob/master/target/riscv/pmu.c?ref_type=heads#L36
>
> > Regards,
> > Elio
>
>
>
> --
> Regards,
> Atish

[-- Attachment #2: Type: text/html, Size: 2376 bytes --]

  reply	other threads:[~2023-12-05 14:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-01 14:27 About RISCV’s Performance Counters and QEMU ELIO VINCIGUERRA
2023-12-04  8:30 ` Atish Patra
2023-12-05 12:56   ` Elio Vinciguerra [this message]
2023-12-06  1:21     ` Atish Patra
2023-12-06  5:47       ` ELIO VINCIGUERRA

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=61ae4c15-c251-43a6-aa98-b12ea5feb246@Spark \
    --to=eliovinciguerra@me.com \
    --cc=atishp@atishpatra.org \
    --cc=elio.vinciguerra@phd.unict.it \
    --cc=qemu-riscv@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.