Re: [PATCH v3 5/5] arm64: Enable perf events based hard lockup detector

From: Petr Mladek
Date: Thu Apr 28 2022 - 04:27:48 EST


On Wed 2022-04-27 00:38:40, Lecopzer Chen wrote:
> > What about just introducing the API that will allow to try to
> > initialize the hardlockup detector later:
> >
> > /*
> > * Retry hardlockup detector init. It is useful when it requires some
> > * functionality that has to be initialized later on a particular
> > * platform.
> > */
> > void __init retry_lockup_detector_init(void)
> > {
> > /* Must be called before late init calls. */
> > if (!allow_lockup_detector_init_retry)
> > return 0;
> >
> > queue_work_on(__smp_processor_id(), system_wq, &detector_work);
> > }
> >
> > /*
> > * Ensure that optional delayed hardlockup init is proceed before
> > * the init code and memory is freed.
> > */
> > static int __init lockup_detector_check(void)
> > {
> > /* Prevent any later retry. */
> > allow_lockup_detector_init_retry = false;
> >
> > /* Make sure no work is pending. */
> > flush_work(&detector_work);
> > }
> > late_initcall_sync(lockup_detector_check);
> >
> > You could leave lockup_detector_init() as it is. It does not really
> > matter what was the exact error value returned by watchdog_nmi_probe().
> >
> > Then you could call retry_lockup_detector_init() in
> > armv8_pmu_driver_init() and be done with it.
> >
> > It will be universal API that might be used on any architecture
> > for any reason. If nobody calls retry_lockup_detector_init()
> > then nohing will happen and the code will work as before.
> >
> > It might make sense to provide the API only on architectures that
> > really need it. We could hide it under
> >
> > ARCH_NEED_DELAYED_HARDLOCKUP_DETECTOR_INIT
> >
> > , similar to ARCH_NEEDS_CPU_IDLE_COUPLE.
> >
>
> During implementation, if I add ARCH_NEED_DELAYED_..., there will contain
> many enclosed ifdef-endif and is a little bit ugly.
> Also, I didn't find a must-have reason to this Kconfig after I rebase from
> your suggestion.
>
> The one calls retry_lockup_detector_init() must fail at lockup_detector_init,
> so I think anyone who has aleady failed at lockup_detector_init() has right
> to retry no matter HW, SW or Arch reason.
> Thus I might not introduce a new Kconfig in v4, and I would be glad to see
> if any further commet on this.

Sounds reasonable from my POV. There is not much code. It will be removed
after the init phase. It will be most likely removed even during
compilation when linked with gcc LTE optimization and the symbols
are not used.

Best Regards,
Petr

PS: It might take few days until I do the review of v4. I am a bit
overloaded at the moment.