[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdW7Ab13DdGs2acMQcix5ObJK0O2dG_Fxzr8_g58Rc1_0g@mail.gmail.com>
Date: Fri, 22 Aug 2025 09:38:38 +0200
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Lance Yang <ioworker0@...il.com>
Cc: akpm@...ux-foundation.org, will@...nel.org, peterz@...radead.org,
mingo@...hat.com, longman@...hat.com, mhiramat@...nel.org,
anna.schumaker@...cle.com, boqun.feng@...il.com, joel.granados@...nel.org,
kent.overstreet@...ux.dev, leonylgao@...cent.com,
linux-kernel@...r.kernel.org, rostedt@...dmis.org, senozhatsky@...omium.org,
tfiga@...omium.org, amaindex@...look.com, jstultz@...gle.com,
Mingzhe Yang <mingzhe.yang@...com>, Eero Tamminen <oak@...sinkinet.fi>,
linux-m68k <linux-m68k@...ts.linux-m68k.org>
Subject: Re: [PATCH v5 2/3] hung_task: show the blocker task if the task is
hung on semaphore
Hi Lance,
(this time the right email thread, I hope ;-)
On Mon, 14 Apr 2025 at 17:23, Lance Yang <ioworker0@...il.com> wrote:
> Inspired by mutex blocker tracking[1], this patch makes a trade-off to
> balance the overhead and utility of the hung task detector.
>
> Unlike mutexes, semaphores lack explicit ownership tracking, making it
> challenging to identify the root cause of hangs. To address this, we
> introduce a last_holder field to the semaphore structure, which is
> updated when a task successfully calls down() and cleared during up().
>
> The assumption is that if a task is blocked on a semaphore, the holders
> must not have released it. While this does not guarantee that the last
> holder is one of the current blockers, it likely provides a practical hint
> for diagnosing semaphore-related stalls.
>
> With this change, the hung task detector can now show blocker task's info
> like below:
>
> [Tue Apr 8 12:19:07 2025] INFO: task cat:945 blocked for more than 120 seconds.
> [Tue Apr 8 12:19:07 2025] Tainted: G E 6.14.0-rc6+ #1
> [Tue Apr 8 12:19:07 2025] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
> [Tue Apr 8 12:19:07 2025] task:cat state:D stack:0 pid:945 tgid:945 ppid:828 task_flags:0x400000 flags:0x00000000
> [Tue Apr 8 12:19:07 2025] Call Trace:
> [Tue Apr 8 12:19:07 2025] <TASK>
> [Tue Apr 8 12:19:07 2025] __schedule+0x491/0xbd0
> [Tue Apr 8 12:19:07 2025] schedule+0x27/0xf0
> [Tue Apr 8 12:19:07 2025] schedule_timeout+0xe3/0xf0
> [Tue Apr 8 12:19:07 2025] ? __folio_mod_stat+0x2a/0x80
> [Tue Apr 8 12:19:07 2025] ? set_ptes.constprop.0+0x27/0x90
> [Tue Apr 8 12:19:07 2025] __down_common+0x155/0x280
> [Tue Apr 8 12:19:07 2025] down+0x53/0x70
> [Tue Apr 8 12:19:07 2025] read_dummy_semaphore+0x23/0x60
> [Tue Apr 8 12:19:07 2025] full_proxy_read+0x5f/0xa0
> [Tue Apr 8 12:19:07 2025] vfs_read+0xbc/0x350
> [Tue Apr 8 12:19:07 2025] ? __count_memcg_events+0xa5/0x140
> [Tue Apr 8 12:19:07 2025] ? count_memcg_events.constprop.0+0x1a/0x30
> [Tue Apr 8 12:19:07 2025] ? handle_mm_fault+0x180/0x260
> [Tue Apr 8 12:19:07 2025] ksys_read+0x66/0xe0
> [Tue Apr 8 12:19:07 2025] do_syscall_64+0x51/0x120
> [Tue Apr 8 12:19:07 2025] entry_SYSCALL_64_after_hwframe+0x76/0x7e
> [Tue Apr 8 12:19:07 2025] RIP: 0033:0x7f419478f46e
> [Tue Apr 8 12:19:07 2025] RSP: 002b:00007fff1c4d2668 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
> [Tue Apr 8 12:19:07 2025] RAX: ffffffffffffffda RBX: 0000000000020000 RCX: 00007f419478f46e
> [Tue Apr 8 12:19:07 2025] RDX: 0000000000020000 RSI: 00007f4194683000 RDI: 0000000000000003
> [Tue Apr 8 12:19:07 2025] RBP: 00007f4194683000 R08: 00007f4194682010 R09: 0000000000000000
> [Tue Apr 8 12:19:07 2025] R10: fffffffffffffbc5 R11: 0000000000000246 R12: 0000000000000000
> [Tue Apr 8 12:19:07 2025] R13: 0000000000000003 R14: 0000000000020000 R15: 0000000000020000
> [Tue Apr 8 12:19:07 2025] </TASK>
> [Tue Apr 8 12:19:07 2025] INFO: task cat:945 blocked on a semaphore likely last held by task cat:938
> [Tue Apr 8 12:19:07 2025] task:cat state:S stack:0 pid:938 tgid:938 ppid:584 task_flags:0x400000 flags:0x00000000
> [Tue Apr 8 12:19:07 2025] Call Trace:
> [Tue Apr 8 12:19:07 2025] <TASK>
> [Tue Apr 8 12:19:07 2025] __schedule+0x491/0xbd0
> [Tue Apr 8 12:19:07 2025] ? _raw_spin_unlock_irqrestore+0xe/0x40
> [Tue Apr 8 12:19:07 2025] schedule+0x27/0xf0
> [Tue Apr 8 12:19:07 2025] schedule_timeout+0x77/0xf0
> [Tue Apr 8 12:19:07 2025] ? __pfx_process_timeout+0x10/0x10
> [Tue Apr 8 12:19:07 2025] msleep_interruptible+0x49/0x60
> [Tue Apr 8 12:19:07 2025] read_dummy_semaphore+0x2d/0x60
> [Tue Apr 8 12:19:07 2025] full_proxy_read+0x5f/0xa0
> [Tue Apr 8 12:19:07 2025] vfs_read+0xbc/0x350
> [Tue Apr 8 12:19:07 2025] ? __count_memcg_events+0xa5/0x140
> [Tue Apr 8 12:19:07 2025] ? count_memcg_events.constprop.0+0x1a/0x30
> [Tue Apr 8 12:19:07 2025] ? handle_mm_fault+0x180/0x260
> [Tue Apr 8 12:19:07 2025] ksys_read+0x66/0xe0
> [Tue Apr 8 12:19:07 2025] do_syscall_64+0x51/0x120
> [Tue Apr 8 12:19:07 2025] entry_SYSCALL_64_after_hwframe+0x76/0x7e
> [Tue Apr 8 12:19:07 2025] RIP: 0033:0x7f7c584a646e
> [Tue Apr 8 12:19:07 2025] RSP: 002b:00007ffdba8ce158 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
> [Tue Apr 8 12:19:07 2025] RAX: ffffffffffffffda RBX: 0000000000020000 RCX: 00007f7c584a646e
> [Tue Apr 8 12:19:07 2025] RDX: 0000000000020000 RSI: 00007f7c5839a000 RDI: 0000000000000003
> [Tue Apr 8 12:19:07 2025] RBP: 00007f7c5839a000 R08: 00007f7c58399010 R09: 0000000000000000
> [Tue Apr 8 12:19:07 2025] R10: fffffffffffffbc5 R11: 0000000000000246 R12: 0000000000000000
> [Tue Apr 8 12:19:07 2025] R13: 0000000000000003 R14: 0000000000020000 R15: 0000000000020000
> [Tue Apr 8 12:19:07 2025] </TASK>
>
> [1] https://lore.kernel.org/all/174046694331.2194069.15472952050240807469.stgit@mhiramat.tok.corp.google.com
>
> Suggested-by: Andrew Morton <akpm@...ux-foundation.org>
> Suggested-by: Masami Hiramatsu (Google) <mhiramat@...nel.org>
> Signed-off-by: Mingzhe Yang <mingzhe.yang@...com>
> Signed-off-by: Lance Yang <ioworker0@...il.com>
> Reviewed-by: Masami Hiramatsu (Google) <mhiramat@...nel.org>
Thanks for your patch, which is now commit 194a9b9e843b4077
("hung_task: show the blocker task if the task is hung on
semaphore") in v6.16-rc1.
Eero reported [1] two WARNINGS seen with v6.16 on emulated Atari.
I managed to reproduce it on ARAnyM using the provided config (it does
not happen with atari_defconfig), and bisected it to this commit:
------------[ cut here ]------------
WARNING: CPU: 0 PID: 39 at include/linux/hung_task.h:48
__down_common+0x13a/0x1be
CPU: 0 UID: 0 PID: 39 Comm: getty Not tainted
6.15.0-rc6hatari-00018-g194a9b9e843b #1986 NONE
Stack from 01633d00:
01633d00 00366e9e 00366e9e 00000000 002c9762 00360cb5 01633d24 0000873e
00366e9e 01633d40 0002e0d4 00360cb5 00000030 00000009 0039c79a 00061408
01633d78 000028e0 00360cb5 00000030 002c9762 00000009 00000000 00000000
7fffffff 00000002 1185d266 01633eb0 01326c58 00000080 01633dc0 002c9762
00360cb5 00000030 00000009 00000000 00002014 01326c00 1185d266 01633eb0
002c93ea 00053d60 00061408 01326c58 0038db90 0038db90 01633e32 01633fb8
Call Trace: [<002c9762>] __down_common+0x13a/0x1be
[<0000873e>] dump_stack+0x10/0x16
[<0002e0d4>] __warn+0x7a/0xbc
[<00061408>] msleep+0x0/0x2c
[<000028e0>] warn_slowpath_fmt+0x42/0x62
[<002c9762>] __down_common+0x13a/0x1be
[<002c9762>] __down_common+0x13a/0x1be
[<00002014>] arch_local_irq_enable+0xe/0x22
[<002c93ea>] mutex_lock+0x0/0x28
[<00053d60>] other_cpu_in_panic+0x0/0x26
[<00061408>] msleep+0x0/0x2c
[<002c97fc>] __down+0x16/0x1e
[<002c9832>] down+0x2e/0x30
[<00053dac>] console_lock+0x26/0x4c
[<001aae4e>] do_con_write+0x3a/0x16d4
[<002c93ea>] mutex_lock+0x0/0x28
[<0004fa70>] __add_wait_queue+0x3a/0x6a
[<001ac520>] con_write+0x1a/0x30
[<0019cafa>] n_tty_write+0x2c6/0x35e
[<00199456>] signal_pending+0x0/0x26
[<000aba2a>] __kvmalloc_node_noprof+0x3a/0x114
[<00004cc0>] io_uring_try_cancel_requests+0x98/0x318
[<0004fb2e>] woken_wake_function+0x0/0x24
[<0019a180>] file_tty_write.isra.0+0x144/0x1b8
[<0019a206>] tty_write+0x12/0x16
[<000b97c2>] vfs_write+0xec/0x148
[<00028000>] fp_getdest+0x1b8/0x224
[<00010000>] g_trace+0x16/0x28
[<000b9916>] ksys_write+0x54/0x8a
[<000b9962>] sys_write+0x16/0x1a
[<000093da>] syscall+0x8/0xc
[<0000c001>] arch_dma_prep_coherent+0x51/0x58
---[ end trace 0000000000000000 ]---
------------[ cut here ]------------
WARNING: CPU: 0 PID: 39 at include/linux/hung_task.h:56
__down_common+0x17a/0x1be
CPU: 0 UID: 0 PID: 39 Comm: getty Tainted: G W
6.15.0-rc6hatari-00018-g194a9b9e843b #1986 NONE
Tainted: [W]=WARN
Stack from 01633d00:
01633d00 00366e9e 00366e9e 00000000 002c97a2 00360cb5 01633d24 0000873e
00366e9e 01633d40 0002e0d4 00360cb5 00000038 00000009 0039c79a 01633db2
01633d78 000028e0 00360cb5 00000038 002c97a2 00000009 00000000 00000000
00000000 00000002 00000000 00000000 01326c58 0039c79a 01633dc0 002c97a2
00360cb5 00000038 00000009 00000000 00002014 01326c00 1185d266 01633eb0
002c93ea 00053d60 00061408 01326c58 00380000 01000000 01220162 b64001b8
Call Trace: [<002c97a2>] __down_common+0x17a/0x1be
[<0000873e>] dump_stack+0x10/0x16
[<0002e0d4>] __warn+0x7a/0xbc
[<000028e0>] warn_slowpath_fmt+0x42/0x62
[<002c97a2>] __down_common+0x17a/0x1be
[<002c97a2>] __down_common+0x17a/0x1be
[<00002014>] arch_local_irq_enable+0xe/0x22
[<002c93ea>] mutex_lock+0x0/0x28
[<00053d60>] other_cpu_in_panic+0x0/0x26
[<00061408>] msleep+0x0/0x2c
[<002c97fc>] __down+0x16/0x1e
[<002c9832>] down+0x2e/0x30
[<00053dac>] console_lock+0x26/0x4c
[<001aae4e>] do_con_write+0x3a/0x16d4
[<002c93ea>] mutex_lock+0x0/0x28
[<0004fa70>] __add_wait_queue+0x3a/0x6a
[<001ac520>] con_write+0x1a/0x30
[<0019cafa>] n_tty_write+0x2c6/0x35e
[<00199456>] signal_pending+0x0/0x26
[<000aba2a>] __kvmalloc_node_noprof+0x3a/0x114
[<00004cc0>] io_uring_try_cancel_requests+0x98/0x318
[<0004fb2e>] woken_wake_function+0x0/0x24
[<0019a180>] file_tty_write.isra.0+0x144/0x1b8
[<0019a206>] tty_write+0x12/0x16
[<000b97c2>] vfs_write+0xec/0x148
[<00028000>] fp_getdest+0x1b8/0x224
[<00010000>] g_trace+0x16/0x28
[<000b9916>] ksys_write+0x54/0x8a
[<000b9962>] sys_write+0x16/0x1a
[<000093da>] syscall+0x8/0xc
[<0000c001>] arch_dma_prep_coherent+0x51/0x58
---[ end trace 0000000000000000 ]---
It still happens on v6.17-rc2. Reverting commits 77da18de55ac6417
("hung_task: extend hung task blocker tracking to rwsems") and
194a9b9e843b4077 ("hung_task: show the blocker task if the task is
hung on semaphore") fixes the issue for me.
Thanks!
[1] "v6.16 console issues on Atari Falcon"
https://lore.kernel.org/all/92518308-c763-4591-96ef-6b38c5d8f434@helsinkinet.fi
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Powered by blists - more mailing lists