All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Kao <alankao@andestech.com>
To: Palmer Dabbelt <palmer@sifive.com>, <laanwj@gmail.com>
Cc: linux-riscv@lists.infradead.org, nickhu@andestech.com
Subject: Re: Perf counters on SiFive FU540-C000
Date: Wed, 3 Apr 2019 09:04:26 +0800	[thread overview]
Message-ID: <20190403010426.GA4033@andestech.com> (raw)
In-Reply-To: <mhng-0cd5a4db-2499-4830-a4bf-656275714836@palmer-si-x1c4>

Hi,

On Tue, Apr 02, 2019 at 10:57:14AM -0700, Palmer Dabbelt wrote:
> On Sun, 31 Mar 2019 07:37:32 PDT (-0700), laanwj@gmail.com wrote:
> >Hello,
> >
> >I'm planning on doing some optimization work for RISC-V, so I'd like to add
> >perf support for the performance counters on the FU540-C000—as described in
> >Section 4.10 of the "SiFive FU540-C000 Manual".
> 
> That would be great, thanks!
> 
> >These are very basic: CSRs mhpmevent3 and mhpmevent4 can be used to choose a category
> >(Instruction Commit Events, Microarchitectural Events, Memory System Events), then
> >from these categories a bitmask of events can be set that will increase the associated
> >counter when they happen. I don't understand the rationale for counting multiple
> >kinds of events in one register, so from what I understand, two counters can be
> >supported at once in the perf interface.
> 
> The idea here is to allow users to have different performance counter
> granularities.  For example, users might want to count all pipeline flushes
> (maybe their framework defines that as a possible counter type) or may want
> to specifically indicate which sort of pipeline flush should be counted.
> 
> >I found some documentation about platform specfic counters in Documentation/riscv/pmu.txt,
> >hopefully this is enough to get me started.
> >(If someone started work on this, please let me know)
> 
> Someone from Andes had patches out to add support for their performance
> counters a while ago.  The issue there was that the performance counter
> implementation was chosen at compile time, but it should really be detected
> at run time via some platform-specific mechanism (ie, device tree).

PMU detection was one of the problems, and should have been solved in previous
patches.  For the rest of the problems, Documentation/riscv/pmu.txt should
serve as a good guide.

> Aside from that I think the only issue was how to expose these to userspace
> in a sane fashion, which is something I thought would be quite tricky.  IIRC
> someone managed to convince me that there was a really simple scheme for
> doing this, but I don't remember what it was.

The corresponding userspace tool is in tools/perf.  Once one finishes the kernel
part, the work left for userspace perf will be the symbolization of PMU raw
events.  The preliminary patch supports common counters only, so I believe this
will be the first platform-specific PMU in RISC-V.

Alan

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

  reply	other threads:[~2019-04-03  1:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-31 14:37 Perf counters on SiFive FU540-C000 Wladimir J. van der Laan
2019-04-02 17:57 ` Palmer Dabbelt
2019-04-03  1:04   ` Alan Kao [this message]
2019-04-03  8:42     ` Wladimir J. van der Laan
2019-04-03  9:27       ` Alan Kao
2019-04-03  9:58         ` Wladimir J. van der Laan
2019-04-03 22:15       ` Palmer Dabbelt

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=20190403010426.GA4033@andestech.com \
    --to=alankao@andestech.com \
    --cc=laanwj@gmail.com \
    --cc=linux-riscv@lists.infradead.org \
    --cc=nickhu@andestech.com \
    --cc=palmer@sifive.com \
    /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.