linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Readahead regressed with c1f6925e1091("mm: put readahead pages in cache earlier") on multicore arm64 platforms
       [not found]         ` <CAJMQK-j-=q3gHyB6hb-5HvTY6QGf8wCg9q99cfj7wTCT+He4mA@mail.gmail.com>
@ 2021-10-07 13:45           ` Matthew Wilcox
  2021-10-08  4:11             ` Hsin-Yi Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Wilcox @ 2021-10-07 13:45 UTC (permalink / raw)
  To: Hsin-Yi Wang
  Cc: Andrew Morton, William Kucharski, Christoph Hellwig, linux-mm,
	linux-fsdevel, Phillip Lougher

On Thu, Oct 07, 2021 at 03:08:38PM +0800, Hsin-Yi Wang wrote:
> This calls into squashfs_readpage().

Aha!  I hadn't looked at squashfs before, and now that I do, I can
see why this commit causes problems for squashfs.  (It would be
helpful if your report included more detail about which paths inside
squashfs were taken, but I think I can guess):

squashfs_readpage()
  squashfs_readpage_block()
    squashfs_copy_cache()
      grab_cache_page_nowait()

Before this patch, readahead of 1MB would allocate 256x4kB pages,
then add each one to the page cache and call ->readpage on it:

        for (page_idx = 0; page_idx < readahead_count(rac); page_idx++) {
                struct page *page = lru_to_page(pages);
                list_del(&page->lru);
                if (!add_to_page_cache_lru(page, rac->mapping, page->index,
                               gfp))
                        aops->readpage(rac->file, page);

When Squashfs sees it has more than 4kB of data, it calls
grab_cache_page_nowait(), which allocates more memory (ignoring the
other 255 pages which have been allocated, because they're not in the
page cache yet).  Then this loop frees the pages that readahead
allocated.

After this patch, the pages are already in the page cache when
->readpage is called the first time.  So the call to
grab_cache_page_nowait() fails and squashfs redoes the decompression for
each page.

Neither of these approaches are efficient.  Squashfs need to implement
->readahead.  Working on it now ...


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Readahead regressed with c1f6925e1091("mm: put readahead pages in cache earlier") on multicore arm64 platforms
  2021-10-07 13:45           ` Readahead regressed with c1f6925e1091("mm: put readahead pages in cache earlier") on multicore arm64 platforms Matthew Wilcox
@ 2021-10-08  4:11             ` Hsin-Yi Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Hsin-Yi Wang @ 2021-10-08  4:11 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Andrew Morton, William Kucharski, Christoph Hellwig, linux-mm,
	linux-fsdevel, Phillip Lougher

On Thu, Oct 7, 2021 at 9:46 PM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Thu, Oct 07, 2021 at 03:08:38PM +0800, Hsin-Yi Wang wrote:
> > This calls into squashfs_readpage().
>
> Aha!  I hadn't looked at squashfs before, and now that I do, I can
> see why this commit causes problems for squashfs.  (It would be
> helpful if your report included more detail about which paths inside
> squashfs were taken, but I think I can guess):
>
> squashfs_readpage()
>   squashfs_readpage_block()
>     squashfs_copy_cache()
>       grab_cache_page_nowait()
>
Right, before the patch, push_page won't be null but after the patch,
grab_cache_page_nowait() fails.


> Before this patch, readahead of 1MB would allocate 256x4kB pages,
> then add each one to the page cache and call ->readpage on it:
>
>         for (page_idx = 0; page_idx < readahead_count(rac); page_idx++) {
>                 struct page *page = lru_to_page(pages);
>                 list_del(&page->lru);
>                 if (!add_to_page_cache_lru(page, rac->mapping, page->index,
>                                gfp))
>                         aops->readpage(rac->file, page);
>
> When Squashfs sees it has more than 4kB of data, it calls
> grab_cache_page_nowait(), which allocates more memory (ignoring the
> other 255 pages which have been allocated, because they're not in the
> page cache yet).  Then this loop frees the pages that readahead
> allocated.
>
> After this patch, the pages are already in the page cache when
> ->readpage is called the first time.  So the call to
> grab_cache_page_nowait() fails and squashfs redoes the decompression for
> each page.
>
> Neither of these approaches are efficient.  Squashfs need to implement
> ->readahead.  Working on it now ...
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-08  4:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CAJMQK-g9G6KQmH-V=BRGX0swZji9Wxe_2c7ht-MMAapdFy2pXw@mail.gmail.com>
     [not found] ` <YV2GlrdkRMHGAPOE@casper.infradead.org>
     [not found]   ` <CAJMQK-hVH9uFLPnuySyfQ7o5d-m7gSXG5=Nx_7-92t82M0PMnQ@mail.gmail.com>
     [not found]     ` <YV2gpWYhcJxiDArT@casper.infradead.org>
     [not found]       ` <CAJMQK-i0wL7SAo3C5r2Ty9SaJhZ7OyO+DJdq-E3i9LBW_vJ4Jw@mail.gmail.com>
     [not found]         ` <CAJMQK-j-=q3gHyB6hb-5HvTY6QGf8wCg9q99cfj7wTCT+He4mA@mail.gmail.com>
2021-10-07 13:45           ` Readahead regressed with c1f6925e1091("mm: put readahead pages in cache earlier") on multicore arm64 platforms Matthew Wilcox
2021-10-08  4:11             ` Hsin-Yi Wang

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).