mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fengguang Wu <wfg@mail.ustc.edu.cn>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Steven Pratt <slpratt@austin.ibm.com>
Cc: Ram Pai <linuxram@us.ibm.com>
Subject: [PATCH 2/9] readahead: add look-ahead support to __do_page_cache_readahead()
Date: Thu, 17 May 2007 06:47:54 +0800	[thread overview]
Message-ID: <379355695.11913@ustc.edu.cn> (raw)
Message-ID: <20070516224818.384876951@mail.ustc.edu.cn> (raw)
In-Reply-To: <20070516224752.500812933@mail.ustc.edu.cn>

[-- Attachment #1: readahead-add-look-ahead-support-to-__do_page_cache_readahead.patch --]
[-- Type: text/plain, Size: 2998 bytes --]

Add look-ahead support to __do_page_cache_readahead().

It works by
	- mark the Nth backwards page with PG_readahead,
	(which instructs the page's first reader to invoke readahead)
	- and only do the marking for newly allocated pages.
	(to prevent blindly doing readahead on already cached pages)

Look-ahead is a technique to achieve I/O pipelining:
While the application is working through a chunk of cached pages,
the kernel reads-ahead the next chunk of pages _before_ time of need.
It effectively hides low level I/O latencies to high level applications.

Signed-off-by: Fengguang Wu <wfg@mail.ustc.edu.cn>
---

 mm/readahead.c |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

--- linux-2.6.22-rc1-mm1.orig/mm/readahead.c
+++ linux-2.6.22-rc1-mm1/mm/readahead.c
@@ -265,7 +265,8 @@ out:
  */
 static int
 __do_page_cache_readahead(struct address_space *mapping, struct file *filp,
-			pgoff_t offset, unsigned long nr_to_read)
+			pgoff_t offset, unsigned long nr_to_read,
+			unsigned long lookahead_size)
 {
 	struct inode *inode = mapping->host;
 	struct page *page;
@@ -278,7 +279,7 @@ __do_page_cache_readahead(struct address
 	if (isize == 0)
 		goto out;
 
- 	end_index = ((isize - 1) >> PAGE_CACHE_SHIFT);
+	end_index = ((isize - 1) >> PAGE_CACHE_SHIFT);
 
 	/*
 	 * Preallocate as many pages as we will need.
@@ -301,6 +302,8 @@ __do_page_cache_readahead(struct address
 			break;
 		page->index = page_offset;
 		list_add(&page->lru, &page_pool);
+		if (page_idx == nr_to_read - lookahead_size)
+			SetPageReadahead(page);
 		ret++;
 	}
 	read_unlock_irq(&mapping->tree_lock);
@@ -337,7 +340,7 @@ int force_page_cache_readahead(struct ad
 		if (this_chunk > nr_to_read)
 			this_chunk = nr_to_read;
 		err = __do_page_cache_readahead(mapping, filp,
-						offset, this_chunk);
+						offset, this_chunk, 0);
 		if (err < 0) {
 			ret = err;
 			break;
@@ -384,7 +387,7 @@ int do_page_cache_readahead(struct addre
 	if (bdi_read_congested(mapping->backing_dev_info))
 		return -1;
 
-	return __do_page_cache_readahead(mapping, filp, offset, nr_to_read);
+	return __do_page_cache_readahead(mapping, filp, offset, nr_to_read, 0);
 }
 
 /*
@@ -404,7 +407,7 @@ blockable_page_cache_readahead(struct ad
 	if (!block && bdi_read_congested(mapping->backing_dev_info))
 		return 0;
 
-	actual = __do_page_cache_readahead(mapping, filp, offset, nr_to_read);
+	actual = __do_page_cache_readahead(mapping, filp, offset, nr_to_read, 0);
 
 	return check_ra_success(ra, nr_to_read, actual);
 }
@@ -449,7 +452,7 @@ static int make_ahead_window(struct addr
  * @req_size: hint: total size of the read which the caller is performing in
  *            PAGE_CACHE_SIZE units
  *
- * page_cache_readahead() is the main function.  If performs the adaptive
+ * page_cache_readahead() is the main function.  It performs the adaptive
  * readahead window size management and submits the readahead I/O.
  *
  * Note that @filp is purely used for passing on to the ->readpage[s]()

--

  parent reply	other threads:[~2007-05-16 22:49 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20070516224752.500812933@mail.ustc.edu.cn>
2007-05-16 22:47 ` [PATCH 0/9] on-demand readahead Fengguang Wu
     [not found] ` <20070516224818.384876951@mail.ustc.edu.cn>
2007-05-16 22:47   ` Fengguang Wu [this message]
     [not found] ` <20070516224818.544351896@mail.ustc.edu.cn>
2007-05-16 22:47   ` [PATCH 3/9] readahead: MIN_RA_PAGES/MAX_RA_PAGES macros Fengguang Wu
     [not found] ` <20070516224818.963553696@mail.ustc.edu.cn>
2007-05-16 22:47   ` [PATCH 6/9] readahead: convert filemap invocations Fengguang Wu
     [not found] ` <20070516224819.131727893@mail.ustc.edu.cn>
2007-05-16 22:47   ` [PATCH 7/9] readahead: convert splice invocations Fengguang Wu
     [not found] ` <20070516224819.281192313@mail.ustc.edu.cn>
2007-05-16 22:48   ` [PATCH 8/9] readahead: convert ext3/ext4 invocations Fengguang Wu
2007-05-19 12:19   ` Andi Kleen
     [not found] ` <20070516224819.420933490@mail.ustc.edu.cn>
2007-05-16 22:48   ` [PATCH 9/9] readahead: remove the old algorithm Fengguang Wu
2007-05-19 12:18   ` Andi Kleen
     [not found]     ` <20070519131713.GA6510@mail.ustc.edu.cn>
2007-05-19 13:17       ` Fengguang Wu
     [not found] ` <20070516224818.246719596@mail.ustc.edu.cn>
2007-05-16 22:47   ` [PATCH 1/9] readahead: introduce PG_readahead Fengguang Wu
2007-05-19  6:28     ` Andrew Morton
2007-05-19 11:35       ` Andi Kleen
2007-05-19 15:19         ` Andrew Morton
     [not found]       ` <20070519123031.GA6095@mail.ustc.edu.cn>
2007-05-19 12:30         ` Fengguang Wu
2007-05-19 15:25           ` Andrew Morton
     [not found]             ` <20070520030904.GA9176@mail.ustc.edu.cn>
2007-05-20  3:09               ` Fengguang Wu
2007-05-20  7:10                 ` Christoph Lameter
2007-06-12  1:04   ` Rusty Russell
     [not found]     ` <20070612025201.GA6447@mail.ustc.edu.cn>
2007-06-12  2:52       ` Fengguang Wu
     [not found] ` <20070516224818.683288460@mail.ustc.edu.cn>
2007-05-16 22:47   ` [PATCH 4/9] readahead: data structure and routines Fengguang Wu
2007-06-12  3:30   ` Rusty Russell
     [not found]     ` <20070612120706.GB9624@mail.ustc.edu.cn>
2007-06-12 12:07       ` Fengguang Wu
2007-06-13  0:27       ` Rusty Russell
     [not found]         ` <20070613030701.GA6494@mail.ustc.edu.cn>
2007-06-13  3:07           ` Fengguang Wu
     [not found] ` <20070516224818.841068730@mail.ustc.edu.cn>
2007-05-16 22:47   ` [PATCH 5/9] readahead: on-demand readahead logic Fengguang Wu
2007-05-19  6:23     ` Andrew Morton
     [not found]       ` <20070519130202.GB6095@mail.ustc.edu.cn>
2007-05-19 13:02         ` Fengguang Wu
2007-06-12  4:36   ` Rusty Russell
     [not found]     ` <20070612103518.GA9624@mail.ustc.edu.cn>
2007-06-12 10:35       ` Fengguang Wu
2007-06-13  1:40       ` Rusty Russell
     [not found]         ` <20070613040044.GB6494@mail.ustc.edu.cn>
2007-06-13  4:00           ` Fengguang Wu
2007-06-13  5:51           ` Rusty Russell
     [not found]             ` <20070613070724.GA6146@mail.ustc.edu.cn>
2007-06-13  7:07               ` Fengguang Wu

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=379355695.11913@ustc.edu.cn \
    --to=wfg@mail.ustc.edu.cn \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.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

Powered by JetHome