[PATCH 0/9] readahead stats/tracing, backwards prefetching and more (v5)

February 11th, 2012 - 05:00 am ET by Wu Fengguang | Report spam
Andrew,

This introduces the per-cpu readahead stats, tracing, backwards prefetching,
fixes context readahead for SSD random reads and does some other minor changes.

Changes since v4:
- fix changelog for readahead stats

Changes since v3:
- default to CONFIG_READAHEAD_STATS=n
- drop "block: limit default readahead size for small devices"
(and expect some distro udev rules to do the job)
- use percpu_counter for the readahead stats

Changes since v2:
- use per-cpu counters for readahead stats
- make context readahead more conservative
- simplify readahead tracing format and use __print_symbolic()
- backwards prefetching and snap to EOF fixes and cleanups

Changes since v1:
- use bit fields: pattern, for_mmap, for_metadata, lseek
- comment the various readahead patterns
- drop boot options "readahead=" and "readahead_stats="
- add for_metadata
- add snapping to EOF

[PATCH 1/9] readahead: make context readahead more conservative
[PATCH 2/9] readahead: record readahead patterns
[PATCH 3/9] readahead: tag mmap page fault call sites
[PATCH 4/9] readahead: tag metadata call sites
[PATCH 5/9] readahead: add vfs/readahead tracing event
[PATCH 6/9] readahead: add /debug/readahead/stats
[PATCH 7/9] readahead: dont do start-of-file readahead after lseek()
[PATCH 8/9] readahead: snap readahead request to EOF
[PATCH 9/9] readahead: basic support for backwards prefetching

fs/Makefile | 1
fs/ext3/dir.c | 1
fs/ext4/dir.c | 1
fs/read_write.c | 3
fs/trace.c | 2
include/linux/fs.h | 41 ++++
include/linux/mm.h | 4
include/trace/events/vfs.h | 78 ++++++++
mm/Kconfig | 15 +
mm/filemap.c | 9 -
mm/readahead.c | 310 +++++++++++++++++++++++++++++++++--
11 files changed, 450 insertions(+), 15 deletions(-)

Thanks,
Fengguang

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
email Follow the discussionReplies 1 replyReplies Make a reply

Replies

#1 Wu Fengguang
February 11th, 2012 - 05:00 am ET | Report spam
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
Signed-off-by: Wu Fengguang

mm/readahead.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

linux-next.orig/mm/readahead.c 2012-01-25 15:57:58.000000000 +0800
+++ linux-next/mm/readahead.c 2012-01-25 15:57:59.000000000 +0800
@@ -466,6 +466,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.
*/
@@ -477,6 +496,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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Similar topics