Re: [v7 PATCH 1/2] hung_task: Refactor detection logic and atomicise detection count
From: Petr Mladek
Date: Mon Feb 02 2026 - 07:59:27 EST
On Sun 2026-01-25 08:58:47, Aaron Tomlin wrote:
> The check_hung_task() function currently conflates two distinct
> responsibilities: validating whether a task is hung and handling the
> subsequent reporting (printing warnings, triggering panics, or
> tracepoints).
>
> This patch refactors the logic by introducing hung_task_info(), a
> function dedicated solely to reporting. The actual detection check,
> task_is_hung(), is hoisted into the primary loop within
> check_hung_uninterruptible_tasks(). This separation clearly decouples
> the mechanism of detection from the policy of reporting.
>
> Furthermore, to facilitate future support for concurrent hung task
> detection, the global sysctl_hung_task_detect_count variable is
> converted from unsigned long to atomic_long_t. Consequently, the
> counting logic is updated to accumulate the number of hung tasks locally
> (this_round_count) during the iteration. The global counter is then
> updated atomically via atomic_long_cmpxchg_relaxed() once the loop
> concludes, rather than incrementally during the scan.
>
> These changes are strictly preparatory and introduce no functional
> change to the system's runtime behaviour.
>
> Signed-off-by: Aaron Tomlin <atomlin@xxxxxxxxxxx>
LGTM. Feel free to use:
Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>
Best Regards,
Petr