Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/perf: Clear all MMCR settings before calling compute_mmcr()

Because we reuse cpuhw->mmcr on each call to compute_mmcr() there's a
risk that we could forget to set one of the values and use whatever
value was in there previously.

Currently all the implementations are careful to set all the values, but
it's safer to clear them all before we call compute_mmcr().

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Michael Ellerman and committed by
Benjamin Herrenschmidt
79a4cb28 f929a464

+3 -1
+3 -1
arch/powerpc/perf/core-book3s.c
··· 1219 1219 } 1220 1220 1221 1221 /* 1222 - * Compute MMCR* values for the new set of events 1222 + * Clear all MMCR settings and recompute them for the new set of events. 1223 1223 */ 1224 + memset(cpuhw->mmcr, 0, sizeof(cpuhw->mmcr)); 1225 + 1224 1226 if (ppmu->compute_mmcr(cpuhw->events, cpuhw->n_events, hwc_index, 1225 1227 cpuhw->mmcr)) { 1226 1228 /* shouldn't ever get here */