From: Lance Yang <lance.yang@linux.dev>
To: "Nanji Parmar (he/him)" <nparmar@purestorage.com>
Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] hung_task: Skip hung task detection during core dump operations
Date: Thu, 14 Aug 2025 12:30:44 +0800 [thread overview]
Message-ID: <b7e7670b-c665-4938-aa38-5813e8e85b00@linux.dev> (raw)
In-Reply-To: <CAEK+-Od=j88QND5pZ-K_23fwmacy9enxogzNLxH4PjPYotDh9A@mail.gmail.com>
On 2025/8/14 11:31, Nanji Parmar (he/him) wrote:
> Hi Lance, Andrew,
>
> Thanks for looking into this.
> After checking further, we found that the following patch fixed that
> issue. Thank you once again.
Ah, I see. That's why I couldn't reproduce it on 6.16 kernel — the
fix was already there ;)
Thanks for digging this up!
Lance
>
> commit b8e753128ed074fcb48e9ceded940752f6b1c19f
> Author: Paul E. McKenney <paulmck@kernel.org <mailto:paulmck@kernel.org>>
> Date: Wed Jul 24 17:51:52 2024
>
> exit: Sleep at TASK_IDLE when waiting for application core dump
>
> Currently, the coredump_task_exit() function sets the task state
> to TASK_UNINTERRUPTIBLE|TASK_FREEZABLE, which usually works well.
> But a combination of large memory and slow (and/or highly contended)
> mass storage can cause application core dumps to take more than
> two minutes, which can cause check_hung_task(), which is invoked by
> check_hung_uninterruptible_tasks(), to produce task-blocked splats.
> There does not seem to be any reasonable benefit to getting these
> splats.
>
> Furthermore, as Oleg Nesterov points out, TASK_UNINTERRUPTIBLE could
> be misleading because the task sleeping in coredump_task_exit() really
> is killable, albeit indirectly. See the check of signal->core_state
> in prepare_signal() and the check of fatal_signal_pending()
> in dump_interrupted(), which bypass the normal unkillability of
> TASK_UNINTERRUPTIBLE, resulting in coredump_finish() invoking
> wake_up_process() on any threads sleeping in coredump_task_exit().
>
> Therefore, change that TASK_UNINTERRUPTIBLE to TASK_IDLE.
>
> Reported-by: Anhad Jai Singh <ffledgling@meta.com
> <mailto:ffledgling@meta.com>>
> Signed-off-by: Paul E. McKenney <paulmck@kernel.org
> <mailto:paulmck@kernel.org>>
> Acked-by: Oleg Nesterov <oleg@redhat.com <mailto:oleg@redhat.com>>
> Cc: Jens Axboe <axboe@kernel.dk <mailto:axboe@kernel.dk>>
> Cc: Christian Brauner <brauner@kernel.org <mailto:brauner@kernel.org>>
> Cc: Andrew Morton <akpm@linux-foundation.org <mailto:akpm@linux-
> foundation.org>>
> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org
> <mailto:willy@infradead.org>>
> Cc: Chris Mason <clm@fb.com <mailto:clm@fb.com>>
> Cc: Rik van Riel <riel@surriel.com <mailto:riel@surriel.com>>
>
> diff --git a/kernel/exit.c b/kernel/exit.c
> index 7430852a8571..0d62a53605df 100644
> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -428,7 +428,7 @@ static void coredump_task_exit(struct task_struct *tsk)
> complete(&core_state->startup);
>
> for (;;) {
> - set_current_state(TASK_UNINTERRUPTIBLE|
> TASK_FREEZABLE);
> + set_current_state(TASK_IDLE|TASK_FREEZABLE);
> if (!self.task) /* see coredump_finish() */
> break;
> schedule();
>
> Thanks,
> Nanji
>
> On Wed, Aug 13, 2025 at 8:12 PM Lance Yang <lance.yang@linux.dev
> <mailto:lance.yang@linux.dev>> wrote:
>
> Hi Nanji,
>
> Thanks for your patch!
>
> On 2025/8/14 06:01, Andrew Morton wrote:
> > On Wed, 13 Aug 2025 11:30:36 -0700 "Nanji Parmar (he/him)"
> <nparmar@purestorage.com <mailto:nparmar@purestorage.com>> wrote:
> >
> >> Tasks involved in core dump operations can legitimately block for
> >> extended periods, especially for large memory processes. The hung
> >> task detector should skip tasks with PF_DUMPCORE (main dumping
> >> thread) or PF_POSTCOREDUMP (other threads in the group) flags to
> >> avoid false positive warnings.
> >>
> >> This prevents incorrect hung task reports during legitimate core
> >> dump generation that can take xx minutes for large processes.
> >
> > It isn't pleasing to be putting coredump special cases into the
> core of
> > the hung-task detector. Perhaps the hung task detector should get an
>
> Yeah, adding a special case for coredumps is not a good design ;)
>
> > equivalent to touch_softlockup_watchdog(). I'm surprised it doesn't
> > already have such a thing. Maybe it does and I've forgotten
> where it is.
> >
> > Please provide a full description of the problem, mainly the relevant
> > dmesg output. Please always provide this full description when
> > addressing kernel issues, thanks.
>
> Interestingly, I wasn't able to reproduce the hung task warning on my
> machine with a SSD, even when generating a 100 GiB coredump. The process
> switches between R and D states so fast that it never hits the timeout,
> even with hung_task_timeout_secs set as low as 5s ;)
>
> So it seems this isn't a general problem for all coredumps. It look like
> it only happens on systems with slow I/O, which can cause a process to
> stay in a D-state for a long time.
>
> Anyway, any task *actually* blocked on I/O for that long should be
> flagged;
> that is the hung task detector's job, IMHO.
>
> Thanks,
> Lance
>
>
next prev parent reply other threads:[~2025-08-14 4:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 18:30 Nanji Parmar (he/him)
2025-08-13 22:01 ` Andrew Morton
2025-08-14 3:12 ` Lance Yang
[not found] ` <CAEK+-Od=j88QND5pZ-K_23fwmacy9enxogzNLxH4PjPYotDh9A@mail.gmail.com>
2025-08-14 4:30 ` Lance Yang [this message]
2025-08-14 6:58 ` Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b7e7670b-c665-4938-aa38-5813e8e85b00@linux.dev \
--to=lance.yang@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=nparmar@purestorage.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®