linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: alankao@andestech.com (Alan Kao)
To: linux-riscv@lists.infradead.org
Subject: [PATCH 1/2] perf: riscv: preliminary RISC-V support
Date: Mon, 9 Apr 2018 15:07:11 +0800	[thread overview]
Message-ID: <20180409070710.GA3844@andestech.com> (raw)
In-Reply-To: <mhng-c22f4be6-e89e-42b6-a776-bf4e035c10d4@palmer-si-x1c4>

On Thu, Apr 05, 2018 at 09:47:50AM -0700, Palmer Dabbelt wrote:
> On Mon, 26 Mar 2018 00:57:54 PDT (-0700), alankao at andestech.com wrote:
> >This patch provide a basic PMU, riscv_base_pmu, which supports two
> >general hardware event, instructions and cycles.  Furthermore, this
> >PMU serves as a reference implementation to ease the portings in
> >the future.
> >
> >riscv_base_pmu should be able to run on any RISC-V machine that
> >conforms to the Priv-Spec.  Note that the latest qemu model hasn't
> >fully support a proper behavior of Priv-Spec 1.10 yet, but work
> >around should be easy with very small fixes.  Please check
> >https://github.com/riscv/riscv-qemu/pull/115 for future updates.
> >
> >Cc: Nick Hu <nickhu@andestech.com>
> >Cc: Greentime Hu <greentime@andestech.com>
> >Signed-off-by: Alan Kao <alankao@andestech.com>
> 
> We should really be able to detect PMU types at runtime (via a device tree
> entry) rather than requiring that a single PMU is built in to the kernel.
> This will require a handful of modifications to how this patch works, which
> I'll try to list below.

> >+menu "PMU type"
> >+	depends on PERF_EVENTS
> >+
> >+config RISCV_BASE_PMU
> >+	bool "Base Performance Monitoring Unit"
> >+	def_bool y
> >+	help
> >+	  A base PMU that serves as a reference implementation and has limited
> >+	  feature of perf.
> >+
> >+endmenu
> >+
> 
> Rather than a menu where a single PMU can be selected, there should be
> options to enable or disable support for each PMU type -- this is just like
> how all our other drivers work.
> 

I see.  Sure.  The descriptions and implementation will be refined in v3.

> >+struct pmu * __weak __init riscv_init_platform_pmu(void)
> >+{
> >+	riscv_pmu = &riscv_base_pmu;
> >+	return riscv_pmu->pmu;
> >+}
> 
> Rather than relying on a weak symbol that gets overridden by other PMU
> types, this should look through the device tree for a compatible PMU (in the
> case of just the base PMU it could be any RISC-V hart) and install a PMU
> handler for it.  There'd probably be some sort of priority scheme here, like
> there are for other driver subsystems, where we'd pick the best PMU driver
> that's compatible with the PMUs on every hart.
> 
> >+
> >+int __init init_hw_perf_events(void)
> >+{
> >+	struct pmu *pmu = riscv_init_platform_pmu();
> >+
> >+	perf_irq = NULL;
> >+	perf_pmu_register(pmu, "cpu", PERF_TYPE_RAW);
> >+	return 0;
> >+}
> >+arch_initcall(init_hw_perf_events);
> 
> Since we only have a single PMU type right now this isn't critical to handle
> right away, but we will have to refactor this before adding another PMU.

I see.  My rough plan is to do the device tree parsing here, and if no specific
PMU string is found then just register the base PMU proposed in this patch.
How about this idea?

Thanks.

  reply	other threads:[~2018-04-09  7:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-26  7:57 [PATCH 0/2] perf: riscv: Preliminary Perf Event Support on RISC-V Alan Kao
2018-03-26  7:57 ` [PATCH 1/2] perf: riscv: preliminary RISC-V support Alan Kao
     [not found]   ` <CAJ2AOiNQuMJoPZPxy2CDFD0vnxk8E+N-8xiir2nPYKjWJKxshQ@mail.gmail.com>
2018-03-29  2:30     ` Alan Kao
2018-03-31 22:47       ` Alex Solomatnikov
2018-04-02  7:36         ` Alan Kao
2018-04-02  8:18           ` Alan Kao
2018-04-05 16:47   ` Palmer Dabbelt
2018-04-09  7:07     ` Alan Kao [this message]
2018-04-09 21:03       ` Palmer Dabbelt
2018-04-10 18:15       ` Alex Solomatnikov
2018-03-26  7:57 ` [PATCH 2/2] perf: riscv: Add Document for Future Porting Guide Alan Kao
     [not found] <CAJ2AOiNQiTpJ9cBCb_fXVCyVNj9U-Xk3tUG=9toAC7HpQTRQvA@mail.gmail.com>
2018-03-29  0:41 ` [PATCH 1/2] perf: riscv: preliminary RISC-V support 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=20180409070710.GA3844@andestech.com \
    --to=alankao@andestech.com \
    --cc=linux-riscv@lists.infradead.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 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).