aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/perf
diff options
context:
space:
mode:
authorAndrew Murray <andrew.murray@arm.com>2019-01-10 08:53:30 -0500
committerIngo Molnar <mingo@kernel.org>2019-01-21 05:01:25 -0500
commita66b0010f89e50ca0dd8bb3dc5187cd21e1da891 (patch)
tree6e7af291b8f009d2d440c4f9314eea101f2cf6cb /drivers/perf
parent306563985819ed2af9df0a26ae368ed12cf28f41 (diff)
perf/drivers: Strengthen exclusion checks with PERF_PMU_CAP_NO_EXCLUDE
For drivers that do not support context exclusion let's advertise the PERF_PMU_CAP_NO_EXCLUDE capability. This ensures that perf will prevent us from handling events where any exclusion flags are set. Let's also remove the now unnecessary check for exclusion flags. This change means that qcom_{l2|l3}_pmu will now also indicate that they do not support exclude_{host|guest} and that xgene_pmu does not also support exclude_idle and exclude_hv. Note that for qcom_l2_pmu we now implictly return -EINVAL instead of -EOPNOTSUPP. This change will result in the perf userspace utility retrying the perf_event_open system call with fallback event attributes that do not fail. Signed-off-by: Andrew Murray <andrew.murray@arm.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Will Deacon <will.deacon@arm.com> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Matt Turner <mattst88@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Richard Henderson <rth@twiddle.net> Cc: Russell King <linux@armlinux.org.uk> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Shawn Guo <shawnguo@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-arm-kernel@lists.infradead.org Cc: linuxppc-dev@lists.ozlabs.org Cc: robin.murphy@arm.com Cc: suzuki.poulose@arm.com Link: https://lkml.kernel.org/r/1547128414-50693-9-git-send-email-andrew.murray@arm.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'drivers/perf')
-rw-r--r--drivers/perf/qcom_l2_pmu.c9
-rw-r--r--drivers/perf/qcom_l3_pmu.c8
-rw-r--r--drivers/perf/xgene_pmu.c6
3 files changed, 3 insertions, 20 deletions
diff --git a/drivers/perf/qcom_l2_pmu.c b/drivers/perf/qcom_l2_pmu.c
index 842135cf35a3..091b4d7d32c4 100644
--- a/drivers/perf/qcom_l2_pmu.c
+++ b/drivers/perf/qcom_l2_pmu.c
@@ -509,14 +509,6 @@ static int l2_cache_event_init(struct perf_event *event)
509 return -EOPNOTSUPP; 509 return -EOPNOTSUPP;
510 } 510 }
511 511
512 /* We cannot filter accurately so we just don't allow it. */
513 if (event->attr.exclude_user || event->attr.exclude_kernel ||
514 event->attr.exclude_hv || event->attr.exclude_idle) {
515 dev_dbg_ratelimited(&l2cache_pmu->pdev->dev,
516 "Can't exclude execution levels\n");
517 return -EOPNOTSUPP;
518 }
519
520 if (((L2_EVT_GROUP(event->attr.config) > L2_EVT_GROUP_MAX) || 512 if (((L2_EVT_GROUP(event->attr.config) > L2_EVT_GROUP_MAX) ||
521 ((event->attr.config & ~L2_EVT_MASK) != 0)) && 513 ((event->attr.config & ~L2_EVT_MASK) != 0)) &&
522 (event->attr.config != L2CYCLE_CTR_RAW_CODE)) { 514 (event->attr.config != L2CYCLE_CTR_RAW_CODE)) {
@@ -982,6 +974,7 @@ static int l2_cache_pmu_probe(struct platform_device *pdev)
982 .stop = l2_cache_event_stop, 974 .stop = l2_cache_event_stop,
983 .read = l2_cache_event_read, 975 .read = l2_cache_event_read,
984 .attr_groups = l2_cache_pmu_attr_grps, 976 .attr_groups = l2_cache_pmu_attr_grps,
977 .capabilities = PERF_PMU_CAP_NO_EXCLUDE,
985 }; 978 };
986 979
987 l2cache_pmu->num_counters = get_num_counters(); 980 l2cache_pmu->num_counters = get_num_counters();
diff --git a/drivers/perf/qcom_l3_pmu.c b/drivers/perf/qcom_l3_pmu.c
index 2dc63d61f2ea..5d70646da8c7 100644
--- a/drivers/perf/qcom_l3_pmu.c
+++ b/drivers/perf/qcom_l3_pmu.c
@@ -495,13 +495,6 @@ static int qcom_l3_cache__event_init(struct perf_event *event)
495 return -ENOENT; 495 return -ENOENT;
496 496
497 /* 497 /*
498 * There are no per-counter mode filters in the PMU.
499 */
500 if (event->attr.exclude_user || event->attr.exclude_kernel ||
501 event->attr.exclude_hv || event->attr.exclude_idle)
502 return -EINVAL;
503
504 /*
505 * Sampling not supported since these events are not core-attributable. 498 * Sampling not supported since these events are not core-attributable.
506 */ 499 */
507 if (hwc->sample_period) 500 if (hwc->sample_period)
@@ -777,6 +770,7 @@ static int qcom_l3_cache_pmu_probe(struct platform_device *pdev)
777 .read = qcom_l3_cache__event_read, 770 .read = qcom_l3_cache__event_read,
778 771
779 .attr_groups = qcom_l3_cache_pmu_attr_grps, 772 .attr_groups = qcom_l3_cache_pmu_attr_grps,
773 .capabilities = PERF_PMU_CAP_NO_EXCLUDE,
780 }; 774 };
781 775
782 memrc = platform_get_resource(pdev, IORESOURCE_MEM, 0); 776 memrc = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c
index 0dc9ff0f8894..d4ec04868d59 100644
--- a/drivers/perf/xgene_pmu.c
+++ b/drivers/perf/xgene_pmu.c
@@ -917,11 +917,6 @@ static int xgene_perf_event_init(struct perf_event *event)
917 if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) 917 if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK)
918 return -EINVAL; 918 return -EINVAL;
919 919
920 /* SOC counters do not have usr/os/guest/host bits */
921 if (event->attr.exclude_user || event->attr.exclude_kernel ||
922 event->attr.exclude_host || event->attr.exclude_guest)
923 return -EINVAL;
924
925 if (event->cpu < 0) 920 if (event->cpu < 0)
926 return -EINVAL; 921 return -EINVAL;
927 /* 922 /*
@@ -1136,6 +1131,7 @@ static int xgene_init_perf(struct xgene_pmu_dev *pmu_dev, char *name)
1136 .start = xgene_perf_start, 1131 .start = xgene_perf_start,
1137 .stop = xgene_perf_stop, 1132 .stop = xgene_perf_stop,
1138 .read = xgene_perf_read, 1133 .read = xgene_perf_read,
1134 .capabilities = PERF_PMU_CAP_NO_EXCLUDE,
1139 }; 1135 };
1140 1136
1141 /* Hardware counter init */ 1137 /* Hardware counter init */