From: Wu Fengguang <fengguang.wu@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andi Kleen <andi@firstfloor.org>, Jan Kara <jack@suse.cz>,
Wu Fengguang <fengguang.wu@intel.com>
Cc: Linux Memory Management List <linux-mm@kvack.org>,
<linux-fsdevel@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 10/10] readahead: snap readahead request to EOF
Date: Mon, 19 Dec 2011 18:23:18 +0800 [thread overview]
Message-ID: <20111219102357.846551861@intel.com> (raw)
In-Reply-To: 20111219102308.488847921@intel.com
[-- Attachment #1: readahead-eof --]
[-- Type: text/plain, Size: 1926 bytes --]
If the file size is 20kb and readahead request is [0, 16kb),
it's better to expand the readahead request to [0, 20kb), which will
likely save one followup I/O for the ending [16kb, 20kb).
If the readahead request already covers EOF, trimm it down to EOF.
Also don't set the PG_readahead mark to avoid an unnecessary future
invocation of the readahead code.
This special handling looks worthwhile because small to medium sized
files are pretty common.
Acked-by: Jan Kara <jack@suse.cz>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
mm/readahead.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
--- linux-next.orig/mm/readahead.c 2011-12-19 16:09:45.000000000 +0800
+++ linux-next/mm/readahead.c 2011-12-19 16:10:04.000000000 +0800
@@ -457,6 +457,25 @@ unsigned long max_sane_readahead(unsigne
+ node_page_state(numa_node_id(), NR_FREE_PAGES)) / 2);
}
+static void snap_to_eof(struct file_ra_state *ra, struct address_space *mapping)
+{
+ pgoff_t eof = ((i_size_read(mapping->host)-1) >> PAGE_CACHE_SHIFT) + 1;
+ pgoff_t start = ra->start;
+ unsigned int size = ra->size;
+
+ /*
+ * skip backwards and random reads
+ */
+ if (ra->pattern > RA_PATTERN_MMAP_AROUND)
+ return;
+
+ size += min(size / 2, ra->ra_pages / 4);
+ if (start + size > eof) {
+ ra->size = eof - start;
+ ra->async_size = 0;
+ }
+}
+
/*
* Submit IO for the read-ahead request in file_ra_state.
*/
@@ -468,6 +487,8 @@ unsigned long ra_submit(struct file_ra_s
{
int actual;
+ snap_to_eof(ra, mapping);
+
actual = __do_page_cache_readahead(mapping, filp,
ra->start, ra->size, ra->async_size);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Wu Fengguang <fengguang.wu@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andi Kleen <andi@firstfloor.org>, Jan Kara <jack@suse.cz>,
Wu Fengguang <fengguang.wu@intel.com>,
Linux Memory Management List <linux-mm@kvack.org>,
linux-fsdevel@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 10/10] readahead: snap readahead request to EOF
Date: Mon, 19 Dec 2011 18:23:18 +0800 [thread overview]
Message-ID: <20111219102357.846551861@intel.com> (raw)
In-Reply-To: 20111219102308.488847921@intel.com
[-- Attachment #1: readahead-eof --]
[-- Type: text/plain, Size: 1926 bytes --]
If the file size is 20kb and readahead request is [0, 16kb),
it's better to expand the readahead request to [0, 20kb), which will
likely save one followup I/O for the ending [16kb, 20kb).
If the readahead request already covers EOF, trimm it down to EOF.
Also don't set the PG_readahead mark to avoid an unnecessary future
invocation of the readahead code.
This special handling looks worthwhile because small to medium sized
files are pretty common.
Acked-by: Jan Kara <jack@suse.cz>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
mm/readahead.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
--- linux-next.orig/mm/readahead.c 2011-12-19 16:09:45.000000000 +0800
+++ linux-next/mm/readahead.c 2011-12-19 16:10:04.000000000 +0800
@@ -457,6 +457,25 @@ unsigned long max_sane_readahead(unsigne
+ node_page_state(numa_node_id(), NR_FREE_PAGES)) / 2);
}
+static void snap_to_eof(struct file_ra_state *ra, struct address_space *mapping)
+{
+ pgoff_t eof = ((i_size_read(mapping->host)-1) >> PAGE_CACHE_SHIFT) + 1;
+ pgoff_t start = ra->start;
+ unsigned int size = ra->size;
+
+ /*
+ * skip backwards and random reads
+ */
+ if (ra->pattern > RA_PATTERN_MMAP_AROUND)
+ return;
+
+ size += min(size / 2, ra->ra_pages / 4);
+ if (start + size > eof) {
+ ra->size = eof - start;
+ ra->async_size = 0;
+ }
+}
+
/*
* Submit IO for the read-ahead request in file_ra_state.
*/
@@ -468,6 +487,8 @@ unsigned long ra_submit(struct file_ra_s
{
int actual;
+ snap_to_eof(ra, mapping);
+
actual = __do_page_cache_readahead(mapping, filp,
ra->start, ra->size, ra->async_size);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Wu Fengguang <fengguang.wu@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andi Kleen <andi@firstfloor.org>, Jan Kara <jack@suse.cz>,
Wu Fengguang <fengguang.wu@intel.com>
Cc: Linux Memory Management List <linux-mm@kvack.org>,
<linux-fsdevel@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 10/10] readahead: snap readahead request to EOF
Date: Mon, 19 Dec 2011 18:23:18 +0800 [thread overview]
Message-ID: <20111219102357.846551861@intel.com> (raw)
In-Reply-To: 20111219102308.488847921@intel.com
[-- Attachment #1: readahead-eof --]
[-- Type: text/plain, Size: 1623 bytes --]
If the file size is 20kb and readahead request is [0, 16kb),
it's better to expand the readahead request to [0, 20kb), which will
likely save one followup I/O for the ending [16kb, 20kb).
If the readahead request already covers EOF, trimm it down to EOF.
Also don't set the PG_readahead mark to avoid an unnecessary future
invocation of the readahead code.
This special handling looks worthwhile because small to medium sized
files are pretty common.
Acked-by: Jan Kara <jack@suse.cz>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
mm/readahead.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
--- linux-next.orig/mm/readahead.c 2011-12-19 16:09:45.000000000 +0800
+++ linux-next/mm/readahead.c 2011-12-19 16:10:04.000000000 +0800
@@ -457,6 +457,25 @@ unsigned long max_sane_readahead(unsigne
+ node_page_state(numa_node_id(), NR_FREE_PAGES)) / 2);
}
+static void snap_to_eof(struct file_ra_state *ra, struct address_space *mapping)
+{
+ pgoff_t eof = ((i_size_read(mapping->host)-1) >> PAGE_CACHE_SHIFT) + 1;
+ pgoff_t start = ra->start;
+ unsigned int size = ra->size;
+
+ /*
+ * skip backwards and random reads
+ */
+ if (ra->pattern > RA_PATTERN_MMAP_AROUND)
+ return;
+
+ size += min(size / 2, ra->ra_pages / 4);
+ if (start + size > eof) {
+ ra->size = eof - start;
+ ra->async_size = 0;
+ }
+}
+
/*
* Submit IO for the read-ahead request in file_ra_state.
*/
@@ -468,6 +487,8 @@ unsigned long ra_submit(struct file_ra_s
{
int actual;
+ snap_to_eof(ra, mapping);
+
actual = __do_page_cache_readahead(mapping, filp,
ra->start, ra->size, ra->async_size);
next prev parent reply other threads:[~2011-12-19 10:23 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-19 10:23 [PATCH 00/10] readahead stats/tracing, backwards prefetching and more (v3) Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` [PATCH 01/10] block: limit default readahead size for small devices Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` [PATCH 02/10] readahead: make context readahead more conservative Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` [PATCH 03/10] readahead: record readahead patterns Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` [PATCH 04/10] readahead: tag mmap page fault call sites Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` [PATCH 05/10] readahead: tag metadata " Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` [PATCH 06/10] readahead: add vfs/readahead tracing event Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` [PATCH 07/10] readahead: add /debug/readahead/stats Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-23 12:59 ` [PATCH 07/10 v2] " Wu Fengguang
2011-12-23 12:59 ` Wu Fengguang
2011-12-23 13:48 ` Jan Kara
2011-12-23 13:48 ` Jan Kara
2011-12-19 10:23 ` [PATCH 08/10] readahead: basic support for backwards prefetching Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` [PATCH 09/10] readahead: dont do start-of-file readahead after lseek() Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang [this message]
2011-12-19 10:23 ` [PATCH 10/10] readahead: snap readahead request to EOF Wu Fengguang
2011-12-19 10:23 ` Wu Fengguang
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=20111219102357.846551861@intel.com \
--to=fengguang.wu@intel.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=jack@suse.cz \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.