Re: [PATCH v2 1/4] mm/filemap: Add folio_lock_timeout()

Doug Anderson
2023-04-24T16:57:26Z

Hi,

On Fri, Apr 21, 2023 at 10:19 PM Hillf Danton <hdanton@sina.com> wrote:
>
> On 21 Apr 2023 15:12:45 -0700 Douglas Anderson <dianders@chromium.org>
> > Add a variant of folio_lock() that can timeout. This is useful to
> > avoid unbounded waits for the page lock in kcompactd.
>
> Given no mutex_lock_timeout() (perhaps because timeout makes no sense for
> spinlock), I suspect your fix lies in the right layer.

I'm not 100% sure I understood the above comment, but I think you're
saying that the approach my patch takes seems OK.

> If waiting for
> page under IO causes trouble for you, another simpler option is make
> IO faster (perhaps all you can do) for instance.

Yeah, this gets into the discussion about whether our current squashfs
settings actually make sense. I suspect that they don't and that we
should look into EROFS like Gao suggested, or at least choose
different squashfs settings (smaller block sizes, ZSTD instead of
zlib). Unfortunately I believe that the current squashfs settings were
chosen because disk space is a concern.

> If kcompactd is waken
> up by kswapd, waiting for slow IO is the right thing to do.

I don't have enough intuition here, so I'm happy to take others'
advice here. I guess my thought was that kcompactd is explicitly not
using the full "sync" and instead choosing the "sync light". To me
that means we shouldn't block for _too_ long.

-Doug