Re: [PATCH 3/5] kernel/watchdog: adapt the watchdog_hld interface for async model

From: Peter Zijlstra
Date: Wed Sep 15 2021 - 10:04:52 EST


On Wed, Sep 15, 2021 at 11:51:01AM +0800, Pingfan Liu wrote:
> When lockup_detector_init()->watchdog_nmi_probe(), PMU may be not ready
> yet. E.g. on arm64, PMU is not ready until
> device_initcall(armv8_pmu_driver_init). And it is deeply integrated
> with the driver model and cpuhp. Hence it is hard to push this
> initialization before smp_init().
>
> But it is easy to take an opposite approach by enabling watchdog_hld to
> get the capability of PMU async.
>
> The async model is achieved by introducing an extra parameter notifier
> of watchdog_nmi_probe().
>
> Note after this patch, the async model, which is utilized by the next
> patch, does not take effect yet.

I can't make any sense of what you're trying to do..

> +static void watchdog_nmi_report_capability(struct watchdog_nmi_status *data)
> +{
> + /* Set status to 1 temporary to block any further access */
> + if (atomic_cmpxchg((atomic_t *)&nmi_watchdog_status, -EBUSY, 1)
> + == -EBUSY) {

But this..

> + if (!data->status) {
> + nmi_watchdog_status = 0;
> + lockup_detector_update_enable();
> + } else {
> + nmi_watchdog_status = -ENODEV;
> + /* turn offf watchdog_enabled forever */
> + lockup_detector_update_enable();
> + pr_info("Perf NMI watchdog permanently disabled\n");
> + }
> + }
> +}

> @@ -467,7 +494,8 @@ static void watchdog_enable(unsigned int cpu)
> /* Initialize timestamp */
> update_touch_ts();
> /* Enable the perf event */
> - if (watchdog_enabled & NMI_WATCHDOG_ENABLED)
> + if (watchdog_enabled &
> + (NMI_WATCHDOG_ENABLED | NMI_WATCHDOG_UNDETERMINED))

and this, are horrible indenting.