Re: [PATCH v8] watchdog/hardlockup: simplify perf event probe and remove per-cpu dependency
From: Doug Anderson
Date: Wed Jan 28 2026 - 12:46:41 EST
Hi,
On Wed, Jan 28, 2026 at 5:29 AM Qiliang Yuan <realwujing@xxxxxxxxx> wrote:
>
> Simplify the hardlockup detector's probe path and remove its implicit
> dependency on pinned per-cpu execution.
>
> Refactor hardlockup_detector_event_create() to be stateless. Return
> the created perf_event pointer to the caller instead of directly
> modifying the per-cpu 'watchdog_ev' variable. This allows the probe
> path to safely manage a temporary event without the risk of leaving
> stale pointers should task migration occur.
>
> Signed-off-by: Shouxin Sun <sunshx@xxxxxxxxxxxxxxx>
> Signed-off-by: Junnan Zhang <zhangjn11@xxxxxxxxxxxxxxx>
> Signed-off-by: Qiliang Yuan <yuanql9@xxxxxxxxxxxxxxx>
> Signed-off-by: Qiliang Yuan <realwujing@xxxxxxxxx>
> Cc: Douglas Anderson <dianders@xxxxxxxxxxxx>
> Cc: Song Liu <song@xxxxxxxxxx>
> Cc: Jinchao Wang <wangjinchao600@xxxxxxxxx>
> ---
> v8:
> - Add Signed-off-by with work email.
> - v7 link: https://lore.kernel.org/all/20260128060833.1715622-1-realwujing@xxxxxxxxx/
> v7:
> - Update Signed-off-by to match author email.
> - Remove redundant cpu_hotplug_disable() in probe path.
> - v6 link: https://lore.kernel.org/all/20260128023136.1691973-1-realwujing@xxxxxxxxx/
> v6:
> - Change title to "simplify/cleanup" and remove "Fixes" tag since the issue
> is not reproducible on mainline.
> - Rewrite commit message in imperative mood.
> - Clarify that mainline is safe while this improves robustness.
> - v5 link: https://lore.kernel.org/all/20260127022238.1182079-1-realwujing@xxxxxxxxx/
> v5:
> - Refine description: clarify that the retry path uses worker threads
> without PF_PERCPU_THREAD (though mainline is safe due to system_percpu_wq).
> - v4 link: https://lore.kernel.org/all/20260124070814.806828-1-realwujing@xxxxxxxxx/
> v4:
> - Add cpu_hotplug_disable() in watchdog_hardlockup_probe() to stabilize
> the probe CPU.
> - Update description to explain the relevance of 4.19 logs.
> v3:
> - Refactor hardlockup_detector_event_create() to be stateless by returning
> the event pointer instead of directly assigning to per-cpu variables.
> - Restore PMU cycle fallback and unify the enable/probe paths.
> v2:
> - Add Cc: stable@xxxxxxxxxxxxxxx.
> v1:
> - Avoid 'watchdog_ev' in probe path by manually creating and releasing a
> local perf event.
>
> kernel/watchdog_perf.c | 51 ++++++++++++++++++++++++------------------
> 1 file changed, 29 insertions(+), 22 deletions(-)
>
> diff --git a/kernel/watchdog_perf.c b/kernel/watchdog_perf.c
> index d3ca70e3c256..4a798443033b 100644
> --- a/kernel/watchdog_perf.c
> +++ b/kernel/watchdog_perf.c
> @@ -17,6 +17,7 @@
> #include <linux/atomic.h>
> #include <linux/module.h>
> #include <linux/sched/debug.h>
> +#include <linux/cpu.h>
IIRC, the above include was added for the call to
cpu_hotplug_disable(), which has now been removed. The #include can be
removed now, right?
In any case:
Reviewed-by: Douglas Anderson <dianders@xxxxxxxxxxxx>