Skip to content

hung_task: Provide runtime reset interface for hung task detector

Aaron Tomlin lkml 9 versions – Applied

Status from this message: [merged mm-nonmm-stable] hung_task-increment-the-global-counter-immediately.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v9 Latest3 patches 0 repliesApplied 3/3
  2. v83 patches 6 repliesSuperseded
  3. v72 patches 10 repliesSuperseded
Earlier versions · 6
VersionPostedPatchesRepliesStatus
v62 patches9 repliesSuperseded
v52 patches19 repliesSuperseded
v42 patches2 repliesSuperseded
v32 patches14 repliesSuperseded
v22 patches4 repliesSuperseded
v12 patches8 repliesSuperseded

Patches in v9 All 3 applied

#Subject and filesSizeRepliesApplied
1/3hung_task: Refactor detection logic and atomicise detection countkernel/hung_task.c+33 -250 repliesApplied
2/3hung_task: Enable runtime reset of hung_task_detect_countDocumentation/admin-guide/sysctl/kernel.rst kernel/hung_task.c+53 -80 repliesApplied
3/3hung_task: Increment the global counter immediatelykernel/hung_task.c+8 -150 repliesApplied

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchMasami Hiramatsu (Google)Petr MladekJoel GranadosAaron TomlinLance Yang
1/3R-b R-b
2/3R-b R-b R-b
3/3R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v9 thread

Cover letter [PATCH v9 0/3] hung_task: Provide runtime reset interface for hung task detector

Hi Lance, Greg, Petr, Joel, Masami, Andrew,

This series introduces the ability to reset /proc/sys/kernel/hung_task_detect_count.

Writing a "0" value to this file atomically resets the counter of detected hung tasks. This functionality provides system administrators with the means to clear the cumulative diagnostic history following incident resolution, thereby simplifying subsequent monitoring without necessitating a system restart.

Please let me know your thoughts.

Changes since v8 [1]:
- Added Reviewed-by: tag from Petr Mladek, Joel Granados and Lance Yang

Changes since v7 [2]:
- Immediately update the global counter as soon as a hung task is detected (Petr Mladek)
- Added Reviewed-by: tag from Masami Hiramatsu and Aaron Tomlin

Changes since v6 [3]:
- Decoupled the detection logic from the reporting logic. check_hung_task() was renamed to hung_task_info() and the task_is_hung() check was hoisted into the primary check_hung_uninterruptible_tasks() loop (Petr Mladek)

- Changed the global statistic update mechanism from incremental atomic increments (per task) to a single batched atomic_long_cmpxchg_relaxed() at the end of the scan (Petr Mladek)

- Strengthened the memory ordering using atomic_long_read_acquire() and atomic_long_cmpxchg_release(). This ensures strict synchronisation between the scan and concurrent userspace resets (Petr Mladek)

- Updated the inline reporting comment to remove the hardcoded "2 minutes" reference

Changes since v5 [4]:
- Introduced a preparatory patch (Joel Granados)
- Extended custom proc_handler to handle SYSCTL_USER_TO_KERN writes, strictly validating that only a value of "0" is permitted for resets (Joel Granados)
- Transitioned from atomic_long_inc_return_relaxed() to a more robust read_acquire/cmpxchg_release pattern to ensure "All-or-Nothing" scan updates (Petr Mladek)
- Re-introduce hung_task_diagnostics(). For better readability and consistent metadata publication

Changes since v4 [5]:
- Added missing underflow check (Lance Yang)

Changes since v3 [6]:
- Use atomic operations to ensure cross-CPU visibility and prevent an integer underflow
- Use acquire/release semantics for memory ordering (Petr Mladek)
- Move quoted string to a single line (Petr Mladek)
- Remove variables coredump_msg and disable_msg to simplify code (Petr Mladek)
- Add trailing "\n" to all strings to ensure immediate console flushing (Petr Mladek)
- Improve the hung task counter documentation (Joel Granados)
- Reject non-zero writes with -EINVAL (Joel Granados)
- Translate to the new sysctl API (Petr Mladek)

Changes since v2 [7]:
- Avoided a needless double update to hung_task_detect_count (Lance Yang)
- Restored previous use of pr_err() for each message (Greg KH)
- Provided a complete descriptive comment for the helper

Changes since v1 [8]:
- Removed write-only sysfs attribute (Lance Yang)
- Modified procfs hung_task_detect_count instead (Lance Yang)
- Introduced a custom proc_handler
- Updated documentation (Lance Yang)
- Added 'static inline' as a hint to eliminate any function call overhead
- Removed clutter through encapsulation

[1]: https://lore.kernel.org/lkml/[email protected]/
[2]: https://lore.kernel.org/lkml/[email protected]/
[3]: https://lore.kernel.org/lkml/[email protected]/
[4]: https://lore.kernel.org/lkml/[email protected]/
[5]: https://lore.kernel.org/lkml/[email protected]/
[6]: https://lore.kernel.org/all/[email protected]/
[7]: https://lore.kernel.org/lkml/[email protected]/
[8]: https://lore.kernel.org/lkml/[email protected]/

Aaron Tomlin (2):
hung_task: Refactor detection logic and atomicise detection count
hung_task: Enable runtime reset of hung_task_detect_count

Petr Mladek (1):
hung_task: Increment the global counter immediately

 Documentation/admin-guide/sysctl/kernel.rst |   3 +-
 kernel/hung_task.c                          | 101 ++++++++++++++------
 2 files changed, 75 insertions(+), 29 deletions(-)
Signature · 1 line
2.51.0