linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peng Zhang <zhangpengpeng0808@gmail.com>
To: willy@infradead.org, akpm@linux-foundation.org,
	linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Cc: bruzzhang <bruzzhang@tencent.com>,
	Rongwei Wang <zigiwang@tencent.com>,
	Vern Hao <vernhao@tencent.com>
Subject: [PATCH RFC] mm/readahead: Fix repeat initial_readahead
Date: Tue, 18 Jun 2024 19:49:41 +0800	[thread overview]
Message-ID: <20240618114941.5935-1-zhangpengpeng0808@gmail.com> (raw)

From: bruzzhang <bruzzhang@tencent.com>

Now, if read from start of file, readahead
state will be repeatly initialized when
first time async readahead after sync one.
This case likes:

sequence read
page_cache_sync_readahead()
  --> ondemand_readahead() <-- initial ra
  --> folio ready <-- order=2, readahead flags
folio_test_readahead(folio)
filemap_readahead() <-- async readahead
 --> ondemand_readahead() <-- initial ra again

The second initialization of ra seems a
mistake, and right ra window
(start, size, async_size) should be (4,8,8)
instead of (0,4,3) after async readahead.

What's more, this patch can improve sequence
read greatly, the result of test as following:

case name             upstream    upstream+fix  speedup
----------            --------    ------------  --------
randread-4k-sync      48981.00    48948.0000    -0.0674%
seqread-4k-sync       1162630.00  1334915.00    14.8186%
randread-4k-libaio    47561.00    49910.00      4.9389%
seqread-4k-libaio     1058526.00  1257134.00    18.7627%
seqread-1024k-libaio  1365866.00  1411463.00    3.3383%

Signed-off-by: bruzzhang <bruzzhang@tencent.com>
Signed-off-by: Rongwei Wang <zigiwang@tencent.com>
Signed-off-by: Vern Hao <vernhao@tencent.com>
---
 mm/readahead.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/readahead.c b/mm/readahead.c
index c1b23989d..498708b4b 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -571,7 +571,7 @@ static void ondemand_readahead(struct readahead_control *ractl,
 	/*
 	 * start of file
 	 */
-	if (!index)
+	if (!folio && !index)
 		goto initial_readahead;
 
 	/*
-- 
2.39.3


             reply	other threads:[~2024-06-18 11:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-18 11:49 Peng Zhang [this message]
2024-06-25  6:28 ` [PATCH RFC] mm/readahead: Fix repeat initial_readahead zippermonkey
2024-06-25 10:36   ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240618114941.5935-1-zhangpengpeng0808@gmail.com \
    --to=zhangpengpeng0808@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bruzzhang@tencent.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=vernhao@tencent.com \
    --cc=willy@infradead.org \
    --cc=zigiwang@tencent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).