Re: [PATCH v2 for-akpm for-6.14-rcX] NFS: fix nfs_release_folio() to not deadlock via kcompactd writeback

Andrew Morton
2025-02-25T06:53:11Z

On Mon, 24 Feb 2025 21:20:02 -0500 Mike Snitzer <snitzer@kernel.org> wrote:

> Add PF_KCOMPACTD flag and current_is_kcompactd() helper to check for
> it so nfs_release_folio() can skip calling nfs_wb_folio() from
> kcompactd.
>

--- a/mm/compaction.c~a
+++ a/mm/compaction.c
@@ -3182,7 +3182,7 @@ static int kcompactd(void *p)
long default_timeout = msecs_to_jiffies(HPAGE_FRAG_CHECK_INTERVAL_MSEC);
long timeout = default_timeout;

- tsk->flags |= PF_KCOMPACTD;
+ current->flags |= PF_KCOMPACTD;
set_freezable();

pgdat->kcompactd_max_order = 0;
@@ -3239,7 +3239,7 @@ static int kcompactd(void *p)
pgdat->proactive_compact_trigger = false;
}

- tsk->flags &= ~PF_KCOMPACTD;
+ current->flags &= ~PF_KCOMPACTD;

return 0;
}

I am of course concerned about how well tested this was!