From: Sasha Levin Date: Wed, 18 Mar 2020 19:27:18 +0000 (-0400) Subject: Fixes for 4.9 X-Git-Tag: v4.4.217~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=18109dd29e6cbe624d53a7fc310b1e603d628461;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.9 Signed-off-by: Sasha Levin --- diff --git a/queue-4.9/perf-amd-uncore-replace-manual-sampling-check-with-c.patch b/queue-4.9/perf-amd-uncore-replace-manual-sampling-check-with-c.patch new file mode 100644 index 00000000000..d75006712dd --- /dev/null +++ b/queue-4.9/perf-amd-uncore-replace-manual-sampling-check-with-c.patch @@ -0,0 +1,88 @@ +From d398f780361c3379742a3e5a0f580e08cc6a9e18 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 11 Mar 2020 14:13:21 -0500 +Subject: perf/amd/uncore: Replace manual sampling check with CAP_NO_INTERRUPT + flag + +From: Kim Phillips + +[ Upstream commit f967140dfb7442e2db0868b03b961f9c59418a1b ] + +Enable the sampling check in kernel/events/core.c::perf_event_open(), +which returns the more appropriate -EOPNOTSUPP. + +BEFORE: + + $ sudo perf record -a -e instructions,l3_request_g1.caching_l3_cache_accesses true + Error: + The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (l3_request_g1.caching_l3_cache_accesses). + /bin/dmesg | grep -i perf may provide additional information. + +With nothing relevant in dmesg. + +AFTER: + + $ sudo perf record -a -e instructions,l3_request_g1.caching_l3_cache_accesses true + Error: + l3_request_g1.caching_l3_cache_accesses: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat' + +Fixes: c43ca5091a37 ("perf/x86/amd: Add support for AMD NB and L2I "uncore" counters") +Signed-off-by: Kim Phillips +Signed-off-by: Borislav Petkov +Acked-by: Peter Zijlstra +Cc: stable@vger.kernel.org +Link: https://lkml.kernel.org/r/20200311191323.13124-1-kim.phillips@amd.com +Signed-off-by: Sasha Levin +--- + arch/x86/events/amd/uncore.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c +index c16c99bc2a109..6bfb9a68134c1 100644 +--- a/arch/x86/events/amd/uncore.c ++++ b/arch/x86/events/amd/uncore.c +@@ -185,20 +185,18 @@ static int amd_uncore_event_init(struct perf_event *event) + + /* + * NB and Last level cache counters (MSRs) are shared across all cores +- * that share the same NB / Last level cache. Interrupts can be directed +- * to a single target core, however, event counts generated by processes +- * running on other cores cannot be masked out. So we do not support +- * sampling and per-thread events. ++ * that share the same NB / Last level cache. On family 16h and below, ++ * Interrupts can be directed to a single target core, however, event ++ * counts generated by processes running on other cores cannot be masked ++ * out. So we do not support sampling and per-thread events via ++ * CAP_NO_INTERRUPT, and we do not enable counter overflow interrupts: + */ +- if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) +- return -EINVAL; + + /* NB and Last level cache 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; + +- /* and we do not enable counter overflow interrupts */ + hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB; + hwc->idx = -1; + +@@ -275,6 +273,7 @@ static struct pmu amd_nb_pmu = { + .start = amd_uncore_start, + .stop = amd_uncore_stop, + .read = amd_uncore_read, ++ .capabilities = PERF_PMU_CAP_NO_INTERRUPT, + }; + + static struct pmu amd_llc_pmu = { +@@ -287,6 +286,7 @@ static struct pmu amd_llc_pmu = { + .start = amd_uncore_start, + .stop = amd_uncore_stop, + .read = amd_uncore_read, ++ .capabilities = PERF_PMU_CAP_NO_INTERRUPT, + }; + + static struct amd_uncore *amd_uncore_alloc(unsigned int cpu) +-- +2.20.1 + diff --git a/queue-4.9/series b/queue-4.9/series index 5b9a248e010..5778eefdf5d 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -75,3 +75,4 @@ batman-adv-don-t-schedule-ogm-for-disabled-interface.patch batman-adv-update-data-pointers-after-skb_cow.patch batman-adv-avoid-probe-elp-information-leak.patch batman-adv-use-explicit-tvlv-padding-for-elp-packets.patch +perf-amd-uncore-replace-manual-sampling-check-with-c.patch