Re: [PATCH 1/2] Revert "page cache: fix page_cache_next/prev_miss off by one"

From: Mike Kravetz
Date: Wed Jun 21 2023 - 19:02:40 EST


On 06/21/23 15:18, Andrew Morton wrote:
> On Wed, 21 Jun 2023 14:24:02 -0700 Mike Kravetz <mike.kravetz@xxxxxxxxxx> wrote:
>
> > This reverts commit 9425c591e06a9ab27a145ba655fb50532cf0bcc9
> >
> > The reverted commit fixed up routines primarily used by readahead code
> > such that they could also be used by hugetlb. Unfortunately, this
> > caused a performance regression as pointed out by the Closes: tag.
> >
> > The hugetlb code which uses page_cache_next_miss will be addressed in
> > a subsequent patch.
>
> Often these throughput changes are caused by rather random
> alignment/layout changes and the code change itself was innocent.
>
> Do we have an explanation for this regression, or was it a surprise?

It was not a total surprise. As mentioned, the primary user of this
interface is the readahead code. The code in question is in
ondemand_readahead.

rcu_read_lock();
start = page_cache_next_miss(ractl->mapping, index + 1,
max_pages);
rcu_read_unlock();

if (!start || start - index > max_pages)
return;

With the reverted changes, we will take that quick return when there are
no gaps in the range. Previously we did not.

I am of the belief that page_cache_next_miss behavior did not match the
function description. Matthew suggested page_cache_next_miss use in hugetlb
code and I can only guess that he also though it behaved as documented.

I do not know the readahead code well enough to know exactly what is
expected. readahead certainly performs worse with my proposed changes.
Since we can easily 'fix' hugetlb code in another way, let's do that and
leave the readahead code alone unless someone more knowledgable can
provide insight.
--
Mike Kravetz