From: Hillf Danton <hdanton@sina.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: linux-mm <linux-mm@kvack.org>, Hillf Danton <hdanton@sina.com>
Subject: [RFC] mm: readahead: change ra size for random read
Date: Fri, 20 Dec 2019 09:58:27 +0800 [thread overview]
Message-ID: <20191220015827.8904-1-hdanton@sina.com> (raw)
Set a smaller ra size for random read than contiguous one. It is
deemed random if the lower-level device is unable to meet the
read pattern even with its IO capability doubled.
Signed-off-by: Hillf Danton <hdanton@sina.com>
---
--- a/mm/readahead.c
+++ p/mm/readahead.c
@@ -388,6 +388,7 @@ ondemand_readahead(struct address_space
unsigned long max_pages = ra->ra_pages;
unsigned long add_pages;
pgoff_t prev_offset;
+ bool random = true;
/*
* If the request exceeds the readahead window, allow the read to
@@ -399,8 +400,34 @@ ondemand_readahead(struct address_space
/*
* start of file
*/
- if (!offset)
- goto initial_readahead;
+ if (!offset) {
+fill_ra:
+ ra->start = offset;
+ ra->size = random ?
+ min(bdi->io_pages, bdi->ra_pages) :
+ max(bdi->io_pages, bdi->ra_pages);
+
+ ra->async_size = ra->size > req_size ?
+ ra->size - req_size : ra->size;
+
+ return ra_submit(ra, mapping, filp);
+ } else {
+ unsigned long leap;
+
+ if (offset > ra->start)
+ leap = offset - ra->start;
+ else
+ leap = ra->start - offset;
+
+ /*
+ * anything other than page cache cannot help if it is
+ * too great a leap for the lower-level device to back
+ * up so feel free to put ra into fire
+ */
+ random = leap > max(bdi->io_pages, bdi->ra_pages) * 2;
+
+ goto fill_ra;
+ }
/*
* It's the expected callback offset, assume sequential access.
reply other threads:[~2019-12-20 1:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20191220015827.8904-1-hdanton@sina.com \
--to=hdanton@sina.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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