mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: steven.kinney@amd.com
Cc: linux-kernel@vger.kernel.org, mingo@redhat.com,
	iommu@lists.linux-foundation.org, joro@8bytes.org,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Subject: Re: [PATCH 2/2] IOMMU/AMD: IOMMU PC PERF uncore PMU implementation
Date: Tue, 14 May 2013 09:14:24 +0200	[thread overview]
Message-ID: <20130514071424.GB15942@dyad.programming.kicks-ass.net> (raw)
In-Reply-To: <1368481453-5657-1-git-send-email-steven.kinney@amd.com>

On Mon, May 13, 2013 at 04:44:13PM -0500, steven.kinney@amd.com wrote:
> From: Steven L Kinney <Steven.Kinney@amd.com>
> 
> Implement a perf PMU to handle IOMMU PC perf events.  This PMU will handle
> static counter perf events relative to the AMD IOMMU Performance Counters.
> 
> To invoke the AMD IOMMU PMU issue a perf tool command such as:
> 
> ./perf stat -e amd_iommu/config=<config-data>,config1=<config1-data>/u <command>
> 
> For example:
> 
> ./perf stat -e amd_iommu/config=0x8000000000000005,config1=0/u <command>
> 
> The resulting count will be how many IOMMU total peripheral memory
> operations were performed during the command execution window.
> 
> Signed-off-by: Steven Kinney <steven.kinney@amd.com>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> ---

> +PMU_FORMAT_ATTR(iommu_raw, "config:63");

> +static int perf_iommu_init(struct perf_event *event)
> +{
> +	struct hw_perf_event *hwc = &event->hw;
> +	struct perf_iommu *perf_iommu;
> +	u64 config, config1;
> +
> +	/* initialize the cntr_assign_mask */
> +	cntr_assign_mask = 0;
> +
> +	/* test the event attr type check for PMU enumeration */
> +	if (event->attr.type != event->pmu->type)
> +		return -ENOENT;
> +
> +	perf_iommu = &perf_iommu_fetch;
> +
> +	if (perf_iommu) {
> +		config = event->attr.config;
> +		config1 = event->attr.config1;
> +	} else
> +		return -EINVAL;
> +
> +	if (event->pmu != &perf_iommu->pmu)
> +		return -ENOENT;
> +
> +	/* make sure the event->attr.config is raw (vendor specific) */
> +	if (!(config & IOMMU_PC_RAW_CONFIG_MASK))
> +		return -EINVAL;

Is this really needed? Non of the uncore PMU drivers have a magic config bit
either. Seems weird to me.

> +	/* integrate with iommu base devid (0000), assume one iommu */
> +	perf_iommu->max_banks =
> +		amd_iommu_pc_get_max_banks(IOMMU_BASE_DEVID);
> +	perf_iommu->max_counters =
> +		amd_iommu_pc_get_max_counters(IOMMU_BASE_DEVID);
> +
> +	/* update the hw_perf_event struct with the iommu config data */
> +	hwc->config = config;
> +	hwc->extra_reg.config = config1;
> +
> +	return 0;
> +}

Also it might make sense to add a few event aliases to both this IOMMU and the
AMD uncore driver.

Search for uncore_.*_events in arch/x86/kernel/cpu/perf_event_intel_uncore.c
for examples.

This way you can also make the IOMMU a tad more useful by providing some events
you think are the most useful for people interested in this thing.

      reply	other threads:[~2013-05-14  7:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-13 21:44 steven.kinney
2013-05-14  7:14 ` Peter Zijlstra [this message]

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=20130514071424.GB15942@dyad.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=steven.kinney@amd.com \
    --cc=suravee.suthikulpanit@amd.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

all inboxes | Powered by JetHome®