From: Joerg Roedel <joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
To: suravee.suthikulpanit-5C7GfCeVMHo@public.gmane.org
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
a.p.zijlstra-/NLkJaSkS4VmR6Xm/wNWPw@public.gmane.org
Subject: Re: [PATCH 2/2 V3] perf/x86/amd: AMD IOMMU PC PERF uncore PMU implementation
Date: Tue, 28 May 2013 14:18:50 +0200 [thread overview]
Message-ID: <20130528121850.GC2575@8bytes.org> (raw)
In-Reply-To: <1368819813-6481-3-git-send-email-suravee.suthikulpanit-5C7GfCeVMHo@public.gmane.org>
On Fri, May 17, 2013 at 02:43:32PM -0500, Suthikulpanit, Suravee wrote:
> diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
> index b0684e4..fcbd3b8 100644
> --- a/arch/x86/kernel/cpu/Makefile
> +++ b/arch/x86/kernel/cpu/Makefile
> @@ -30,7 +30,7 @@ obj-$(CONFIG_CPU_SUP_UMC_32) += umc.o
> obj-$(CONFIG_PERF_EVENTS) += perf_event.o
>
> ifdef CONFIG_PERF_EVENTS
> -obj-$(CONFIG_CPU_SUP_AMD) += perf_event_amd.o perf_event_amd_uncore.o
> +obj-$(CONFIG_CPU_SUP_AMD) += perf_event_amd.o perf_event_amd_uncore.o perf_event_amd_iommu.o
This should also depend on CONFIG_AMD_IOMMU. If no IOMMU driver is
compiled in it doesn't make sense to have that PMU.
> +static int perf_iommu_event_init(struct perf_event *event)
> +{
> + struct hw_perf_event *hwc = &event->hw;
> + struct perf_amd_iommu *perf_iommu;
> + u64 config, config1;
> +
> + /* test the event attr type check for PMU enumeration */
> + if (event->attr.type != event->pmu->type)
> + return -ENOENT;
> +
> + /*
> + * IOMMU counters are shared across all cores.
> + * Therefore, it does not support per-process mode.
> + * Also, it does not support event sampling mode.
> + */
> + if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK)
> + return -EINVAL;
> +
> + /* IOMMU counters do not have usr/os/guest/host bits */
> + if (event->attr.exclude_user || event->attr.exclude_kernel ||
> + event->attr.exclude_host || event->attr.exclude_guest)
> + return -EINVAL;
> +
> + if (event->cpu < 0)
> + return -EINVAL;
> +
> + perf_iommu = &__perf_iommu;
> +
> + if (event->pmu != &perf_iommu->pmu)
> + return -ENOENT;
> +
> + if (perf_iommu) {
> + config = event->attr.config;
> + config1 = event->attr.config1;
> + } else {
> + return -EINVAL;
> + }
> +
> + /* 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;
> +}
That implementation is very basic. Any reason for not using the event
reporting mechanism of the IOMMU? You could implement a nice perf
iommutop or something to see which devices do the most transactions or
something like that.
Joerg
next prev parent reply other threads:[~2013-05-28 12:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-17 19:43 [PATCH 0/2 V3] perf/x86/amd: IOMMU Performance Counter Support suravee.suthikulpanit-5C7GfCeVMHo
[not found] ` <1368819813-6481-1-git-send-email-suravee.suthikulpanit-5C7GfCeVMHo@public.gmane.org>
2013-05-17 19:43 ` [PATCH 1/2 V3] perf/x86/amd: Adding IOMMU PC resource management suravee.suthikulpanit-5C7GfCeVMHo
[not found] ` <1368819813-6481-2-git-send-email-suravee.suthikulpanit-5C7GfCeVMHo@public.gmane.org>
2013-05-28 11:07 ` Joerg Roedel
[not found] ` <20130528110752.GB2575-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2013-05-28 16:28 ` Suravee Suthikulanit
2013-05-17 19:43 ` [PATCH 2/2 V3] perf/x86/amd: AMD IOMMU PC PERF uncore PMU implementation suravee.suthikulpanit-5C7GfCeVMHo
[not found] ` <1368819813-6481-3-git-send-email-suravee.suthikulpanit-5C7GfCeVMHo@public.gmane.org>
2013-05-28 12:18 ` Joerg Roedel [this message]
[not found] ` <20130528121850.GC2575-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2013-05-28 17:17 ` Suravee Suthikulanit
[not found] ` <51A4E6A8.7080004-5C7GfCeVMHo@public.gmane.org>
2013-05-29 11:24 ` Peter Zijlstra
2013-05-20 15:41 ` [PATCH 0/2 V3] perf/x86/amd: IOMMU Performance Counter Support Suravee Suthikulanit
2013-05-21 9:11 ` Peter Zijlstra
[not found] ` <20130521091157.GD26912-ndre7Fmf5hadTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2013-05-21 13:29 ` Suravee Suthikulanit
[not found] ` <519B76CB.1000208-5C7GfCeVMHo@public.gmane.org>
2013-05-21 13:52 ` Peter Zijlstra
[not found] ` <20130521135231.GK26912-ndre7Fmf5hadTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2013-05-21 14:25 ` Joerg Roedel
[not found] ` <20130521142523.GD7424-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2013-05-21 15:36 ` Peter Zijlstra
2013-05-27 16:30 ` Peter Zijlstra
[not found] ` <20130527163023.GA19373-ndre7Fmf5hadTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2013-05-27 17:26 ` Joerg Roedel
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=20130528121850.GC2575@8bytes.org \
--to=joro-zlv9swrftaidnm+yrofe0a@public.gmane.org \
--cc=a.p.zijlstra-/NLkJaSkS4VmR6Xm/wNWPw@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=suravee.suthikulpanit-5C7GfCeVMHo@public.gmane.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).