linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Ellerman <michael@ellerman.id.au>
To: Runzhen Wang <runzhen@linux.vnet.ibm.com>
Cc: icycoder@gmail.com, linux-kernel@vger.kernel.org,
	xiaoguangrong@linux.vnet.ibm.com, acme@redhat.com,
	paulus@samba.org, sukadev@linux.vnet.ibm.com,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 2/2] perf tools: Make Power7 events available for perf
Date: Thu, 20 Jun 2013 11:41:29 +1000	[thread overview]
Message-ID: <1371692489.21846.14.camel@concordia> (raw)
In-Reply-To: <1371633326-7696-2-git-send-email-runzhen@linux.vnet.ibm.com>

On Wed, 2013-06-19 at 17:15 +0800, Runzhen Wang wrote:
> Power7 supports over 530 different perf events but only a small
> subset of these can be specified by name, for the remaining
> events, we must specify them by their raw code:
> 
>         perf stat -e r2003c <application>
> 
> This patch makes all the POWER7 events available in sysfs.
> So we can instead specify these as:
> 
>         perf stat -e 'cpu/PM_CMPLU_STALL_DFU/' <application>
> 
> where PM_CMPLU_STALL_DFU is the r2003c in previous example.
> 
> Before this patch is applied, the size of power7-pmu.o is:
> 
> $ size arch/powerpc/perf/power7-pmu.o
>    text	   data	    bss	    dec	    hex	filename
>    3073	   2720	      0	   5793	   16a1	arch/powerpc/perf/power7-pmu.o
> 
> and after the patch is applied, it is:
> 
> $ size arch/powerpc/perf/power7-pmu.o
>    text	   data	    bss	    dec	    hex	filename
>   14451	  31112	      0	  45563	   b1fb	arch/powerpc/perf/power7-pmu.o

OK so that's ~38K. Which is not terrible.

Can you measure the runtime overhead as well. I suspect it will be more.


You'll notice below that each event name is repeated four times, which
for 530 events is a bit ugly.

I think we should be able to do something better using the C
preprocessor, this is exactly the sort of thing it's good at.

What I mean is something like we do with arch/powerpc/include/asm/systbl.h,
where we define the list of syscalls once, and then include it in
multiple places, using different macro definitions to get different
outputs.

So perhaps you'd define the list of events like:

#define EVENT(PM_CMPLU_STALL_FXU, 0x20014)
#define EVENT(PM_CMPLU_STALL_DIV, 0x40014)

etc.

Then you do something approximately like:

#define EVENT(_name, _code)	POWER_EVENT_ATTR(_name, _code)
#include "event-list.h"
#undef EVENT

#define EVENT(_name, _code)	POWER_EVENT_PTR(_name)

static struct attribute *power7_events_attr[] = {
#include "event-list.h"
};


You will obviously need to rework the POWER_EVENT macros to make that
work, but it should be possible.

The end result will be we have a single list of the events which we can
check for accuracy once. And we can be sure that there are no mixups
between events.


> diff --git a/arch/powerpc/perf/power7-pmu.c b/arch/powerpc/perf/power7-pmu.c
> index d1821b8..55e2404 100644
> --- a/arch/powerpc/perf/power7-pmu.c
> +++ b/arch/powerpc/perf/power7-pmu.c
> @@ -53,37 +53,544 @@
>  /*
>   * Power7 event codes.
>   */

...

> +#define PME_PM_MRK_DERAT_MISS_64K                 0x2d05c
> +#define PME_PM_INST_PTEG_FROM_DL2L3_MOD           0x4e054
> +#define PME_PM_L2_ST_MISS                         0x26082
> +#define PME_PM_MRK_PTEG_FROM_L21_SHR              0x4d056
> +#undef  LWSYNC
    ^
What is this doing here?

That is not your macro to undefine. Please be more careful.

> +#define PME_PM_LWSYNC                             0xd094



cheers

  parent reply	other threads:[~2013-06-20  1:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-19  9:15 [PATCH 1/2] perf tools: fix a typo of a Power7 event name Runzhen Wang
2013-06-19  9:15 ` [PATCH 2/2] perf tools: Make Power7 events available for perf Runzhen Wang
2013-06-19 16:14   ` Sukadev Bhattiprolu
2013-06-20  1:41   ` Michael Ellerman [this message]
2013-06-20 10:57     ` David Laight
2013-06-19 16:13 ` [PATCH 1/2] perf tools: fix a typo of a Power7 event name Sukadev Bhattiprolu
2013-06-20  1:21 ` Michael Ellerman
2013-06-20  2:28   ` Sukadev Bhattiprolu

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=1371692489.21846.14.camel@concordia \
    --to=michael@ellerman.id.au \
    --cc=acme@redhat.com \
    --cc=icycoder@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    --cc=runzhen@linux.vnet.ibm.com \
    --cc=sukadev@linux.vnet.ibm.com \
    --cc=xiaoguangrong@linux.vnet.ibm.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 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).