From: jeremy.linton@arm.com (Jeremy Linton)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v7 7/9] arm: arm64: pmu: Assign platform PMU CPU affinity
Date: Tue, 23 Aug 2016 15:47:58 -0500 [thread overview]
Message-ID: <1471985280-2243-8-git-send-email-jeremy.linton@arm.com> (raw)
In-Reply-To: <1471985280-2243-1-git-send-email-jeremy.linton@arm.com>
On systems with multiple PMU types the PMU to CPU affinity
needs to be detected and set. The CPU to interrupt affinity
should also be set.
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
drivers/perf/arm_pmu.c | 53 ++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 43 insertions(+), 10 deletions(-)
diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c
index f1aee26..ee9e301 100644
--- a/drivers/perf/arm_pmu.c
+++ b/drivers/perf/arm_pmu.c
@@ -11,6 +11,7 @@
*/
#define pr_fmt(fmt) "hw perfevents: " fmt
+#include <linux/acpi.h>
#include <linux/bitmap.h>
#include <linux/cpumask.h>
#include <linux/cpu_pm.h>
@@ -24,6 +25,7 @@
#include <linux/irq.h>
#include <linux/irqdesc.h>
+#include <asm/cpu.h>
#include <asm/cputype.h>
#include <asm/irq_regs.h>
@@ -876,25 +878,57 @@ static void cpu_pmu_destroy(struct arm_pmu *cpu_pmu)
}
/*
- * CPU PMU identification and probing.
+ * CPU PMU identification and probing. Its possible to have
+ * multiple CPU types in an ARM machine. Assure that we are
+ * picking the right PMU types based on the CPU in question
*/
-static int probe_current_pmu(struct arm_pmu *pmu,
- const struct pmu_probe_info *info)
+static int probe_plat_pmu(struct arm_pmu *pmu,
+ const struct pmu_probe_info *info,
+ unsigned int pmuid)
{
- int cpu = get_cpu();
- unsigned int cpuid = read_cpuid_id();
int ret = -ENODEV;
+ int cpu;
+ int aff_ctr = 0;
+ static int duplicate_pmus;
+ struct platform_device *pdev = pmu->plat_device;
+ int irq = platform_get_irq(pdev, 0);
+
+ if (irq >= 0 && !irq_is_percpu(irq)) {
+ pmu->irq_affinity = kcalloc(pdev->num_resources, sizeof(int),
+ GFP_KERNEL);
+ if (!pmu->irq_affinity)
+ return -ENOMEM;
+ }
- pr_info("probing PMU on CPU %d\n", cpu);
+ for_each_possible_cpu(cpu) {
+ unsigned int cpuid = read_specific_cpuid(cpu);
+ if (cpuid == pmuid) {
+ cpumask_set_cpu(cpu, &pmu->supported_cpus);
+ if (pmu->irq_affinity) {
+ pmu->irq_affinity[aff_ctr] = cpu;
+ aff_ctr++;
+ }
+ }
+ }
+
+ /* find the type of PMU given the CPU */
for (; info->init != NULL; info++) {
- if ((cpuid & info->mask) != info->cpuid)
+ if ((pmuid & info->mask) != info->cpuid)
continue;
ret = info->init(pmu);
+ if ((!info->cpuid) && (duplicate_pmus)) {
+ pmu->name = kasprintf(GFP_KERNEL, "%s_%d",
+ pmu->name, duplicate_pmus);
+ if (!pmu->name) {
+ kfree(pmu->irq_affinity);
+ ret = -ENOMEM;
+ }
+ }
+ duplicate_pmus++;
break;
}
- put_cpu();
return ret;
}
@@ -1029,8 +1063,7 @@ int arm_pmu_device_probe(struct platform_device *pdev,
if (!ret)
ret = init_fn(pmu);
} else if (probe_table) {
- cpumask_setall(&pmu->supported_cpus);
- ret = probe_current_pmu(pmu, probe_table);
+ ret = probe_plat_pmu(pmu, probe_table, read_cpuid_id());
}
if (ret) {
--
2.5.5
next prev parent reply other threads:[~2016-08-23 20:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-23 20:47 [PATCH v7 0/9] Enable PMUs in ACPI systems Jeremy Linton
2016-08-23 20:47 ` [PATCH v7 1/9] arm64: pmu: add fallback probe table Jeremy Linton
2016-08-26 14:34 ` Punit Agrawal
2016-08-23 20:47 ` [PATCH v7 2/9] arm64: pmu: Probe default hw/cache counters Jeremy Linton
2016-08-23 20:47 ` [PATCH v7 3/9] arm64: pmu: Hoist pmu platform device name Jeremy Linton
2016-08-23 20:47 ` [PATCH v7 4/9] arm64: Rename the common MADT parse routine Jeremy Linton
2016-08-23 20:47 ` [PATCH v7 5/9] arm64: pmu: Add support for probing with ACPI Jeremy Linton
2016-08-26 14:42 ` Punit Agrawal
2016-08-23 20:47 ` [PATCH v7 6/9] arm: arm64: Add routine to determine cpuid of other cpus Jeremy Linton
2016-08-23 20:47 ` Jeremy Linton [this message]
2016-08-26 14:54 ` [PATCH v7 7/9] arm: arm64: pmu: Assign platform PMU CPU affinity Punit Agrawal
2016-08-23 20:47 ` [PATCH v7 8/9] arm64: pmu: Detect and enable multiple PMUs in an ACPI system Jeremy Linton
2016-08-26 15:04 ` Punit Agrawal
2016-08-26 22:44 ` Jeremy Linton
2016-08-30 9:43 ` Punit Agrawal
2016-09-01 14:30 ` Will Deacon
2016-08-23 20:48 ` [PATCH v7 9/9] MAINTAINERS: Tweak ARM PMU maintainers Jeremy Linton
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=1471985280-2243-8-git-send-email-jeremy.linton@arm.com \
--to=jeremy.linton@arm.com \
--cc=linux-arm-kernel@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).