]> git.baikalelectronics.ru Git - kernel.git/commit
mm/readahead: Fix readahead with large folios
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 27 Apr 2022 21:01:28 +0000 (17:01 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 5 May 2022 04:47:29 +0000 (00:47 -0400)
commit0189800432f746954d8da4a45e22342bc47d126c
tree08b633cfb49cf8ac4a07cb82d926be6d0857a9d9
parent8a6f129bf6b803001363916d231d5343d424a145
mm/readahead: Fix readahead with large folios

Reading 100KB chunks from a big file (eg dd bs=100K) leads to poor
readahead behaviour.  Studying the traces in detail, I noticed two
problems.

The first is that we were setting the readahead flag on the folio which
contains the last byte read from the block.  This is wrong because we
will trigger readahead at the end of the read without waiting to see
if a subsequent read is going to use the pages we just read.  Instead,
we need to set the readahead flag on the first folio _after_ the one
which contains the last byte that we're reading.

The second is that we were looking for the index of the folio with the
readahead flag set to exactly match the start + size - async_size.
If we've rounded this, either down (as previously) or up (as now),
we'll think we hit a folio marked as readahead by a different read,
and try to read the wrong pages.  So round the expected index to the
order of the folio we hit.

Reported-by: Guo Xuenan <guoxuenan@huawei.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
mm/readahead.c