Re: [PATCH for-akpm for-6.14-rcX] NFS: fix nfs_release_folio() to not call nfs_wb_folio() from kcompactd

Andrew Morton
2025-02-26T22:02:13Z

On Wed, 26 Feb 2025 06:58:11 -0800 Christoph Hellwig <hch@infradead.org> wrote:

> On Mon, Feb 24, 2025 at 07:33:01PM -0500, Mike Snitzer 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.
> >
> > Otherwise NFS can deadlock waiting for kcompactd enduced writeback
> > which recurses back to NFS (which triggers writeback to NFSD via
> > NFS loopback mount on the same host, NFSD blocks waiting for XFS's
> > call to __filemap_get_folio):
>
> Having a flag for a specific kernel thread feels wrong.

Why do you think this?

We are getting a bit short of space in tsk->flags. Five PF__HOLE__'s remain.

For this patch and for kswapd I guess we could simply record the
task_struct*'s in a static array, something like

static struct task_struct nice_name[max nodes];

...

if (current == nice_name[my node])
...

It's something we can look at if we start getting really tight on PF_ space.