On Mon, Oct 14, 2024 at 11:40:21AM -0400, Liang, Kan wrote: > > > On 2024-10-14 7:56 a.m., Peter Zijlstra wrote: > > On Thu, Aug 01, 2024 at 04:58:23AM +0000, Mingwei Zhang wrote: > > > >> @@ -5941,8 +5942,21 @@ void perf_put_mediated_pmu(void) > >> } > >> EXPORT_SYMBOL_GPL(perf_put_mediated_pmu); > >> > >> +static void perf_switch_interrupt(bool enter, u32 guest_lvtpc) > >> +{ > >> + /* Mediated passthrough PMU should have PASSTHROUGH_VPMU cap. */ > >> + if (!passthru_pmu) > >> + return; > >> + > >> + if (passthru_pmu->switch_interrupt && > >> + try_module_get(passthru_pmu->module)) { > >> + passthru_pmu->switch_interrupt(enter, guest_lvtpc); > >> + module_put(passthru_pmu->module); > >> + } > >> +} > > > > Should we move the whole module reference to perf_pmu_(,un}register() ? > > A PMU module can be load/unload anytime. How should we know if the PMU > module is available when the reference check is moved to > perf_pmu_(,un}register()? Feh, dunno. I never really use modules. I just think the above is naf -- doubly so because you're saying the SRCU smp_mb() are expensive; but this module reference crap is more expensive than that. (IOW, the SRCU smp_mb() cannot have been the problem)