On Wed, Jun 01, 2022 at 05:42:56AM -0400, Paolo Bonzini wrote:
From: Like Xu <likexu@xxxxxxxxxxx>
If the PMU is broken due to firmware issues, check_hw_exists() will return
false but perf_get_x86_pmu_capability() will still return data from x86_pmu.
Likewise if some of the hotplug callbacks cannot be installed the contents
of x86_pmu will not be reverted.
Handle the failure in both cases by clearing x86_pmu if init_hw_perf_events()
or reverts to software events only.
Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
No SoB from Like,
@@ -2982,6 +2985,11 @@ unsigned long perf_misc_flags(struct pt_regs *regs)
void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap)
{
+ if (!x86_pmu.name) {
We have x86_pmu_initialized(), the implementation is a bit daft, but
might as well use it here too, no?