--- zzzz-none-000/linux-3.10.107/arch/x86/kernel/cpu/perf_event_knc.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/arch/x86/kernel/cpu/perf_event_knc.c 2021-02-04 17:41:59.000000000 +0000 @@ -217,7 +217,7 @@ int bit, loops; u64 status; - cpuc = &__get_cpu_var(cpu_hw_events); + cpuc = this_cpu_ptr(&cpu_hw_events); knc_pmu_disable_all(); @@ -263,7 +263,9 @@ goto again; done: - knc_pmu_enable_all(0); + /* Only restore PMU state when it's active. See x86_pmu_disable(). */ + if (cpuc->enabled) + knc_pmu_enable_all(0); return handled; }