From: Lance Yang <lance.yang@linux.dev>
To: Julian Sun <sunjunchao@bytedance.com>, mhiramat@kernel.org
Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz,
mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, akpm@linux-foundation.org,
agruenba@redhat.com, hannes@cmpxchg.org, mhocko@kernel.org,
roman.gushchin@linux.dev, shakeel.butt@linux.dev,
muchun.song@linux.dev, linux-kernel@vger.kernel.org,
cgroups@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 0/3] Suppress undesirable hung task warnings.
Date: Mon, 22 Sep 2025 21:12:44 +0800 [thread overview]
Message-ID: <9425363e-944f-4f37-bc5b-2586e44a5c5d@linux.dev> (raw)
In-Reply-To: <fd12dd70-5de8-43bb-a4d8-610b5f5251fa@bytedance.com>
On 2025/9/22 20:40, Julian Sun wrote:
> On 9/22/25 7:38 PM, Lance Yang wrote:
>
> Hi, Lance
>
> Thanks for your review and comments.
>
>> Hi Julian
>>
>> Thanks for the patch series!
>>
>> On 2025/9/22 17:41, Julian Sun wrote:
>>> As suggested by Andrew Morton in [1], we need a general mechanism
>>> that allows the hung task detector to ignore unnecessary hung
>>
>> Yep, I understand the goal is to suppress what can be a benign hung task
>> warning during memcg teardown.
>>
>>> tasks. This patch set implements this functionality.
>>>
>>> Patch 1 introduces a PF_DONT_HUNG flag. The hung task detector will
>>> ignores all tasks that have the PF_DONT_HUNG flag set.
>>
>> However, I'm concerned that the PF_DONT_HUNG flag is a bit too powerful
>> and might mask real, underlying hangs.
>
> The flag takes effect only when wait_event_no_hung() or
> wb_wait_for_completion_no_hung() is called, and its effect is limited to
> a single wait event, without affecting subsequent wait events. So AFAICS
> it will not mask real hang warnings.>
Emm... the risk of future misuse is what worries me. I would rather have
call sites actively "pet the watchdog" by periodically calling a helper
like touch_hung_task_detector(), instead of passively ignoring the detector.
>>>
>>> Patch 2 introduces wait_event_no_hung() and
>>> wb_wait_for_completion_no_hung(),
>>> which enable the hung task detector to ignore hung tasks caused by these
>>> wait events.
>>
>> Instead of making the detector ignore the task, what if we just change
>> the waiting mechanism? Looking at wb_wait_for_completion(), we could
>> introduce a new helper that internally uses wait_event_timeout() in a
>> loop.
>>
>> Something simple like this:
>>
>> void wb_wait_for_completion_no_hung(struct wb_completion *done)
>> {
>> atomic_dec(&done->cnt);
>> while (atomic_read(&done->cnt))
>> wait_event_timeout(*done->waitq, !atomic_read(&done-
>> >cnt), timeout);
>> }
>>
>> The periodic wake-ups from wait_event_timeout() would naturally prevent
>> the detector from complaining about slow but eventually completing
>> writeback.
>
> Yeah, this could definitely eliminate the hung task warning complained
> here.
> However what I aim to provide is a general mechanism for waiting on
> events. Of course, we could use code similar to the following, but this
> would introduce additional overhead from waking tasks and multiple
> operations on wq_head—something I don't want to introduce.
Yeah, I agree there's some overhead with a polling approach, but
mem_cgroup_css_free() should be an infrequent operation. So, I think it's
an acceptable trade-off :)
>
> +#define wait_event_no_hung(wq_head, condition) \
> +do { \
> + while (!(condition)) \
> + wait_event_timeout(wq_head, condition, timeout); \
> +}
>
> But I can try this approach or do not introcude wait_event_no_hung() if
> you want.>
Well, let's see what other folks think ;)
Cheers,
Lance
>>>
>>> Patch 3 uses wb_wait_for_completion_no_hung() in the final phase of
>>> memcg
>>> teardown to eliminate the hung task warning.
>>>
>>> Julian Sun (3):
>>> sched: Introduce a new flag PF_DONT_HUNG.
>>> writeback: Introduce wb_wait_for_completion_no_hung().
>>> memcg: Don't trigger hung task when memcg is releasing.
>>>
>>> fs/fs-writeback.c | 15 +++++++++++++++
>>> include/linux/backing-dev.h | 1 +
>>> include/linux/sched.h | 12 +++++++++++-
>>> include/linux/wait.h | 15 +++++++++++++++
>>> kernel/hung_task.c | 6 ++++++
>>> mm/memcontrol.c | 2 +-
>>> 6 files changed, 49 insertions(+), 2 deletions(-)
>>>
>>
>
> Thanks,
next prev parent reply other threads:[~2025-09-22 13:13 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-22 9:41 [PATCH 0/3] Suppress undesirable hung task warnings Julian Sun
2025-09-22 9:41 ` [PATCH 1/3] sched: Introduce a new flag PF_DONT_HUNG Julian Sun
2025-09-22 9:41 ` [PATCH 2/3] writeback: Introduce wb_wait_for_completion_no_hung() Julian Sun
2025-09-22 9:41 ` [PATCH 3/3] memcg: Don't trigger hung task warnings when memcg is releasing resources Julian Sun
2025-09-22 11:38 ` [PATCH 0/3] Suppress undesirable hung task warnings Lance Yang
2025-09-22 12:40 ` Julian Sun
2025-09-22 13:12 ` Lance Yang [this message]
2025-09-22 21:57 ` Andrew Morton
2025-09-23 2:30 ` Lance Yang
2025-09-23 2:45 ` [External] " Julian Sun
2025-09-23 3:18 ` Lance Yang
2025-09-22 13:07 ` Michal Hocko
2025-09-22 14:24 ` [External] " Julian Sun
2025-09-22 13:27 ` Peter Zijlstra
2025-09-22 14:29 ` [External] " Julian Sun
2025-09-22 15:27 ` Jan Kara
2025-09-22 18:08 ` Christoph Hellwig
2025-09-22 21:50 ` Andrew Morton
2025-09-23 7:16 ` Peter Zijlstra
2025-09-23 12:44 ` Masami Hiramatsu
2025-09-24 10:34 ` Jan Kara
2025-09-25 15:07 ` [External] " Julian Sun
2025-09-25 16:30 ` Jan Kara
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=9425363e-944f-4f37-bc5b-2586e44a5c5d@linux.dev \
--to=lance.yang@linux.dev \
--cc=agruenba@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=bsegall@google.com \
--cc=cgroups@vger.kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=hannes@cmpxchg.org \
--cc=jack@suse.cz \
--cc=juri.lelli@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mhiramat@kernel.org \
--cc=mhocko@kernel.org \
--cc=mingo@redhat.com \
--cc=muchun.song@linux.dev \
--cc=peterz@infradead.org \
--cc=roman.gushchin@linux.dev \
--cc=rostedt@goodmis.org \
--cc=shakeel.butt@linux.dev \
--cc=sunjunchao@bytedance.com \
--cc=vincent.guittot@linaro.org \
--cc=viro@zeniv.linux.org.uk \
--cc=vschneid@redhat.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;
as well as URLs for NNTP newsgroup(s).