Re: [PATCH v2 2/2] memcg: Don't trigger hung task warnings when memcg is releasing resources.
From: Peter Zijlstra
Date: Wed Sep 24 2025 - 02:51:33 EST
On Wed, Sep 24, 2025 at 11:41:00AM +0800, Julian Sun wrote:
> Hung task warning in mem_cgroup_css_free() is undesirable and
> unnecessary since the behavior of waiting for a long time is
> expected.
>
> Use touch_hung_task_detector() to eliminate the possible
> hung task warning.
>
> Signed-off-by: Julian Sun <sunjunchao@xxxxxxxxxxxxx>
Still hate this. It is not tied to progress. If progress really stalls,
no warning will be given.
> mm/memcontrol.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 8dd7fbed5a94..fc73a56372a4 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -63,6 +63,7 @@
> #include <linux/seq_buf.h>
> #include <linux/sched/isolation.h>
> #include <linux/kmemleak.h>
> +#include <linux/nmi.h>
> #include "internal.h"
> #include <net/sock.h>
> #include <net/ip.h>
> @@ -3912,8 +3913,15 @@ static void mem_cgroup_css_free(struct cgroup_subsys_state *css)
> int __maybe_unused i;
>
> #ifdef CONFIG_CGROUP_WRITEBACK
> - for (i = 0; i < MEMCG_CGWB_FRN_CNT; i++)
> + for (i = 0; i < MEMCG_CGWB_FRN_CNT; i++) {
> + /*
> + * We don't want the hung task detector to report warnings
> + * here since there's nothing wrong if the writeback work
> + * lasts for a long time.
> + */
> + touch_hung_task_detector(current);
> wb_wait_for_completion(&memcg->cgwb_frn[i].done);
> + }
> #endif
> if (cgroup_subsys_on_dfl(memory_cgrp_subsys) && !cgroup_memory_nosocket)
> static_branch_dec(&memcg_sockets_enabled_key);
> --
> 2.39.5
>